daffi:
Just to clarify . . . you mean when the next D1 bar starts ?
Hello,
I programm an EA that runs on D1 charts and uses few standard MT indicators. I'd like to close the positions on first open price when trade is in profit. Would someone advise me, how to program that?
daffi:
I'd like to close the positions on first open price when trade is in profit.
I'd like to close the positions on first open price when trade is in profit.
int start(){ static datetime Time0; if (Time0 != Time[0]){ Time0 = Time[0]; // A new bar for(int pos = OrdersTotal()-1; pos >= 0 ; pos--) if ( OrderSelect(pos, SELECT_BY_POS) // Only my orders w/ && OrderMagicNumber() == magic.number // my magic number && OrderSymbol() == Symbol() // and my pair && OrderProfit() > 0. // and in profit. ){ if (!OrderClose( OrderTicket(), OrderLots(), OrderClosePrice(), Slippage.Pips*pips2points/*, op.color*/ )) Alert( "OrderClose(ticket=", OrderTicket(), ", ...) [1] failed: ", GetLastError() ); } } // Newbar :
daffi:
Hello,
I programm an EA that runs on D1 charts and uses few standard MT indicators. I'd like to close the positions on first open price when trade is in profit. Would someone advise me, how to program that?
Thanks in advance,
Daffi
I really wonder, if you were able to "programm an EA that runs on D1 charts and uses few standard MT indicators", then I don't see any prb, in going about with this much simpler closing logic.

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
Hello,
I programm an EA that runs on D1 charts and uses few standard MT indicators. I'd like to close the positions on first open price when trade is in profit. Would someone advise me, how to program that?
Thanks in advance,
Daffi