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

Incorrect Bollinger Values with BarsAgo indexing

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

    Incorrect Bollinger Values with BarsAgo indexing

    Dear NT8 Support team,


    I'm calculating the Bollinger values for current bar and past 2 period bars, but I get incorrect values. When I try to go back to historical bar using "int barsAgo" and calculate the Bollinger values, I'm not getting the correct number? Could you please check?

    Bollinger(ISeries<double> input, double numStdDev, int period).Lower[int barsAgo]
    Bollinger(ISeries<double> input, double numStdDev, int period).Upper[int barsAgo]

    //bollinger for 15 min time frame - current or recently closed bar
    bollingerALT = (Bollinger(BarsArray[1],2,8).Upper[0] - Bollinger(BarsArray[1],2,8).Lower[0]);
    bollingerUpLT = Bollinger(BarsArray[1],2,8).Upper[0];
    bollingerBLT = Math.Round((bollingerALT / bollingerUpLT) * 100, 2);


    //bollinger for 15 min time frame - barsAgo[2]
    bollingerALT = (Bollinger(1, 14).Upper[2] - Bollinger(1, 14).Lower[2]);
    bollingerUpLT = Bollinger(1, 14).Upper[2];
    bollingerBLT = Math.Round((bollingerAST / bollingerUpST) * 100, 2);
    Print(string.Format("{0} | Time[2]: {1}, Bollinger Value [2]:{2}", Time[0], Time[2], bollingerBLT));

    #### Output ####

    3/14/2022 9:00:00 PM - Current bollinger -15 min time frame - 0.27
    3/14/2022 9:00:00 PM | Time[2]: 3/14/2022 8:30:00 PM, Bollinger Value [2]:0.21

    3/14/2022 9:15:00 PM Current bollinger -15 min time frame - 0.27
    3/14/2022 9:15:00 PM | Time[2]: 3/14/2022 8:45:00 PM, Bollinger Value [2]:0.21

    3/14/2022 9:30:00 PM Current bollinger -15 min time frame- 0.33
    3/14/2022 9:30:00 PM | Time[2]: 3/14/2022 9:00:00 PM, Bollinger Value [2]:0.2

    3/14/2022 9:45:00 PM - Current bollinger -15 min time frame- 0.49
    3/14/2022 9:45:00 PM | Time[2]: 3/14/2022 9:15:00 PM, Bollinger Value [2]:0.3

    3/14/2022 10:00:00 PM Current bollinger -15 min time frame- bollingerBLT - 0.54
    3/14/2022 10:00:00 PM | Time[2]: 3/14/2022 9:30:00 PM, Bollinger Value [2]:0.37


    #2
    Hello radhmu978,

    I am not certain I understand the question in contrast to the prints. Are you saying that one of the actual Bollinger values is not correct in some way?

    Do you have a more simple example that does not involve the math you are printing out?

    JesseNinjaTrader Customer Service

    Comment


      #3
      this is an issue with BarsAgo index. If i go back based on historical Bars, I'm not getting the right values


      Bollinger(ISeries<double> input, double numStdDev, int period).Lower[int barsAgo]
      Bollinger(ISeries<double> input, double numStdDev, int period).Upper[int barsAgo]

      Comment


        #4
        Hello radhmu978,

        I understand that part of the concern however I don't understand the question with the print you provided. Are you seeing the BarsAgo on one of the Bollinger's is not working as expected? The math would need to be removed from the sample to see the base indicator values.


        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by ageeholdings, 05-01-2024, 05:22 AM
        6 responses
        42 views
        0 likes
        Last Post ageeholdings  
        Started by tony_28217, Today, 07:04 PM
        0 responses
        11 views
        0 likes
        Last Post tony_28217  
        Started by flybuzz, Today, 10:33 AM
        1 response
        9 views
        0 likes
        Last Post flybuzz
        by flybuzz
         
        Started by spencerp92, 10-10-2023, 09:56 AM
        4 responses
        308 views
        0 likes
        Last Post flybuzz
        by flybuzz
         
        Started by samish18, Yesterday, 10:13 AM
        1 response
        26 views
        0 likes
        Last Post NinjaTrader_Eduardo  
        Working...
        X