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

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 WHICKED, Today, 12:56 PM
        2 responses
        14 views
        0 likes
        Last Post WHICKED
        by WHICKED
         
        Started by Felix Reichert, Today, 02:12 PM
        0 responses
        1 view
        0 likes
        Last Post Felix Reichert  
        Started by Tim-c, Today, 02:10 PM
        0 responses
        1 view
        0 likes
        Last Post Tim-c
        by Tim-c
         
        Started by cre8able, Today, 01:16 PM
        2 responses
        9 views
        0 likes
        Last Post cre8able  
        Started by chbruno, 04-24-2024, 04:10 PM
        3 responses
        49 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Working...
        X