I'm working on a multi-timeframe EA, and am having a problem with detecting a new bar on the higher timeframes.
The EA sits on an M1 chart, and loops through the timeframes, and uses an ATR/AverageSpread filter to determine which timeframe to enter trades on.
I have another filter in place to ensure that only 1 trade is entered per bar, but it's not quite right
Here's the code for the M1 (the code for the other timeframes are the same, Just replace M1_ with M5_, M15_, etc)...
Code: Select all
for (TFCount = 0; TFCount <= ArrayRange(TimeFrames, 0) - 1; TFCount++)
{
CTF = TimeFrames[TFCount];
switch(CTF)
{
case 1:
// Calculate & Store SL, BE, Bep, etc
AdjustStuffByRange();
// Do Trade Management
TradeManagementModule(M1_Managed, M1_Exported, None);
// Do Trade Entries
M1_SpreadIntoATR = iATR(Symbol(), CTF, 14, 0) / (gvg(SpreadGvName) / factor);
if (M1_SpreadIntoATR >= 2)
{
TradingLowerTF = true;
SpreadIntoATR = M1_SpreadIntoATR;
ReadIndicatorValues();
if ((LastTradeTime[TFCount] <= iTime(Symbol(), CTF, 0)) && (OldReadBarTime[TFCount] != iTime(Symbol(), CTF, 0)))
{
OldReadBarTime[TFCount] = iTime(Symbol(), CTF, 0);
LookForTradingOpportunities(M1_Managed);
}
}
break;Have fun!
Radar =8^)
