Programming a Multi-Time Frame Indicator in EasyLanguage

Take a look at this indictor.

MTF indicator EasyLanguage

This indicator plots five different time frames as a stacked chart. The circles or dots at the bottom represent the difference between the closing price of each time frame and its associated pivot price  [(high + low + close)/3].  The value plotted at 4, in this case, represents the 5 minute time frame.  The 10-minute time frame is represented by the plot at 3 and so on.  The value plotted at 7 represents the composite of all the time frames.  It is only turned on if all times are either red or green.  If there is a disagreement then nothing is plotted.

This indicator is relatively simple even though the plot looks complicated.  You have to make sure the indicator is plotted in a separate pane.  The y – axis has 0 and 8 as its boundaries.  All you have to do is keep track of the highest highs/lowest lows for each time frame.  I use a multiplier of the base time frame to create different time frames.  TimeFrame1Mult = 2 represents 10 minutes and TimeFrame2Mult = 3 and that represents 15 minutes.  The indicator shows how strong the current swing is across five different time frames.  When you start getting a mix of green and red dots this could indicate a short term trend change.  You can use the EasyLanguage to plug in any indicator over the different time frames.  Here’s the code.  Just email me with questions or if you see a mistake in the coding.

{EasyLanguage MultiTime Frame Indicator)
 written by George Pruitt - copyright 2019 by George Pruitt
 }


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
	
	mtf0pvt = (close + high + low) / 3;
	diff0 = close - mtf0pvt;
	
	mtf1h = highest(h,tf1Mult);
	mtf1l = lowest(l,tf1Mult);
	mtf1c = close;
	
	mtf1pvt = (mtf1h+mtf1l+mtf1c) / 3;
	diff1 = mtf1c - mtf1pvt;
	
	mtf2h = highest(h,tf2Mult);
	mtf2l = lowest(l,tf2Mult);
	mtf2c = close;
	
	mtf2pvt = (mtf2h+mtf2l+mtf2c) / 3;
	diff2 = mtf2c - mtf2pvt;
		
	mtf3h = highest(h,tf3Mult);
	mtf3l = lowest(l,tf3Mult);
	mtf3c = close;
	
	mtf3pvt = (mtf3h+mtf3l+mtf3c) / 3;
	diff3 = mtf3c - mtf3pvt;
	
	mtf4h = highest(h,tf4Mult);
	mtf4l = lowest(l,tf4Mult);
	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;
MTF in EasyLanguage

 

Please follow and like us:
error

3 thoughts on “Programming a Multi-Time Frame Indicator in EasyLanguage”

  1. Hi George, a very interesting approach to build data for several different timeframes from only data1. Should reduce workarounds due to limitations in Tradestation when several data streams are used.
    I can´t see that the variable mtf1o(0), mtf2o(0) …. is used. Is that to be able to use open data for different timeframes in coming versions?
    How would best practice to store open data for each timeframe be coded?

    And thanks for your valuable efforts to educate through your books and this webpage.

    1. Hi Goran,

      Thanks for your post and question. I didn’t need the open for this analysis but I am sure others will in the future. Add this code and it should do it. You want to store the open tick for each time frame and carry it over for the entire time period before changing it again. I use the modulus function to determine the first time stamp of each time frame. Hope this helps.

      Condition1 =  mod((barNumber+1),tf1Mult) = 0;
      Condition2 =  mod((barNumber+1),tf2Mult) = 0;
      Condition3 =  mod((barNumber+1),tf3Mult) = 0;
      Condition4 =  mod((barNumber+1),tf4Mult) = 0;
      
      
      mtf0pvt = (close + high + low) / 3;
      diff0 = close - mtf0pvt;
      
      mtf1h = highest(h,tf1Mult);
      mtf1l = lowest(l,tf1Mult);
      mtf1c = close;
      mtf1o = iff(condition1[1],open,mtf1o[1]);
      
      1. Hi George,

        And thanks for your prompt reply. I will try both this version and also the discrete time frame version and compare the results. Always interesting to understand more about different logic and what result they give. MTF logic can really be tricky to code, but be the filter that gives the edge for a really good trading system.

        Many thanks for your answer and we out here, are eager to follow your work.

        Best regards
        Goran

Leave a Reply