I understand your return code for your Modify order = 1. If it is the case this means there is no error.
Hi Jacques366.
My TrailingStop is 170. I only want to move my stoploss to breakeven and nothing more. then the EA must recognize that if the stoploss is already the OrderOpenPrice+MaxCurrencySpread, the equation is false and ordermodify shouldn't be executed, and the EA will close by takeprofit or by closebuy/sell parameters.
Thank you.
I have read your code once more and found it ok.
Are you sure it is not working :
- what is the error code in return of the OrderModify?
- Make sure to correctly handle it.
- perform a GetLastError(); before your OrderModify, it will clear the register from previous error.
//Trailing stop
if(UseTrailingStop && TrailingStop > 0 && OrderStopLoss() != OrderOpenPrice() - Point * MaxCurrencySpread) {
if((OrderOpenPrice() - Ask) > (Point * TrailingStop)) {
if((OrderStopLoss() > (Ask + Point * TrailingStop))
|| (OrderStopLoss() == 0)) {
OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice()
- Point * MaxCurrencySpread, OrderTakeProfit(), 0, DarkOrange);
if (!EachTickMode) BarCount = Bars;
continue;
The first code is my base of work. here are my tried modifications. this case is for sell position.
When activated the TS function works but my journal is filled with this warning: 2009.01.06 20:02:01 2001.03.16 09:34 Aries v0 EURUSD,M5: OrderModify error 1
I want to avoid it obviously.
Thanks for your interest.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi.
I'm having a problem coding an EA that when is earning my "TrailingStopValue", the EA modify the stoploss to breakeven+maximalcurrencyspread. In my attempts, after backtesting is logging an error modify 1.
This is my source code without changes...
//Trailing stop to CLOSEBUY
if(UseTrailingStop && TrailingStop > 0) {
if(Bid - OrderOpenPrice() > Point * TrailingStop) {
if(OrderStopLoss() < Bid - Point * TrailingStop) {
OrderModify(OrderTicket(), OrderOpenPrice(), Bid
- Point * TrailingStop, OrderTakeProfit(), 0, MediumSeaGreen);
if (!EachTickMode) BarCount = Bars;
continue;
...... and....
//Trailing stop to CLOSESELL
if(UseTrailingStop && TrailingStop > 0) {
if((OrderOpenPrice() - Ask) > (Point * TrailingStop)) {
if((OrderStopLoss() > (Ask + Point * TrailingStop))
|| (OrderStopLoss() == 0)) {
OrderModify(OrderTicket(), OrderOpenPrice(), Ask
+ Point * TrailingStop, OrderTakeProfit(), 0, DarkOrange);
if (!EachTickMode) BarCount = Bars;
continue;
Can you help me? Many thanks.