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

StrategyPlot Color wont change.

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

    StrategyPlot Color wont change.

    Trying to alter the color of a StrategyPlot. Various suggestions from other posts will not compile for me. Please see commented out code that fails in the OnBarUpdate() method. What's wrong?

    code:

    protected override void Initialize()
    {

    CalculateOnBarClose = true;
    adx = ADX(adxWindow);
    state = new DataSeries(this);

    Add(StrategyPlot(0));
    Add(StrategyPlot(1));
    // Set the color for the indicator plots
    StrategyPlot(1).Plots[0].Pen.Color = Color.Blue;
    StrategyPlot(1).Plots[0].Pen.Color = Color.Green;

    // 1 = price panel, 2 = panel under the price panel, etc.
    StrategyPlot(0).PanelUI = 2;
    StrategyPlot(1).PanelUI = 3;
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    StrategyPlot(0).Value.Set(adx[0]);

    if (CurrentBar > adxWindow)
    {
    if (adx[0] < noTrend )
    {
    state[0] = -1.0; // notrend
    // StrategyPlot(0).Plotcolors[0][0] = Color.Blue;
    // StrategyPlot(0).Plots[0].Plotcolors[0][0] = Color.Blue;
    StrategyPlot(0).Plots[0].Pen.Color = Color.Blue;
    }
    else if (adx[0] > trending)
    {
    state[0] = 1.0; // trending
    StrategyPlot(0).Plots[0].Pen.Color = Color.Green;
    }
    else
    {
    state[0] = 0; // bouncing along
    StrategyPlot(0).Plots[0].Pen.Color = Color.Red;
    }
    }
    else state[0] = 0;

    StrategyPlot(1).Value.Set(state[0]);
    }

    :code

    PS: How do you add an inline code box in this forum?

    #2
    Hello,

    Thank you for the post.

    It looks like you just have an extra portion of syntax and are referencing the same plot:

    // StrategyPlot(0).Plots[0].Plotcolors[0][0] = Color.Blue;

    should instead be :

    StrategyPlot(1).Plots[0].Pen.Color = Color.Blue;

    Also, I noted you are changing the color for the same strategy plot which would change your results:

    StrategyPlot(1).Plots[0].Pen.Color = Color.Blue;
    StrategyPlot(1).Plots[0].Pen.Color = Color.Green;

    To create a code block on the forum, it is the square braces [ and CODE and ][ and /CODE and ], there is also a button in the advanced editor's toolbar.

    I look forward to being of further assistance.
    Last edited by NinjaTrader_Jesse; 10-11-2017, 03:55 PM.
    JesseNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by popecapllc, 08-09-2023, 07:42 PM
    9 responses
    1,362 views
    0 likes
    Last Post BartMan
    by BartMan
     
    Started by ETFVoyageur, 04-30-2024, 02:04 PM
    11 responses
    101 views
    0 likes
    Last Post ETFVoyageur  
    Started by bubblegum, 03-18-2024, 10:41 AM
    3 responses
    46 views
    0 likes
    Last Post vjsworld  
    Started by JamesK1, Today, 02:48 PM
    1 response
    13 views
    0 likes
    Last Post JamesK1
    by JamesK1
     
    Started by llanqui, Today, 03:51 PM
    0 responses
    13 views
    0 likes
    Last Post llanqui
    by llanqui
     
    Working...
    X