Page 121 of 158

Re: Coding Help

Posted: Tue Jan 05, 2021 5:34 pm
by milad1987
mrtools wrote: Tue Jan 05, 2021 7:44 am

Try this dll file in your libraries folder.
Mrtools thank you!

Re: Coding Help

Posted: Wed Jan 06, 2021 11:18 am
by traderduke
mrtools wrote: Tue Jan 05, 2021 8:01 am

Try.
mrtools
Thanks a lot, it works great

Ray

Re: Coding Help

Posted: Tue Jan 12, 2021 4:31 am
by Maffe
Hi

I have a script from back in 2015, now it is not working and I can see some errors while compiling, but have no idea how to fix them.

if anyone would help me id be greatful.

Thanks

Code: Select all

#property  copyright "Copyright © 2011, sangmane."
#property  link      
  
#import "EasyOrder.dll"
   int EasyOrder(int hwnd);

string obj;
int i, ticket;
   
int start()
{	
	int hwnd = WindowHandle(Symbol(),0);
	if(hwnd==0) {
		Alert("Error!");
		return;
	}
	int ret = EasyOrder(hwnd);
	Print("Return value: ",ret);	
	if(ret<0) {
		Alert("Dll function failed!");
		return;
	}	
	if(ret==1) ModifyOrder();
	else {
		for(i=ObjectsTotal()-1; i>=0; i--) {
			obj = ObjectName(i);
			if(StringFind(obj,"EASYORDER",0)>=0) ObjectDelete(obj);
		}	
	}
	InitLines();
	return (0);
}
//+------------------------------------------------------------------+

void InitLines()
{
	//Delete old lines
	bool delete;
	int pos;
	int ticket;
	for(i=ObjectsTotal()-1; i>=0; i--) {
		obj = ObjectName(i);
		if(StringFind(obj,"EASYORDER_MOD")>=0) {
			delete = True;
			pos = StringFind(obj,"#",1);
			if(pos<0) continue;
			ticket = StrToDouble(StringSubstr(obj,pos+1,StringLen(obj)-pos-1));
			if(OrderSelect(ticket,SELECT_BY_TICKET)) {
				if(OrderCloseTime()==0) delete = false;
			}
			if(delete) ObjectDelete(obj);
		}
	}
	double sl, tp;
	for(i=0; i<OrdersTotal(); i++) {
		OrderSelect(i,SELECT_BY_POS);
		if(OrderSymbol()==Symbol()) {
			ticket = OrderTicket();			
			obj = "EASYORDER_MOD_SL_#"+ticket;
			sl = OrderStopLoss();
			tp = OrderTakeProfit();
			if(sl==0) sl = OrderOpenPrice();
			if(tp==0) tp = OrderOpenPrice();
			if(ObjectFind(obj)>=0)	ObjectMove(obj,0,Time[0],sl);
			else DrawLine("SL",ticket,sl);
			obj = "EASYORDER_MOD_TP_#"+ticket;
			if(ObjectFind(obj)>=0)	ObjectMove(obj,0,Time[0],tp);
			else DrawLine("TP",ticket,tp);
			if(OrderType()>OP_SELL) {
				obj = "EASYORDER_MOD_PRICE_#"+ticket;
				if(ObjectFind(obj)>=0)	ObjectMove(obj,0,Time[0],OrderOpenPrice());
				else DrawLine("PRICE",ticket,OrderOpenPrice());				
			}
		}
	}
}

void ModifyOrder()
{
	string obj;
	int i, ticket;
	double sl, price, tp;
	double osl, otp;
	for(i=0; i<OrdersTotal(); i++) {
		OrderSelect(i,SELECT_BY_POS);
		if(OrderSymbol()==Symbol()) {
			ticket = OrderTicket();
			sl = 0; price = 0; tp = 0;
			obj = "EASYORDER_MOD_SL_#"+ticket;
			osl = OrderStopLoss();			
			if(osl==0) osl = OrderOpenPrice();
			otp = OrderStopLoss();
			if(otp==0) otp = OrderOpenPrice();			
			if(ObjectFind(obj)>=0)	{
				if(MathAbs(ObjectGet(obj,OBJPROP_PRICE1)-osl)>Point) sl = ObjectGet(obj,OBJPROP_PRICE1);
			}
			
			obj = "EASYORDER_MOD_TP_#"+ticket;
			if(ObjectFind(obj)>=0)	{
				if(MathAbs(ObjectGet(obj,OBJPROP_PRICE1)-otp)>Point) tp = ObjectGet(obj,OBJPROP_PRICE1);
			}
						
			if(OrderType()>OP_SELL) {
				obj = "EASYORDER_MOD_PRICE_#"+ticket;
				if(ObjectFind(obj)>=0)	{
					if(MathAbs(ObjectGet(obj,OBJPROP_PRICE1)-OrderOpenPrice())>Point) price = ObjectGet(obj,OBJPROP_PRICE1);
				}
			}
			
			if(sl+tp+price>0) {
				if(sl==0) sl = OrderStopLoss();
				if(tp==0) tp = OrderTakeProfit();
				if(price==0) price = OrderOpenPrice();
				OrderModify(ticket,price,sl,tp,0,CLR_NONE);
			}
		}
	}
}

