So I've looked around about this topic quite a bit, and found various threads and posts and even some videos on how to add a higher timeframe indicator (like a moving average) to a lower timeframe chart via an additional panel. I want to do this in code. Taking some notes from the other threads I found, I learned the following need to be done to get to my solution. Here's what I need to do:
- I want to calculate both the daily 50EMA and the 5-minute 50EMA in the same strategy. I want to use the daily 50EMA value as a filter for my 5-minute trades. From all my researching, here's what it seems like I need
1) Add my secondary data series using AddDataSeries(BarsPeriodType.Day, 1)
2) In OnBarUpdate() check when BarsInProgress == 1 indicating that we are calculating daily bars
3) Set the value of the ema using Value[0] = emaDaily[0]. (not 100% sure if this is needed?)
4) Store the value of the daily ema in a variable so we can use it in our primary series entry logic (BarsInProgress == 0)
My results are that the intraday ema calculation seems fine, and is fairly in line with other platforms. The problem is that the daily ema value seems way off from other platforms like ThinkOrSwim. Am I missing something? Or could this just be due to a data discrepancy, or even indicator code differences between the platforms? I want to make sure my code is correct before proceeding, and it would be great to get some confirmation of that.
I've attached a short file below for more context.
Thanks as always
- Jay

Comment