Announcement

Collapse
No announcement yet.

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 frslvr, Today, 04:29 PM
    0 responses
    11 views
    0 likes
    Last Post frslvr
    by frslvr
     
    Started by wjadevries, Today, 04:18 PM
    0 responses
    5 views
    0 likes
    Last Post wjadevries  
    Started by shahabjet1, Today, 03:47 PM
    2 responses
    12 views
    0 likes
    Last Post shahabjet1  
    Started by JTizz, Today, 03:21 PM
    1 response
    6 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by EB Worx, Today, 02:49 PM
    1 response
    10 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Working...
    X