EA stop working help please
Check your parentheses, { and }. I think return(0) in the wrong place.
Roger
thank you
i have change the parentheses and it is scrolling know the orders
but what i have notice is that is not trailing at all
where did i go wrong
try this
extern int TakeProfit=750; extern int TrailingStop=5; extern int StopLoss = 100; // check open possitions and place sl, tp string str; int start() { Comment(str); int cnt, totalOrders; totalOrders = OrdersTotal(); if (totalOrders>0) // open orders identified { for (cnt=0;cnt<totalOrders;cnt++) { OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); Print (cnt); if(OrderType()==OP_SELL && OrderSymbol()==Symbol()) { if (OrderStopLoss()==0) { OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red); } if((OrderOpenPrice()-Ask)>(Point*TrailingStop)) { if(OrderStopLoss()>(Ask+Point*TrailingStop)+Point) { if(!OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red)) Print("Error_Modify - ",GetLastError()); else str=StringConcatenate("\n My ticket number is ", OrderTicket(), " and my stop loss setting is ", DoubleToStr(Ask+Point*TrailingStop,Digits)); // new code } } } if(OrderType()==OP_BUY && OrderSymbol()==Symbol()) { if (OrderStopLoss()==0) { OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green); } if(Bid-OrderOpenPrice()>Point*TrailingStop) { if(OrderStopLoss()<Bid-Point*TrailingStop-Point) { if(!OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green)) Print("Error_Modify - ",GetLastError()); else str=StringConcatenate("\n My ticket number is ", OrderTicket(), " and my stop loss setting is ", DoubleToStr(Bid-Point*TrailingStop,Digits)); // new code } } //int BuyStop; //BuyStop=OrderStopLoss();Print("Cond-0 = ",BuyStop); //Comment("\n My ticket number is ", OrderTicket(), " and my stop loss setting is ", NormalizeDouble(BuyStop,Digits)); // new code //OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(BuyStop,Digits),OrderTakeProfit(),0,White); } } } return(0); }
try this
thanks Roger
i have place it on my ea but i have found it gives me 130 errors
I don't know your broker, my boker allows.
Replace in sell-modify
Print("Error_Modify - ",GetLastError());
to
Print("Error_Modify - ",GetLastError()," price - ",OrderOpenPrice()," stop - ",Ask+Point*TrailingStop," real stop - ", Ask+Point*MarketInfo(Symbol(),MODE_STOPLEVEL," level - ",MarketInfo(Symbol(),MODE_STOPLEVEL );
and in buy-modify
Print("Error_Modify - ",GetLastError());
to
Print("Error_Modify - ",GetLastError()," price - ",OrderOpenPrice()," stop - ",Bid-Point*TrailingStop," real stop - ", Bid-Point*MarketInfo(Symbol(),MODE_STOPLEVEL," level - ",MarketInfo(Symbol(),MODE_STOPLEVEL );
and then show results.
I don't know your broker, my boker allows.
Replace in sell-modify
Print("Error_Modify - ",GetLastError());
to
Print("Error_Modify - ",GetLastError()," price - ",OrderOpenPrice()," stop - ",Ask+Point*TrailingStop," real stop - ", Ask+Point*MarketInfo(Symbol(),MODE_STOPLEVEL," level - ",MarketInfo(Symbol(),MODE_STOPLEVEL );
and in buy-modify
Print("Error_Modify - ",GetLastError());
to
Print("Error_Modify - ",GetLastError()," price - ",OrderOpenPrice()," stop - ",Bid-Point*TrailingStop," real stop - ", Bid-Point*MarketInfo(Symbol(),MODE_STOPLEVEL," level - ",MarketInfo(Symbol(),MODE_STOPLEVEL );
and then show results.
thanks Roger
it is trailing only if i change it to 15pips
what other settings can i use to get a tighter trail. how does step work?
can some one tell me why this EA stopped working
there is still open trades but it will not trail it
extern int TakeProfit=750;extern int TrailingStop=5;
extern int StopLoss = 100;
// check open possitions and place sl, tp
int start()
{
int cnt, totalOrders;
totalOrders = OrdersTotal();
if (totalOrders>0) // open orders identified
{
for (cnt=0;cnt<totalOrders;cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
Print (cnt);
if(OrderType()==OP_SELL && OrderSymbol()==Symbol())
{
if (OrderStopLoss()==0)
{
OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red);
}
if((OrderOpenPrice()-Ask)>(Point*TrailingStop))
{
if(OrderStopLoss()>(Ask+Point*TrailingStop)+Point)
{
OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red);
}
}
}
if(OrderType()==OP_BUY && OrderSymbol()==Symbol())
{
if (OrderStopLoss()==0)
{
OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green);
}
if(Bid-OrderOpenPrice()>Point*TrailingStop)
{
if(OrderStopLoss()<Bid-Point*TrailingStop-Point)
{
OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green);
}
}
int BuyStop;
BuyStop=OrderStopLoss();Print("Cond-0 = ",BuyStop);
Comment("\n My ticket number is ", OrderTicket(), " and my stop loss setting is ", NormalizeDouble(BuyStop,Digits)); // new code
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(BuyStop,Digits),OrderTakeProfit(),0,White);
}
return(0);
}
}
}
//+------------------------------------------------------------------+