void DrawLine(string type, int ticket, double level)
{
	string obj = "EASYORDER_MOD_"+type+"_#"+ticket;
	color clr = Red;
	if(type=="PRICE") clr = LimeGreen;
	//else if(type=="TP") clr = Blue;
	ObjectCreate(obj,OBJ_HLINE,0,Time[0],level,0,0);
	ObjectSet(obj,OBJPROP_COLOR,clr);
	ObjectSet(obj,OBJPROP_STYLE,STYLE_DASHDOT);
}

Re: Coding Help

Posted: Thu Jan 14, 2021 6:48 am
by Modahen77
Hello Mr.Tools and other coders. Happy and prosperous new year to you all and all traders in the house. Please i have this indicator that does not update its signal unless i click on indicator list, and bring it out, click ok, before the arrows can show up, i believe there could be some errors that is not allowing auto update, for the arrows to pop up at the appropriate time. Kindly help me to check the indicator and correct whatever error that is hindering the arrows to come up on chart on all time frame. Thanking you in advance for your precious time.

Re: Coding Help

Posted: Thu Jan 14, 2021 2:56 pm
by mrtools
Maffe wrote: Tue Jan 12, 2021 4:31 am Hi

I have a script from back in 2015, now it is not working and I can see some errors while compiling, but have no idea how to fix them.

if anyone would help me id be greatful.

Thanks

Code: Select all

#property  copyright "Copyright © 2011, sangmane."
#property  link      
  
#import "EasyOrder.dll"
   int EasyOrder(int hwnd);

string obj;
int i, ticket;
   
int start()
{	
	int hwnd = WindowHandle(Symbol(),0);
	if(hwnd==0) {
		Alert("Error!");
		return;
	}
	int ret = EasyOrder(hwnd);
	Print("Return value: ",ret);	
	if(ret<0) {
		Alert("Dll function failed!");
		return;
	}	
	if(ret==1) ModifyOrder();
	else {
		for(i=ObjectsTotal()-1; i>=0; i--) {
			obj = ObjectName(i);
			if(StringFind(obj,"EASYORDER",0)>=0) ObjectDelete(obj);
		}	
	}
	InitLines();
	return (0);
}
//+------------------------------------------------------------------+

void InitLines()
{
	//Delete old lines
	bool delete;
	int pos;
	int ticket;
	for(i=ObjectsTotal()-1; i>=0; i--) {
		obj = ObjectName(i);
		if(StringFind(obj,"EASYORDER_MOD")>=0) {
			delete = True;
			pos = StringFind(obj,"#",1);
			if(pos<0) continue;
			ticket = StrToDouble(StringSubstr(obj,pos+1,StringLen(obj)-pos-1));
			if(OrderSelect(ticket,SELECT_BY_TICKET)) {
				if(OrderCloseTime()==0) delete = false;
			}
			if(delete) ObjectDelete(obj);
		}
	}
	double sl, tp;
	for(i=0; i<OrdersTotal(); i++) {
		OrderSelect(i,SELECT_BY_POS);
		if(OrderSymbol()==Symbol()) {
			ticket = OrderTicket();			
			obj = "EASYORDER_MOD_SL_#"+ticket;
			sl = OrderStopLoss();
			tp = OrderTakeProfit();
			if(sl==0) sl = OrderOpenPrice();
			if(tp==0) tp = OrderOpenPrice();
			if(ObjectFind(obj)>=0)	ObjectMove(obj,0,Time[0],sl);
			else DrawLine("SL",ticket,sl);
			obj = "EASYORDER_MOD_TP_#"+ticket;
			if(ObjectFind(obj)>=0)	ObjectMove(obj,0,Time[0],tp);
			else DrawLine("TP",ticket,tp);
			if(OrderType()>OP_SELL) {
				obj = "EASYORDER_MOD_PRICE_#"+ticket;
				if(ObjectFind(obj)>=0)	ObjectMove(obj,0,Time[0],OrderOpenPrice());
				else DrawLine("PRICE",ticket,OrderOpenPrice());				
			}
		}
	}
}

