"Switch" function
For a long:
if(Bid - desiredStopLoss > OrderStopLoss()){
... calculate new stoploss value and modify order.
.
I see you are trying to do levels, not a smoothly moving stop. Hmm.
YAY PHY
i think you fixed it, i just tried it with a short trade and it seems to work so it will probably work with a long trade, but before i have having trouble getting it to work with both long and short trades so we will see
thank you very much, i would never have realized that was the problem if you hadnt told me, i am indebted to you.
you have helped me very much in the 3 or 4 threads i have made with questions about making my first ever EA!!!
thanks alot
-Alex
if(OrdersTotal() > 0 && OrderSelect(0, SELECT_BY_POS)==true && A==1)
{
switch(OrderProfit())
{
case -0.2:
if(OrderStopLoss() < resetlong + 0.0003)
{
OrderModify(OrderTicket(),OrderOpenPrice(),resetlong+ 0.0003,OrderTakeProfit(),Blue) ;
Alert(GetLastError()); break;
}
case 0.0 :
if(OrderStopLoss() < resetlong + 0.0009)
{
OrderModify(OrderTicket(),OrderOpenPrice(),resetlong+ 0.0009,OrderTakeProfit(),Blue) ;
Alert(GetLastError()); break;
}
case 0.3 :
if(OrderStopLoss() < resetlong + 0.0014)
{
OrderModify(OrderTicket(),OrderOpenPrice(),resetlong+ 0.0014,OrderTakeProfit(),Blue) ;
Alert(GetLastError()); break;
}
case 0.4 :
if(OrderStopLoss() < resetlong + 0.0015)
{
OrderModify(OrderTicket(),OrderOpenPrice(),resetlong+ 0.0015,OrderTakeProfit(),Blue) ;
Alert(GetLastError()); break;
}
case 1.0 :
if(OrderStopLoss() < resetlong + 0.0020)
{
OrderModify(OrderTicket(),OrderOpenPrice(),resetlong+ 0.0020,OrderTakeProfit(),Blue) ;
what it is supposed to do, is at each profit level(which is each case) the stoploss is supposed to move up, but for some reason the stoploss is being moved up before the specified case it is supposed to move up at.
i just tried it out and i only got upto case 0.3 but the stoplose was moved up asif it hit case 1.0