Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Plotting a Variable

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

    Plotting a Variable

    Hi,

    I would like to add a plot of variable1 on a second panel. What would be the best way to do this?

    Here is the code:

    #region Variables

    private DataSeries ds1;
    private double variable1;

    #endregion

    protected override void Initialize()
    {
    Add("SHY", PeriodType.Minute, 1);
    CalculateOnBarClose = false;

    ds1 = new DataSeries(this);
    }

    protected override void OnBarUpdate()
    {
    if(BarsInProgress == 0)
    {
    ds1.Set(Closes[0][0] / Closes[1][0]);
    variable1 = (SMA(ds1, 14)[0]);
    }

    {

    Code goes here...

    }

    }


    Thanks,

    Lee

    #2
    Hello lee612801,

    Thank you for your post.

    You would add a plot and the set it to the variable.

    For example:
    Code:
    protected override void Initialize() 
    {
    Add("SHY", PeriodType.Minute, 1);
    [B]Add(new Plot(Color.Blue, "myPlot"));[/B]
    
    CalculateOnBarClose = false; 
    
    ds1 = new DataSeries(this);
    }
    
    protected override void OnBarUpdate()
    {
    if(BarsInProgress == 0)
    {
    ds1.Set(Closes[0][0] / Closes[1][0]); 
    variable1 = (SMA(ds1, 14)[0]);
    }
    [B]Value.Set(variable1);[/B]
    }

    Comment


      #3
      Hi Patrick,

      thank you for the reply. How would I then plot that onto a separate second panel? I don't want to plot that onto the primary panel.

      Thanks,

      Lee

      Comment


        #4
        Hello lee612801,

        Thank you for your response.

        In Initialize() set Overlay to False: http://www.ninjatrader.com/support/h...t7/overlay.htm

        Please let me know if I may be of further assistance.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        134 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        75 views
        1 like
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        119 views
        2 likes
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        114 views
        1 like
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        92 views
        0 likes
        Last Post CarlTrading  
        Working...
        X