Re: Coding Help

1203
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

1204
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.
“My losses have taught me that I must not begin to advance until I am sure I shall not have to retreat. But if I cannot advance I do not move at all.” –Jesse Livermore

Re: Coding Help

1205
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

1206
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.


Who is online

Users browsing this forum: No registered users and 21 guests