indicator interval printing (higher timeframe to lower one)
Forums › ProRealTime English forum › ProBuilder support › indicator interval printing (higher timeframe to lower one)
- This topic has 3 replies, 2 voices, and was last updated 6 years ago by Nicolas.
-
-
12/13/2017 at 3:34 PM #55586
Hi everyone, I’m trying to make a higher timeframe EMA in my (lower timeframe) chart. I can print the values that have to be the input for the EMA calculation, but there are 0 values in between. The 0 values affect the calculation of the EMA. Therefore my question: is it possible to let an indicator print at intervals?
12/14/2017 at 9:15 AM #55636Difficult to answer your question without your code. But I think you are calling the EMA only one time at round hour and not in between. If you are calculating only on Close, you should give your variable the same value as the one before or not resetting it to zero. Once again, please share the code with the community, it would help also a lot of people here to know how you are achieving this interesting result (higher TF moving average on lower timeframe).
12/14/2017 at 10:29 AM #55648Credit goes to JMat45 for his Higher timeframe RSI code, I used the first part of his code to time the close of the higher timeframe in the lower timeframe chart. In the chart of my first post I print “htfclose”, the 60 minute close, in a 5 minute chart. In the code below I attempt to code an EMA(3) of the 60 minute timeframe for a 5 minute chart, but without success. The ExponentialAverage[3](htfclose) function of PRT doesn’t work either; it takes in the 0’s in between of the htfclose values, which gives a lower than supposed result. Therefore my question was if it’s possible to print at intervals, so the 0’s won’t be put in the calculation of the EMA3.
attempt to code EMA(3) of a higher timeframe12345678910111213141516171819202122232425262728293031323334353637383940414243444546HigherTimeFrame = 60// Chart timeframe:IF Minute > 0 THENIF Day = Day[1] THENChartTimeframe = Minute-Minute[1]ELSIF Day <> Day[1] THENChartTimeframe = MinuteENDIFELSIF Minute = 0 THENIF Hour - Hour[1] = 1 THENChartTimeframe = (60-Minute[1])ELSIF Hour - Hour[1] > 1 THENChartTimeframe = (Hour-Hour[1]) * 60ENDIFENDIFIF BarIndex > 0 AND BarIndex[1] > 0 AND ChartTimeFrame <> ChartTimeFrame[1] THENChartTimeFrame = ChartTimeFrame[1]ENDIF//StartHour = 7// No. of Closes to go back for each higher timeframe:ResHTF = (Hour-StartHour) MOD MAX((HigherTimeFrame/60),1)IF ChartTimeFrame > 0 THENCalc1 = Minute MOD HigherTimeFrameCalc2 = Minute MOD ChartTimeFramePf1 = (ResHTF[1]*60) + (((Calc1-Calc2)/ChartTimeFrame)+1)[1]ENDIFif Pf1 = HigherTimeFrame/ChartTimeFrame thenresult = closeelseresult = 0endifhtfclose = result//Let's try EMA3 of the HigherTimeFrame (htfclose)if Pf1 = HigherTimeFrame/ChartTimeFrame thenEMA3 = (htfclose+(htfclose[HigherTimeFrame/ChartTimeFrame]*0.5)+(htfclose[((HigherTimeFrame/ChartTimeFrame)*2)]*SQUARE(0.5)))/(1+0.5+Square(0.5))endifreturn EMA312/14/2017 at 10:56 AM #55650I don’t know if the EMA calculation is correct and accurate with the real superior timeframe EMA, but I fixed the way it is displayed, now the curve is continuous. Interesting code, thanks for sharing it 🙂
12345678910111213141516171819202122232425262728293031323334353637383940414243444546HigherTimeFrame = 60// Chart timeframe:IF Minute > 0 THENIF Day = Day[1] THENChartTimeframe = Minute-Minute[1]ELSIF Day <> Day[1] THENChartTimeframe = MinuteENDIFELSIF Minute = 0 THENIF Hour - Hour[1] = 1 THENChartTimeframe = (60-Minute[1])ELSIF Hour - Hour[1] > 1 THENChartTimeframe = (Hour-Hour[1]) * 60ENDIFENDIFIF BarIndex > 0 AND BarIndex[1] > 0 AND ChartTimeFrame <> ChartTimeFrame[1] THENChartTimeFrame = ChartTimeFrame[1]ENDIF//StartHour = 7// No. of Closes to go back for each higher timeframe:ResHTF = (Hour-StartHour) MOD MAX((HigherTimeFrame/60),1)IF ChartTimeFrame > 0 THENCalc1 = Minute MOD HigherTimeFrameCalc2 = Minute MOD ChartTimeFramePf1 = (ResHTF[1]*60) + (((Calc1-Calc2)/ChartTimeFrame)+1)[1]ENDIFif Pf1 = HigherTimeFrame/ChartTimeFrame thenresult = closeelseresult = result[1]endifhtfclose = result//Let's try EMA3 of the HigherTimeFrame (htfclose)if Pf1 = HigherTimeFrame/ChartTimeFrame thenEMA3 = (htfclose+(htfclose[HigherTimeFrame/ChartTimeFrame]*0.5)+(htfclose[((HigherTimeFrame/ChartTimeFrame)*2)]*SQUARE(0.5)))/(1+0.5+Square(0.5))endifreturn EMA3 -
AuthorPosts
Find exclusive trading pro-tools on