ronwhite:
Indeed.
ronwhite:
Closing the last oeder when a new one is opened.
void Buy(double& risking){ CloseAllOrders(OP_SELL); OpenOrder(OP_BUY..); } void Sell(double& risking){ CloseAllOrders(OP_BUY); OpenOrder(OP_SELL..); } void CloseAllOrders(int op = -1){ for(int iPos = OrdersTotal()-1; iPos >= 0 ; iPos--) if ( OrderSelect(iPos, SELECT_BY_POS) // Only my orders w/ && OrderMagicNumber() == Magic.Number // my magic number && OrderSymbol() == chart.symbol // and my pair, && (op < 0 || op == OrderType()) // and wanted type. ){ // Don't combine with &&'s Compiler bug. if (!OrderClose( OrderTicket(), OrderLots(), OrderClosePrice(), Slippage.Pips*pips2points, op.color )) Alert("OrderClose failed: ", GetLastError()); } } : if ( Low[iBar] > awUp){ Buy(risking); } else if (High[iBar] < awDn){ Sell(risking); }
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