int OnInit()
{
EventSetTimer(300);//300second
return(INIT_SUCCEEDED);
}
void OnDeinit(const int reason)
{
EventKillTimer()
}
void OnTimer()
{
}
void OnTick()
{
}
//Now execute the code you run in OnTimer(), it will be executed every 5min.
int OnInit()
{
EventSetTimer(300);//300second
return(INIT_SUCCEEDED);
}
void OnDeinit(const int reason)
{
EventKillTimer()
}
void OnTimer()
{
}
void OnTick()
{
}
//Now execute the code you run in OnTimer(), it will be executed every 5min.
You can track the opening of a new bar using a static variable and the bar time.
void OnTick() { static datetime last_trade = 0; if (last_trade == 0) last_trade = Time[0]; else if (last_trade != Time[0]) { int ticket = OrderSend(_Symbol, OP_BUY, 0.01, Ask, 0, 0.0, 0.0); if (ticket >= 0) last_trade = Time[0]; } }
You can track the opening of a new bar using a static variable and the bar time.
Пожалуйста, отправляйте сообщения только на английском языке на этом форуме.
Я использовал инструмент перевода сайта для редактирования вашего поста.
Sorry for the inconvenience
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Now I want to change it because it doesn’t work very well and I want that it open position when the candlestick start (in the timeframe I set). For example, I set the timeframe M5, every 5 minutes (when the candle starts) it opens my position, but I don’t know the function to write it.
Can someone please help me?