if(OrderStopLoss()==0 && Ask-10*MyPoint>OrderOpenPrice()) modify= OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+10*MyPoint,0,0,clrLightGreen);
when
Ask-10*MyPoint>OrderOpenPrice()
is first true you are trying to modify the SL to what is the current Ask
This will not only likely fail because it is too close to the current price, it will be higher than the current bid and a Buy closes at bid.
when
is first true you are trying to modify the SL to what is the current Ask
This will not only likely fail because it is too close to the current price, it will be higher than the current bid and a Buy closes at bid.
GumRai thanks for anwser.
if(OrderStopLoss()==0 && Ask-10*MyPoint>OrderOpenPrice()) modify= OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+7*MyPoint,0,0,clrLightGreen);
correct ?
First you need to decide what you are trying to do.
This is not code for a trailing stop it is more like a move to break-even
As it is a buy, use Bid, not Ask, better to use OrderClosePrice() which is the last price at the time of the OrderSelect
So this is your code set to break-even. You will need to re-think for a trailing stop.
if(OrderStopLoss()==0 && OrderClosePrice()-10*MyPoint>OrderOpenPrice()) modify= OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice(),0,0,clrLightGreen);
First you need to decide what you are trying to do.
This is not code for a trailing stop it is more like a move to break-even
As it is a buy, use Bid, not Ask, better to use OrderClosePrice() which is the last price at the time of the OrderSelect
So this is your code set to break-even. You will need to re-think for a trailing stop.
Gumrai, thank you for answer.
the previous code was incomplete. With your help, I made several tests and had no error
I believe that everything is OK.
if(OrderStopLoss()==0 && OrderClosePrice()-10*MyPoint>stnewpricebuy) modify = OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+5*MyPoint,0,0,clrLightGreen); if(SL>0 && (OrderStopLoss()>OrderStopLoss()+5*MyPoint)) modify = OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss()+2*MyPoint,0,0,clrLightGreen);
once again thank you for your help.
before sending my question looked at many forums. however you helped me. as always helps.
thank very much :)
correction code:
if(SL==0 && OrderClosePrice()-10*MyPoint>stnewpricebuy) modify = OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+5*MyPoint,0,0,clrLightGreen); if(SL>0 && (Bid>OrderStopLoss()+10*MyPoint)) modify = OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss()+5*MyPoint,0,0,clrLightGreen);

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello!!!
I have a problem in the code. I tried everything, but nothing
ERROR: 130.
thanks for help.