Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.

    JesseNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Segwin, 05-07-2018, 02:15 PM
    14 responses
    1,789 views
    0 likes
    Last Post aligator  
    Started by Jimmyk, 01-26-2018, 05:19 AM
    6 responses
    837 views
    0 likes
    Last Post emuns
    by emuns
     
    Started by jxs_xrj, 01-12-2020, 09:49 AM
    6 responses
    3,294 views
    1 like
    Last Post jgualdronc  
    Started by Touch-Ups, Today, 10:36 AM
    0 responses
    13 views
    0 likes
    Last Post Touch-Ups  
    Started by geddyisodin, 04-25-2024, 05:20 AM
    11 responses
    63 views
    0 likes
    Last Post halgo_boulder  
    Working...
    X