Announcement

Collapse
No announcement yet.

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

    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.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        557 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        324 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        545 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        547 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X