Once Stoploss hits, next 15 minutes EA should not trade
Sathish Justin:
My stoploss code is as below, once stoploss is hit, next 15 mins EA should stop trading, how should i modify the below code
Does not compute...
This is how someone with MT4 might do it.
// MT4 read last closed trade profit or loss and check if its closed time is less than 15 minutes if (LastProfit()) return(0); // exit when condition is true. It is reset proof, ie. the platform can be restarted bool LastProfit() { double profit; datetime closetime=TimeCurrent(); for (int pos=OrdersHistoryTotal()-1; pos>=0; pos--) { if (OrderSelect(pos,SELECT_BY_POS, MODE_HISTORY)==TRUE && OrderMagicNumber()==MAGIC && OrderSymbol()==Symbol()) { if (OrderType()== OP_BUY || OrderType()== OP_SELL) { profit=OrderProfit(); closetime=OrderCloseTime(); } } } if(profit < 0 && (TimeCurrent()-closetime) < 15*60) return(true); // return true when time is less than 15 minutes ago ie. 15*60seconds else return(false); }
My stoploss code is as below, once stoploss is hit, next 15 mins EA should stop trading, how should i modify the below code