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 Segwin, 05-07-2018, 02:15 PM
    10 responses
    1,768 views
    0 likes
    Last Post Leafcutter  
    Started by Rapine Heihei, 04-23-2024, 07:51 PM
    2 responses
    30 views
    0 likes
    Last Post Max238
    by Max238
     
    Started by Shansen, 08-30-2019, 10:18 PM
    24 responses
    943 views
    0 likes
    Last Post spwizard  
    Started by Max238, Today, 01:28 AM
    0 responses
    10 views
    0 likes
    Last Post Max238
    by Max238
     
    Started by rocketman7, Today, 01:00 AM
    0 responses
    7 views
    0 likes
    Last Post rocketman7  
    Working...
    X