Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Adding Indicator Plot on Secondary Time Series

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

    Adding Indicator Plot on Secondary Time Series

    Hi,

    I'm trying to add a daily indicator to a 30 minute chart through a strategy. I searched the forum for help and found a post on adding a plot and then setting Values[0][0] in OnBarUpdate and from that, I can get an SMA to work just fine. The problem is when I try to use the Swing indicator, it no longer works. It prints dots on the chart but they aren't accurate.

    Code:

    Code:
    if (State == State.SetDefaults)
    {​
    AddPlot(new Stroke(Brushes.Blue), PlotStyle.Dot, "DAILYSWING");
    }
    
    else if (State == State.Configure)
    {
    AddDataSeries(BarsPeriodType.Second, 15);
    AddDataSeries(BarsPeriodType.Day, 1);
    }​
    
    if (BarsInProgress == 0)
    {​
    Values[0][0] = Low[Math.Max(0, Swing(BarsArray[2], 2).SwingLowBar(0, 1, 1000))];
    }
    
    #region Properties
    [Browsable(false)]
    [XmlIgnore]
    public Series<double> DAILYSWING
    {
    get { return Values[0]; }
    }
    #endregion​
    If I just use "Values[0][0] = SMA(BarsArray[2], 50)[0]" instead, the SMA looks perfect.

    Any idea why? Appreciate any insight.

    #2
    Hello fiddich,

    The swing indicator would be an exception because it re writes past data to its plots so replotting it would result in different values. You can use its custom methods however those just find the swing instances after the fact, that wouldn't be helpful to plot it as it calculates. To incorporate the swing and a plot it you would essentially need to copy the swings code into your script and process it on the daily bars. You could have it plot values however the plots have the number of primary bar slots so it would not be the same as you would see it on a daily chart and you would need to make additional logic to carry over past values to new bars on the lower timeframe series.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    43 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    20 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    29 views
    1 like
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    46 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    38 views
    0 likes
    Last Post CarlTrading  
    Working...
    X