I am attempting to program an EA that looks at the state of the trend in multiple time frames. All timeframes trend, the higher frames have more filtering. This I feel can increase the odds of a winning EA.
In a singe time frame I use the function NewBar() which executes my code at the start of a new bar. This makes entry/exit more stable as the real time data does not effect the trade.
What I am trying to do is look at the trends of multiple time frames (MTF). If the last closed bar and the one previous to it indicate a trend, then I trade in the lower timeframes only in the direction of the Higher timeframe trend.
Does anybody have some code to post that if an EA is on the 5M timeframe chart, it can also look at and indicate the closing of bars on the 15M and 30M charts?
For example if the following 2 MTF functions in an EA are attached to a 5M chart the following must happen:
double NLMASigM5 = iCustom(NULL, 0,"MTF_NonLagMA_v7.1 SW", TimeFrame3, Price3, Length3, 0.0, 1.0 ,0, Current + 1);
this looks at the state of the previous 5min bar, that is 1 to 5 minutes ago.
This function also appears to look at the MTF indicator state at the close of the previous 5M bar. This value is however not fixed as the value can change until the 15M bar is complete (repaint over 3 5M bars)
double NLMASigM15 = iCustom(NULL, 0,"MTF_NonLagMA_v7.1 SW", TimeFrame4, Price4, Length4, 0.0, 1.0 ,0, Current + 1);
What I want is for this function to look at the value of the last closed 15 min bar.
Here is the NewBar function if anybody wants.
//=======================New Bar Function
static datetime lastbar = 0;
datetime curbar = Time;