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 charlesugo_1, 05-26-2026, 05:03 PM
        0 responses
        56 views
        0 likes
        Last Post charlesugo_1  
        Started by DannyP96, 05-18-2026, 02:38 PM
        1 response
        143 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 05-11-2026, 05:56 AM
        0 responses
        160 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 05-10-2026, 08:12 PM
        0 responses
        96 views
        0 likes
        Last Post CarlTrading  
        Started by Hwop38, 05-04-2026, 07:02 PM
        0 responses
        276 views
        0 likes
        Last Post Hwop38
        by Hwop38
         
        Working...
        X