Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

"Swing" indicator script logic

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

    "Swing" indicator script logic

    Hello

    I'm trying to modify the "swing" indicator, but first I'm trying to make sense of the script's logic. For the most part I already understand how the code works, but on line 93 there is an if statement:
    if (BarsArray[0].BarsType.IsRemoveLastBarSupported && CurrentBar < saveCurrentBar)

    I don't understand in which scenario is this if statement true or false and what is the purpose of this if statement?
    Please explain what is "BarsArray[0].BarsType.IsRemoveLastBarSupported" checking for and how can "CurrentBar < saveCurrentBar" be true at all? Since current bar starts counting from 0 and only goes higher and in the beginning saveCurrentBar is -1 and it's value only changes on lines 109 and 212 when its set equal to CurrentBar. There doesn't seem to be any logical scenario where CurrentBar can be lower than saveCurrentBar.


    #2
    Hi Karl, thanks for posting.

    This section is to handle bars types with IsRemoveLastBarSupported, like the Renko bar when it runs OnEachTick. If the current bar is removed it would be less than the saved bar. You can make a copy of the Swing indicator by right clicking the code>Save As, then give it a unique name. This copy can be edited and tested by adding Print() methods throughout.

    Kind regards,
    -ChrisL
    Chris L.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by traderqz, Today, 12:06 AM
    8 responses
    14 views
    0 likes
    Last Post traderqz  
    Started by SightCareAubetter, Today, 12:50 PM
    0 responses
    1 view
    0 likes
    Last Post SightCareAubetter  
    Started by Mongo, Today, 11:05 AM
    4 responses
    14 views
    0 likes
    Last Post Mongo
    by Mongo
     
    Started by Skifree, Today, 03:41 AM
    5 responses
    13 views
    0 likes
    Last Post Skifree
    by Skifree
     
    Started by traderqz, Yesterday, 09:06 AM
    5 responses
    35 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Working...
    X