Just a quick post here. I was asked how to keep track of the opening price for each time frame from our original Multi-Time Frame indicator and I was answering the question when I thought about modifying the indicator. This version keeps track of each discrete time frame. The original simply looked back a multiple of the base chart to gather the highest highs and lowest lows and then would do a simple calculation to determine the trend. So let’s say its 1430 on a five-minute bar and you are looking back at time frame 2. All I did was get the highest high and lowest low two bars back and stored that information as the high and low of time frame 2. Time frame 3 simply looked back three bars to gather that information. However if you tried to compare these values to a 10-minute or 15-minute chart they would not match.
In this version, I use the modulus function to determine the demarcation of each time frame. If I hit the border of the time frame I reset the open, high, low and carry that value over until I hit the next demarcation. All the while collecting the highest highs and lowest lows. In this model, I am working my way from left to right instead of right to left. And in doing so each time frame is discrete.
Let me know which version you like best.
Inputs:tf1Mult(2),tf2Mult(3),tf3Mult(4),tf4Mult(5);
vars: mtf1h(0),mtf1l(0),mtf1o(0),mtf1c(0),mtf1pvt(0),diff1(0),
mtf2h(0),mtf2l(0),mtf2o(0),mtf2c(0),mtf2pvt(0),diff2(0),
mtf3h(0),mtf3l(0),mtf3o(0),mtf3c(0),mtf3pvt(0),diff3(0),
mtf4h(0),mtf4l(0),mtf4o(0),mtf4c(0),mtf4pvt(0),diff4(0),
mtf0pvt(0),diff0(0);
If barNumber = 1 then
Begin
mtf1o = o;
mtf2o = o;
mtf3o = o;
mtf4o = o;
end;
If barNumber > 1 then
Begin
Condition1 = mod((barNumber+1),tf1Mult) = 0;
Condition2 = mod((barNumber+1),tf2Mult) = 0;
Condition3 = mod((barNumber+1),tf3Mult) = 0;
Condition4 = mod((barNumber+1),tf4Mult) = 0;
mtf1h = iff(not(condition1[1]),maxList(high,mtf1h[1]),high);
mtf1l = iff(not(condition1[1]),minList(low,mtf1l[1]),low);
mtf1o = iff(condition1[1],open,mtf1o[1]);
mtf1c = close;
mtf0pvt = (close + high + low) / 3;
diff0 = close - mtf0pvt;
mtf2h = iff(not(condition2[1]),maxList(high,mtf2h[1]),high);
mtf2l = iff(not(condition2[1]),minList(low,mtf2l[1]),low);
mtf2o = iff(condition2[1],open,mtf2o[1]);
mtf2c = close;
mtf1pvt = (mtf1h+mtf1l+mtf1c) / 3;
diff1 = mtf1c - mtf1pvt;
mtf2pvt = (mtf2h+mtf2l+mtf2c) / 3;
diff2 = mtf2c - mtf2pvt;
mtf3h = iff(not(condition3[1]),maxList(high,mtf3h[1]),high);
mtf3l = iff(not(condition3[1]),minList(low,mtf3l[1]),low);
mtf3o = iff(condition3[1],open,mtf3o[1]);
mtf3c = close;
mtf3pvt = (mtf3h+mtf3l+mtf3c) / 3;
diff3 = mtf3c - mtf3pvt;
mtf4h = iff(not(condition4[1]),maxList(high,mtf4h[1]),high);
mtf4l = iff(not(condition4[1]),minList(low,mtf4l[1]),low);
mtf4o = iff(condition4[1],open,mtf4o[1]);
mtf4c = close;
mtf4pvt = (mtf4h+mtf4l+mtf4c) / 3;
diff4 = mtf4c - mtf4pvt;
Condition10 = diff0 > 0;
Condition11 = diff1 > 0;
Condition12 = diff2 > 0;
Condition13 = diff3 > 0;
Condition14 = diff4 > 0;
If condition10 then setPlotColor(1,Green) else SetPlotColor(1,Red);
If condition11 then setPlotColor(2,Green) else SetPlotColor(2,Red);
If condition12 then setPlotColor(3,Green) else SetPlotColor(3,Red);
If condition13 then setPlotColor(4,Green) else SetPlotColor(4,Red);
If condition14 then setPlotColor(5,Green) else SetPlotColor(5,Red);
condition6 = condition10 and condition11 and condition12 and condition13 and condition14;
Condition7 = not(condition10) and not(condition11) and not(condition12) and not(condition13) and not(condition14);
If condition6 then setPlotColor(7,Green);
If condition7 then setPlotColor(7,Red);
If condition6 or condition7 then plot7(7,"trend");
Plot6(5,"line");
Plot1(4,"t1");
Plot2(3,"t2");
Plot3(2,"t3");
Plot4(1,"t4");
Plot5(0,"t5");
end;
Multi-Time Frame with Discrete Time Frames
Hi George,
Must say I have some problems to get the code to return the correct high, open, low for each timeframe when i am debugging. Has had some errors with TS Development Environment but I don´t think that is the case now. I have plotted each timeframe as data 2 etc and comparing with print. Has anyone else that experience too or?
Hi Goran,
Excellent question! Since I am using BarNumber the time frames that you are looking at may not synch with my output. I am going to create a new post to demonstrate.
Thanks again for the question!