Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Overbought/oversold multiple time frames

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Overbought/oversold multiple time frames

    Hello

    I have created an oscillator that is to check 5 timeframes and return a 1 if all 5 timeframes are either overbought or oversold. I am using the Stochastic RSI to make that determination.

    The indicator plots on the chart, but appears to not be giving accurate information.

    So far I have:
    • confirmed all timeframes are represented in the AddDataSeries()
    • ensured all overbought/oversold values are accurate
    • ensured all bool values are returned back to false
    • ensured correct </> operators were used.


    At this point, I do not see what would be causing the incorrect plots. I am attaching the full code as well as a screenshot of the weekly AUDCAD chart showing 3 examples of incorrect plots.

    Could you help me with looking to see if there is something wrong in my logic. I have debugged as far as what I can figure out up to this point.
    Attached Files

    #2
    Hello jg123,

    Thanks for your post.

    Multi Time Frame indicators require a consideration that each added time frame will call an OnBarUpdate. When that happens the code will then point to that Dataseries.

    In your code you have:

    double stoch60 = StochRSI(14)[1];
    double stoch240 = StochRSI(14)[2];
    double stochDay = StochRSI(14)[3];
    double stochWeek = StochRSI(14)[4];
    double stochMonth = StochRSI(14)[5];


    When each timeframe calls OnBarUpdate, these values will be of that bars object. For example, when the added day series calls OnBarUpdate, those values will be from the previous 5 days, [1] - [5].

    You want the data of the StochRSI based on the other time frames. To accomplish that goal you will need to add a BarsArray[n] reference, for example:

    double stoch60 = StochRSI(BarsArray[1], 14)[0];
    double stoch240 = StochRSI(BarsArray[2], 14)[0];
    double stochDay = StochRSI(BarsArray[3], 14)[0];
    double stochWeek = StochRSI(BarsArray[4], 14)[0];
    double stochMonth = StochRSI(BarsArray[5], 14)[0];


    The above will get the current value [0] of each of the added bar series no matter which bars object calls OnBarUpdate()..

    The other issue is, I think, you only want to evaluate those 5 when the chart bar series (Bars in progress 0) calls the OnbarUpdate() then you would want to add something like:

    if (BarsInProgress != 0) return; // Only process data on chart bar close

    Also, when looking historically or when using Calculate.OnBarClose, the code will be looking at the last closed (not current bar) in each data series. In the helpguide section linked below please see the section titled, "How Bars Data is Referenced" to fully understand which bar is being used as that also points to which StochRSI value is being used.

    Please refer to the helpguide section for a good read on the multi timeframe/series: http://ninjatrader.com/support/helpG...nstruments.htm
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Thank you fro writing, Paul

      I have made those changes and read through the multi-timeframe information.

      I have attached a screenshot of the changes that I've made. The plots are still showing up in different spots and where the should be plots, there is nothing. I have attached a screenshot that shows where there should be plots on a EURGBP 60 minute chart.
      Attached Files

      Comment


        #4
        Hello jg123,

        Thanks for your reply.

        Please move the BarsInProgress check below the CurrentBars check and recompile. Make sure to remove then re add the indicator to the chart.

        If the signals still do not appear then you may want to begin the debug process of printing out the StochRSI data as captured during barsinprogress == 0.
        Paul H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by PaulMohn, Today, 03:49 AM
        0 responses
        7 views
        0 likes
        Last Post PaulMohn  
        Started by inanazsocial, Today, 01:15 AM
        1 response
        9 views
        0 likes
        Last Post NinjaTrader_Jason  
        Started by rocketman7, Today, 02:12 AM
        0 responses
        10 views
        0 likes
        Last Post rocketman7  
        Started by dustydbayer, Today, 01:59 AM
        0 responses
        4 views
        0 likes
        Last Post dustydbayer  
        Started by trilliantrader, 04-18-2024, 08:16 AM
        5 responses
        23 views
        0 likes
        Last Post trilliantrader  
        Working...
        X