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 TraderBCL, Today, 04:38 AM
    2 responses
    16 views
    0 likes
    Last Post TraderBCL  
    Started by martin70, 03-24-2023, 04:58 AM
    14 responses
    106 views
    0 likes
    Last Post martin70  
    Started by Radano, 06-10-2021, 01:40 AM
    19 responses
    609 views
    0 likes
    Last Post Radano
    by Radano
     
    Started by KenneGaray, Today, 03:48 AM
    0 responses
    5 views
    0 likes
    Last Post KenneGaray  
    Started by thanajo, 05-04-2021, 02:11 AM
    4 responses
    471 views
    0 likes
    Last Post tradingnasdaqprueba  
    Working...
    X