Thank you for the answer! EA has written in code to prevent opening new orders. What is the other way (without endless loop) to open order if there is no price change? I'm looking what WHRoeder write but need some help with timer, OnTimer(), EventSetTimer(),...
01005379:
Thank you for the answer! EA has written in code to prevent opening new orders. What is the other way (without endless loop) to open order if there is no price change? I'm looking what WHRoeder write but need some help with timer, OnTimer(), EventSetTimer(),...
intOnInit()
{
//--- create timerEventSetTimer(1); // 1 second
//---return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+//| Expert deinitialization function |//+------------------------------------------------------------------+voidOnDeinit(constint reason)
{
//--- destroy timerEventKillTimer();
}
//+------------------------------------------------------------------+//| Expert tick function |//+------------------------------------------------------------------+voidOnTick()
{
//---
}
//+------------------------------------------------------------------+//| Timer function |//+------------------------------------------------------------------+voidOnTimer()
{
//---// YOUR CODE HERE, executed every second
}
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Yes, it probably would, but why would you want to create an endless loop?
If you want to open an order as soon as you attach the EA to the chart, then putting the order in init should work.
But if you put the order in an endless loop, it may open order after order(depending on your code
Also it would have to be coded so that it doesn't repeat the OrderSend if you change time-frames, restart the platform etc
Thank you for the answer! EA has written in code to prevent opening new orders. What is the other way (without endless loop) to open order if there is no price change? I'm looking what WHRoeder write but need some help with timer, OnTimer(), EventSetTimer(),...
Here is my code. EA still opening orders only when price change...
How do you know?
Price is changing all the time (usually)
I ran a test with this code. I disconnected from the internet, so no new ticks possible.
Timer worked perfectly