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

Trying to Plot Line in Strategy

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

    Trying to Plot Line in Strategy

    I have a multiple instrument Strategy that is supposed to plot a line on the price chart. I use a Strategy for this because I cannot add multiple instruments to an Indicator.

    This is the code for it which is compilable:

    #region Using declarations
    using System;
    using System.ComponentModel;
    using System.Diagnostics;
    using System.Drawing;
    using System.Drawing.Drawing2D;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Data;
    using NinjaTrader.Indicator;
    using NinjaTrader.Strategy;
    #endregion

    namespace NinjaTrader.Strategy
    {
    [Description("Plots the Value of the Dow 30 over the DJIA in real time.")]
    publicclass Dow30Price : Strategy
    {

    #region Variables
    private DateTime activeBar;
    private DateTime startTime;
    privatedouble SymbolClose;
    #endregion

    protectedoverridevoid Initialize()
    {
    CalculateOnBarClose = false;
    startTime = DateTime.Now;

    Add("AA", PeriodType.Tick, 1);
    Add("AXP", PeriodType.Tick, 1);
    Add("BA", PeriodType.Tick, 1);
    Add("BAC", PeriodType.Tick, 1);
    Add("C", PeriodType.Tick, 1);
    Add("CAT", PeriodType.Tick, 1);
    Add("CVX", PeriodType.Tick, 1);
    Add("DD", PeriodType.Tick, 1);
    Add("DIS", PeriodType.Tick, 1);
    Add("GE", PeriodType.Tick, 1);
    Add("GM", PeriodType.Tick, 1);
    Add("HD", PeriodType.Tick, 1);
    Add("HPQ", PeriodType.Tick, 1);
    Add("IBM", PeriodType.Tick, 1);
    Add("INTC", PeriodType.Tick, 1);
    Add("JNJ", PeriodType.Tick, 1);
    Add("JPM", PeriodType.Tick, 1);
    Add("KFT", PeriodType.Tick, 1);
    Add("KO", PeriodType.Tick, 1);
    Add("MCD", PeriodType.Tick, 1);
    Add("MMM", PeriodType.Tick, 1);
    Add("MRK", PeriodType.Tick, 1);
    Add("MSFT", PeriodType.Tick, 1);
    Add("PFE", PeriodType.Tick, 1);
    Add("PG", PeriodType.Tick, 1);
    Add("T", PeriodType.Tick, 1);
    Add("UTX", PeriodType.Tick, 1);
    Add("VZ", PeriodType.Tick, 1);
    Add("VZ", PeriodType.Tick, 1);
    Add("WMT", PeriodType.Tick, 1);
    Add("XOM", PeriodType.Tick, 1);

    StrategyPlot(0).Plots[0].Pen.Color = Color.DarkBlue;
    //StrategyPlot(0).Plots[0].PlotStyle = PlotStyle.Line;
    Add(StrategyPlot(0));
    StrategyPlot(0).PanelUI = 1;
    }

    protectedoverridevoid OnBarUpdate()
    {
    SymbolClose = 0;
    for(int SymbolNumber=1;SymbolNumber<31;SymbolNumber++)
    {
    //Print("SymbolNumber "+SymbolNumber+" Close "+Closes[SymbolNumber][0]);
    SymbolClose = SymbolClose + Closes[SymbolNumber][0];
    }
    SymbolClose = SymbolClose / 0.125552709;
    StrategyPlot(0).Value.Set(SymbolClose);
    }

    #region Properties
    #endregion
    }
    }


    Instead of drawing a line on the price chart, it draws a histogram. I've tried adding:

    StrategyPlot(0).Plots[0].PlotStyle = PlotStyle.Line;

    to the Initialize section (you'll see it commented out above), but when I try to compile it, it give me the following error message:

    The name 'PlotStyle' does not exist in the current context CS0103-click for info. I clicked for the info, but the help section doesn't seem to give me anything relevant.

    What am I doing wrong here?

    #2
    Not sure why you can't compile. It compiles fine on my end. Please ensure you are on NT6.5.1000.10.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      I got it to work

      Here's what I did:

      I cut and paste the code into MS Notepad

      Deleted the old Strategy

      Created and new strategy

      put the old code and compiled it line-by-line

      And it works the way I want it to now....Don't ask me why.

      Thanks for your help.

      Yam Digger

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by wuannetraam, Today, 02:40 AM
      0 responses
      7 views
      0 likes
      Last Post wuannetraam  
      Started by cyberpete76, 03-27-2023, 12:29 AM
      7 responses
      269 views
      1 like
      Last Post slightly  
      Started by renewsaltwater, Today, 01:15 AM
      0 responses
      2 views
      0 likes
      Last Post renewsaltwater  
      Started by slightly, Today, 12:49 AM
      0 responses
      4 views
      0 likes
      Last Post slightly  
      Started by sdauteuil, 09-23-2021, 10:16 AM
      4 responses
      1,211 views
      0 likes
      Last Post jacobpescaia44  
      Working...
      X