Title says it all, I'm not sure what the most efficient way of doing this is so I am asking here. For EAs that trade on hourly or daily it may try to place trades at 00:00 during/on market close so what is the most efficient way of making wait like 5 minutes before trying to place the same trade again? I have a little code here just for reference.
- Close By - Trade - MetaTrader 5 for Android
- Managing Pending Orders - Trade - MetaTrader 5 for iPhone
- Close By - Trade - MetaTrader 5 for iPhone
Casey Courtney:
Title says it all, I'm not sure what the most efficient way of doing this is so I am asking here. For EAs that trade on hourly or daily it may try to place trades at 00:00 during/on market close so what is the most efficient way of making wait like 5 minutes before trying to place the same trade again? I have a little code here just for reference.
Title says it all, I'm not sure what the most efficient way of doing this is so I am asking here. For EAs that trade on hourly or daily it may try to place trades at 00:00 during/on market close so what is the most efficient way of making wait like 5 minutes before trying to place the same trade again? I have a little code here just for reference.
search codebase for time filter or the forum.
Casey Courtney:
Title says it all, I'm not sure what the most efficient way of doing this is so I am asking here. For EAs that trade on hourly or daily it may try to place trades at 00:00 during/on market close so what is the most efficient way of making wait like 5 minutes before trying to place the same trade again? I have a little code here just for reference.
Title says it all, I'm not sure what the most efficient way of doing this is so I am asking here. For EAs that trade on hourly or daily it may try to place trades at 00:00 during/on market close so what is the most efficient way of making wait like 5 minutes before trying to place the same trade again? I have a little code here just for reference.
I think I've figured out something that works nicely
bool retryBuy = false; bool retrySell = false; void executeBuy(){ CopyBuffer(handleATR,0,1,1,bufferATR); double ask = SymbolInfoDouble(_Symbol, SYMBOL_ASK); double bid = SymbolInfoDouble(_Symbol, SYMBOL_BID); double sl = ask - bufferATR[0] * ATR_SL_multiplier; double tp = ask + bufferATR[0] * ATR_TP_multiplier; double Lots = calcLots(ask-sl); trade.Buy(Lots, _Symbol, ask, sl, tp, "Regular Buy Signal"); Print(__FUNCTION__, " > Buy Order Sent. Retcode: ", trade.ResultRetcode()); if(trade.ResultRetcode() == TRADE_RETCODE_MARKET_CLOSED){ Print("Trade Failed Because market is closed... Retrying in 5 min"); retryBuy = true; } else { retryBuy = false; } } void executeSell(){ CopyBuffer(handleATR,0,1,1,bufferATR); double ask = SymbolInfoDouble(_Symbol, SYMBOL_ASK); double bid = SymbolInfoDouble(_Symbol, SYMBOL_BID); double sl = bid + bufferATR[0] * ATR_SL_multiplier; double tp = bid - bufferATR[0] * ATR_TP_multiplier; double Lots = calcLots(sl-bid); trade.Sell(Lots, _Symbol, bid, sl, tp, "Regular Sell Signal"); Print(__FUNCTION__, " > Sell Order Sent. Retcode: ", trade.ResultRetcode()); if(trade.ResultRetcode() == TRADE_RETCODE_MARKET_CLOSED){ Print("Trade Failed Because market is closed... Retrying in 5 min"); retrySell = true; } else { retrySell = false; } } void OnTimer() { if (retryBuy == true) { executeBuy(); } if(retrySell == true){ executeSell(); } }
You need to add Ctrade and then Event set timer in Oninit of course...
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