Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Swing indicator values

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

    Swing indicator values

    hi, i am wondering why my swinghigh is displaying a wrong value. I place swing indicator on chart with default settings and in strategy i am referencing the default values too but it places stop at wrong level, not excactly at default swing level. Am i doing it right?

    double swinghigh = Swing(5).SwingHigh[1];

    ExitShortStopMarket(1, true, Position.Quantity, Position.AveragePrice + swinghigh, "SLS", "BS");

    Click image for larger version

Name:	image.png
Views:	502
Size:	74.6 KB
ID:	1261879

    #2
    Hello tkaboris,

    The swing indicator has custom methods that are used to get the swing values. You can see an example of getting the most recent instance of the swing here: https://ninjatrader.com/support/help...lightsub=swing

    Comment


      #3
      ok I entered these values like from teh help guide
      double swinghigh = High[Math.Max(0, Swing(5).SwingHighBar(0, 1, 10))];
      double swinglow = Low[Math.Min(0, Swing(5).SwingLowBar(0, 1, 10))];​

      but i now have error onbarupate outofrrange index
      What validation i need for this?
      Thank you
      I have
      if (CurrentBar < 20) return;

      Comment


        #4
        Hello tkaboris,

        You need to use Math.Max on both lines of code, you want the higher of the bars ago value between 0 and any positive number. If no swing is found a -1 is reported which your Math.Min is selecting and that is not a valid bars ago.
        Return Value
        An int value representing the number of bars ago. Returns a value of -1 if a swing point is not found within the look back period.​

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Yesterday, 05:17 AM
        0 responses
        65 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        139 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        75 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        45 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        50 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X