pause loop for 3 candles
pause loop for 3 candles
12 Feb 2021, 15:47
Hi.
I have IF loop in my code with market order in the end of it.
After market order, i want this loop to be inactive for 3 candles for example, but rest of the code running normally. That way i will not get multiple entries in short time span.
Is there some kind of wait/sleep function? And where to write it?
if (*logic*)
{
ExecuteMarketOrder(TradeType.Buy, SymbolName, volume, "bot", SL, TP, "buy");
// Time.sleep(3)
}
Replies
marian.kosa
15 Feb 2021, 15:42
RE:
"pretty basic" is good estimate of my programming skills. :)
Thanks for respond. I was not sure where to look. I should be able figure it out now.
JerryTrader said:
I don't know your level of programming skills, but a pretty basic way of doing it without knowing anything about the cBot API would be to:
- Create a field or property in your class
- When you execute the market order, store the bar index in the field/property
- Add a condition to check if the current bar index is greater than your field/property + 3
I think the best way to perform what you are looking for is to override the OnTimer method to set a flag like CanExecuteMarketOrder and stop the timer.
As soon as you execute a market order, you reset the flag and start the timer with Timer.Start() with the timespan you wanna wait before setting the CanExecuteMarketOrder flag.
@marian.kosa
JerryTrader
15 Feb 2021, 15:37
I don't know your level of programming skills, but a pretty basic way of doing it without knowing anything about the cBot API would be to:
I think the best way to perform what you are looking for is to override the OnTimer method to set a flag like CanExecuteMarketOrder and stop the timer.
As soon as you execute a market order, you reset the flag and start the timer with Timer.Start() with the timespan you wanna wait before setting the CanExecuteMarketOrder flag.
@JerryTrader