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

Swing indicator questions

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

    Swing indicator questions

    Hi!
    I have two questions to the code of the standard NT Swing indicator.

    1) In what situations will the code in the "else branch" be executed, that is when (saveCurrentBar == CurrentBar) ? Why does it exist? The only situation I have figured out is when you loop through the indicator on historical bars, but I still don't understand the reason for the code in this situation, since the historical output values are stored in DataSeries.

    Code:
            protected override void OnBarUpdate()
            {
                if (saveCurrentBar != CurrentBar)
                {
                    /.../
                    
                    saveCurrentBar = CurrentBar;
                }
                [COLOR=Red]else
                {
                    /.../
                }[/COLOR]
            }
    2) Why do you have to use "Update()" in the properties section although you use the IDataSeries Class?

    Code:
    public DataSeries SwingLow
            {
                get 
                { 
                   [COLOR=Red] Update();[/COLOR]
                    return swingLowSeries; 
                }
            }
    /Regards

    #2
    Hello poseidon_sthlm,

    I will have someone reply to you on Monday. Thank you for your patience.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      poseidon, I believe the else branch is for situations where CalculateOnBarClose = false and the indicator needs to be re-drawn.

      Along those lines, the Update() is there so if the indicator is called, it will be updated (re-drawn) before the results are returned.
      AustinNinjaTrader Customer Service

      Comment


        #4
        Thanks for the reply. Although the option exists, it would be unusual to use the Swing indicator with COBC == false, in my opinion. But the code then makes sense.

        /Regards

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Kensonprib, 04-28-2021, 10:11 AM
        5 responses
        191 views
        0 likes
        Last Post Hasadafa  
        Started by GussJ, 03-04-2020, 03:11 PM
        11 responses
        3,230 views
        0 likes
        Last Post xiinteractive  
        Started by andrewtrades, Today, 04:57 PM
        1 response
        14 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by chbruno, Today, 04:10 PM
        0 responses
        7 views
        0 likes
        Last Post chbruno
        by chbruno
         
        Started by josh18955, 03-25-2023, 11:16 AM
        6 responses
        441 views
        0 likes
        Last Post Delerium  
        Working...
        X