Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Swing Low on Cht?

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

    Swing Low on Cht?

    What's the correct code to use for putting in a swing low indicator in the strategy script so that those are drawn on a price chart?

    I've tried "AddChartIndicator ( Swing (5).SwingLow [0] );" and "AddChartIndicator ( Swing (5).SwingLowBar (0, 1, 10) );" but keep getting compile error messages (yes, these are going inside "State.DataLoaded").


    #2
    Hello spottysallrite,

    For a strategy to add an indicator to the chart you would use AddChartIndicator. The indicator will display the swing low you just need to add the base indicator. AddChartIndicator(Swing(5));

    Comment


      #3
      Ok, I used "Draw.Text()" to draw on the chart the values produced by "Lows[0] [Math.Max (0,
      Swing (5).SwingLowBar (0, 1, 10) ) ];​". However, these aren't the same values as drawn on the chart by "AddChartIndicator ( Swing (5) ); ". Shouldn't these produce the same values?

      Comment


        #4
        Hello spottysallrite,

        Are you using a large enough lookback period to get at least one instance? The code you provided uses either the low of the current bar or the swing low bar depending on which has a higher value. If you want to print just a swing you need to first make sure your lookback period got at least 1 swing and then print the value.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by CaptainJack, 05-29-2026, 05:09 AM
        0 responses
        475 views
        0 likes
        Last Post CaptainJack  
        Started by CaptainJack, 05-29-2026, 12:02 AM
        0 responses
        315 views
        0 likes
        Last Post CaptainJack  
        Started by charlesugo_1, 05-26-2026, 05:03 PM
        0 responses
        253 views
        1 like
        Last Post charlesugo_1  
        Started by DannyP96, 05-18-2026, 02:38 PM
        1 response
        340 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 05-11-2026, 05:56 AM
        0 responses
        305 views
        0 likes
        Last Post CarlTrading  
        Working...
        X