Converting 200 SMA on 4hr chart to show on 15 min chart
Forums › ProRealTime English forum › ProBuilder support › Converting 200 SMA on 4hr chart to show on 15 min chart
- This topic has 5 replies, 3 voices, and was last updated 5 years ago by Nicolas.
-
-
04/10/2019 at 7:35 PM #9600004/11/2019 at 8:28 AM #96022
It is not really possible, the most accurate solution is to use a workaround with a backtest continuously running, like the example of this post: https://www.prorealcode.com/topic/timeframe-3/#post-94066
or in examples of our online documentation here: https://www.prorealcode.com/documentation/graphonprice/
04/11/2019 at 9:11 AM #96032You can code an indicator that only updates at the start of each new 4 hour candle. This gives a stepped result.
Here is an example for a 4 hour 20MA. If you increase the stored variables to 200 and then divide the sum of them by 200 you will have a 200MA. I got bored with the typing after 20 so I’ll leave the rest up to you!
Obviously you will need to make sure that your chart has at least 200 4 hour closes on it. A 10k 15 minute chart has over 3200 on it so you should be good to go. Happy typing and share the result here when you finish it please!
Making it update every fifteen minutes would be a coding nightmare and probably very slow to draw so I think this stepped MA is about as good as it gets. If it is just an indicator on a chart rather than a value from an indicator that you want then Nicolas’ MTF idea will probably suit you better.
123456789101112131415161718192021222324252627282930if opentime = 000000 or opentime = 040000 or opentime = 080000 or opentime = 120000 or opentime = 160000 or opentime = 200000 thena1 = a2a2 = a3a3 = a4a4 = a5a5 = a6a6 = a7a7 = a8a8 = a9a9 = a10a10 = a11a11 = a12a12 = a13a13 = a14a14 = a15a15 = a16a16 = a17a17 = a18a18 = a19a19 = a20a20 = openendifif a1 <> 0 thenave20 = (a1+a2+a3+a4+a5+a6+a7+a8+a9+a10+a11+a12+a13+a14+a15+a16+a17+a18+a19+a20) / 20elseave20 = undefinedendifreturn ave2004/11/2019 at 9:25 AM #9603604/11/2019 at 2:04 PM #96096Thank you Nicolas and Vonasi for your replies!
The original question came to be because I have a strategy on the 15 min chart and I want to add a condition to check if the 200 SMA on the 4hr chart is slightly above the current price.
And if so, then not to place an order as the trade against resistance would result in a loss.
I thought drawing the 200 SMA of the 4hr chart on the 15 min chart would be the easiest solution to create that condition.
But maybe there is a solution with the Timeframe function?
04/11/2019 at 2:15 PM #96098If you are talking about an automated trading strategy, that’s right the solution is to use the TIMEFRAME instruction like in the example of that pages:
https://www.prorealcode.com/documentation/timeframe-probacktest-proorder/
https://www.prorealcode.com/topic/echelle-de-temps-multiples/#post-82039
-
AuthorPosts
Find exclusive trading pro-tools on