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:	307
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
    JesseNinjaTrader Customer Service

    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.​
        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by AHamxa, Yesterday, 11:24 PM
        0 responses
        5 views
        0 likes
        Last Post AHamxa
        by AHamxa
         
        Started by AHamxa, Yesterday, 11:22 PM
        0 responses
        4 views
        0 likes
        Last Post AHamxa
        by AHamxa
         
        Started by AHamxa, Yesterday, 11:17 PM
        0 responses
        5 views
        0 likes
        Last Post AHamxa
        by AHamxa
         
        Started by Spiderbird, 07-27-2018, 07:52 PM
        12 responses
        9,240 views
        2 likes
        Last Post Mountain_cast  
        Started by chrischongpdx, Yesterday, 09:39 PM
        0 responses
        7 views
        0 likes
        Last Post chrischongpdx  
        Working...
        X