GumRai. Thank you very much!!!! =)
exactly!
CODE;
double stnewprice = OrderOpenPrice(); double st = OrderStopLoss(); if(st<=0 && Ask-20*MyPoint>stnewprice) modify = OrderModify(OrderTicket(),OrderOpenPrice(),stnewprice+10*MyPoint,0,0,clrLightGreen);
I don't know that there are any advantages of using different variables instead of OrderOpenPrice() etc. Personally, I would not
if(OrderStopLoss()<OrderOpenPrice() && Bid-20*MyPoint>OrderOpenPrice()) if(!OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+10*MyPoint,0,0,clrLightGreen)) Print("Error modifying ",OrderTicket()," Error code ",GetLastError());
note that as this is a buy order, I have used Bid instead of Ask
Indidentally, the code is not a trailing stop as it will only modify the stoploss once
For a sell, the if condition will need to be slightly different if the stoploss is zero.
if((OrderStopLoss()>OrderOpenPrice() || OrderStopLoss()==0) && OrderOpenPrice()-Ask>20*MyPoint)
Gumrai. Sorry for the delay!
CODE ATT:
double stnewpricebuy = OrderOpenPrice(); double stbuy = OrderStopLoss(); if(stbuy<=0 && Ask-20*MyPoint>stnewpricebuy) { modify = OrderModify(OrderTicket(),OrderOpenPrice(),stnewpricebuy+10*MyPoint,0,0,clrLightGreen); } else if(stbuy>0 && Ask-20*MyPoint>stbuy) { modify = OrderModify(OrderTicket(),OrderOpenPrice(),stbuy+10*MyPoint,0,0,clrLightGreen); }
===]]]]]]]]]]
Thanks.
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
heeey gus!!!
It is a pleasure to be in this forum. The forum helps me a lot in my studies. =) Thankss!!!
People,I can not place stop when the price reach a value.
Example:
price is 1.50
Stop in 01.30
is Result the code:
Price is 1.30
Stop in 1.30.
it's wrong. why it does not work?
Thank you very much for your help. =)
*Sorry for any English error.