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

Help with divergence idea

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

    Help with divergence idea

    Hello,
    I'm working on a divergence indicator. I have a block of code that helps me find the lowest low for a given period:
    Code:
    if(!TSSuperTrend(14,MovingAverageType.HMA,2.618,14,SuperTrendMode.ATR)._trend[0]
                    && Low[1] > Low[0] && Low[0] < curr_Price_Low_Value)
                {    
                    curr_Price_Low_Value         = Low[0];
                    curr_Price_Low_Bar            = CurrentBar; 
                    DrawDot("curr_Price_Low_Value" + CurrentBar, true, 0, curr_Price_Low_Value - .08, Color.Pink);
                    curr_Stoch_Low_Value        = MIN(Stochastics(2,5,1),3)[0];
                    curr_Stoch_Low_Bar            = CurrentBar - LowestBar(Stochastics(2,5,1), 3);
                    curr_DM_Low_Value            = MIN(DM(14).DiMinus, 3)[0];
                    curr_DM_Low_Bar                = CurrentBar - LowestBar(DM(14).DiMinus, 3);
                }
    I have another block of code that sets the previous values that I compare for larger scale divergence. I use the TSSuperTrend to determine the period. I find divergence between the uptrends when a downtrend has broken the pattern.

    My challenge is when I try to find divergence on a minor scale, during the same period.
    So lets say the market is trending down, pulls back for a bar or two, not enough to change trend, and then continues to trend down. My current logic will capture those lows in price and lows with the indicator. But often when price goes lower an indicator will rise and then not make new lows. My current logic changes my indicator values every time price goes lower. Does someone know a better way to do this? Thanks.

    #2
    Hello CaptainAmericaXX,

    Thanks for your post.

    You may want to add a "qualifier" for the values. This would be similar to how the Swing indicator logic works. It uses the "strength" value to basically say if the detected swing high is still the swing high after 5 bars then it is the new swing high, otherwise if a new high is detected within the subsequent 5 bars then the detection is reset to the latest high detected and again would not be "used" until qualified by being the swing high of the last 5 bars. To clarify the strength setting is simply the number of bars to wait to "qualify" as a swing high (or swing low). While this "delays" the display of the swing it reduces "false" swings which sounds very similar to what you are experiencing with your indicator.
    Paul H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by techgetgame, Yesterday, 11:42 PM
    0 responses
    8 views
    0 likes
    Last Post techgetgame  
    Started by sephichapdson, Yesterday, 11:36 PM
    0 responses
    2 views
    0 likes
    Last Post sephichapdson  
    Started by bortz, 11-06-2023, 08:04 AM
    47 responses
    1,613 views
    0 likes
    Last Post aligator  
    Started by jaybedreamin, Yesterday, 05:56 PM
    0 responses
    10 views
    0 likes
    Last Post jaybedreamin  
    Started by DJ888, 04-16-2024, 06:09 PM
    6 responses
    20 views
    0 likes
    Last Post DJ888
    by DJ888
     
    Working...
    X