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 CarlTrading, 03-31-2026, 09:41 PM
        1 response
        47 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        23 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        33 views
        1 like
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        51 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        42 views
        0 likes
        Last Post CarlTrading  
        Working...
        X