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 nandhumca, Today, 03:41 PM
    0 responses
    1 view
    0 likes
    Last Post nandhumca  
    Started by The_Sec, Today, 03:37 PM
    0 responses
    3 views
    0 likes
    Last Post The_Sec
    by The_Sec
     
    Started by GwFutures1988, Today, 02:48 PM
    1 response
    5 views
    0 likes
    Last Post NinjaTrader_Clayton  
    Started by ScottWalsh, 04-16-2024, 04:29 PM
    6 responses
    32 views
    0 likes
    Last Post ScottWalsh  
    Started by frankthearm, Today, 09:08 AM
    10 responses
    36 views
    0 likes
    Last Post frankthearm  
    Working...
    X