void ModifyOrder()
{
	string obj;
	int i, ticket;
	double sl, price, tp;
	double osl, otp;
	for(i=0; i<OrdersTotal(); i++) {
		OrderSelect(i,SELECT_BY_POS);
		if(OrderSymbol()==Symbol()) {
			ticket = OrderTicket();
			sl = 0; price = 0; tp = 0;
			obj = "EASYORDER_MOD_SL_#"+ticket;
			osl = OrderStopLoss();			
			if(osl==0) osl = OrderOpenPrice();
			otp = OrderStopLoss();
			if(otp==0) otp = OrderOpenPrice();			
			if(ObjectFind(obj)>=0)	{
				if(MathAbs(ObjectGet(obj,OBJPROP_PRICE1)-osl)>Point) sl = ObjectGet(obj,OBJPROP_PRICE1);
			}
			
			obj = "EASYORDER_MOD_TP_#"+ticket;
			if(ObjectFind(obj)>=0)	{
				if(MathAbs(ObjectGet(obj,OBJPROP_PRICE1)-otp)>Point) tp = ObjectGet(obj,OBJPROP_PRICE1);
			}
						
			if(OrderType()>OP_SELL) {
				obj = "EASYORDER_MOD_PRICE_#"+ticket;
				if(ObjectFind(obj)>=0)	{
					if(MathAbs(ObjectGet(obj,OBJPROP_PRICE1)-OrderOpenPrice())>Point) price = ObjectGet(obj,OBJPROP_PRICE1);
				}
			}
			
			if(sl+tp+price>0) {
				if(sl==0) sl = OrderStopLoss();
				if(tp==0) tp = OrderTakeProfit();
				if(price==0) price = OrderOpenPrice();
				OrderModify(ticket,price,sl,tp,0,CLR_NONE);
			}
		}
	}
}

void DrawLine(string type, int ticket, double level)
{
	string obj = "EASYORDER_MOD_"+type+"_#"+ticket;
	color clr = Red;
	if(type=="PRICE") clr = LimeGreen;
	//else if(type=="TP") clr = Blue;
	ObjectCreate(obj,OBJ_HLINE,0,Time[0],level,0,0);
	ObjectSet(obj,OBJPROP_COLOR,clr);
	ObjectSet(obj,OBJPROP_STYLE,STYLE_DASHDOT);
}
Removed all the errors but not sure i did you any good.

Re: Coding Help

Posted: Thu Jan 14, 2021 2:59 pm
by mrtools
Modahen77 wrote: Thu Jan 14, 2021 6:48 am Hello Mr.Tools and other coders. Happy and prosperous new year to you all and all traders in the house. Please i have this indicator that does not update its signal unless i click on indicator list, and bring it out, click ok, before the arrows can show up, i believe there could be some errors that is not allowing auto update, for the arrows to pop up at the appropriate time. Kindly help me to check the indicator and correct whatever error that is hindering the arrows to come up on chart on all time frame. Thanking you in advance for your precious time.
Looks to me it repaints and possibly need a complete recoding to make it work correctly.

Re: Coding Help

Posted: Thu Jan 14, 2021 8:42 pm
by Maffe
mrtools wrote: Thu Jan 14, 2021 2:56 pm

Removed all the errors but not sure i did you any good.
Thank you a million times :)

Re: Coding Help

Posted: Fri Jan 15, 2021 5:09 am
by Maffe
Maffe wrote: Thu Jan 14, 2021 8:42 pm

Thank you a million times :)
Hi Mr.Tools

Still seems to get 6 errores, did you paste the new code?

Re: Coding Help

Posted: Fri Jan 15, 2021 12:12 pm
by mrtools
Maffe wrote: Fri Jan 15, 2021 5:09 am

Hi Mr.Tools

Still seems to get 6 errores, did you paste the new code?
I may have accidentally posted the old code, try this one.

Re: Coding Help

Posted: Fri Jan 15, 2021 7:01 pm
by Maffe
mrtools wrote: Fri Jan 15, 2021 12:12 pm

I may have accidentally posted the old code, try this one.
million thanks, now i have 0 errores :D