Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Plotting newbie question

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

    Plotting newbie question

    I have read through best I can on plotting (NT7b20) and this is what I understand and what I am trying to do in a strategy:

    protected override void Initialize()
    {
    Add(EMA(11)); // plots the moving average continuously
    //
    // adds a StrategyPlot indicator to paint the 'stop loss' with.
    Add(StrategyPlot(0));
    StrategyPlot(0).Plots[0].Pen.Color = Color.Black;
    StrategyPlot(0).Plots[0].PlotStyle = PlotStyle.Square;
    StrategyPlot(0).PanelUI = 1;
    StrategyPlot(0).Name = "StopLoss";
    } // so that is all fine

    // but I only want to have plotting completed on certain conditions as:

    protected override void OnBarUpdate()
    { // this condition
    if (EMA(11)[0] > (EMA(5)[0] // does not
    { // plot something somehow} //have a way of plotting

    // and this condition
    while (EMA(11)[0] > (EMA(5)[0] // also does not
    { // plot something somehow} //have a way of plotting

    }
    // so what can I use in OnBarUpdate to plot on certain conditions

    TIA,
    Jon
    Last edited by Trader.Jon; 08-19-2010, 02:30 PM.

    #2
    Jon, you could use a plot, but there are also quite a few different drawing objects you could place on the chart, like squares, dots, triangles, arrows, diamonds, etc. So if you wanted to place arrows on each crossover, for example, you could do something like this:
    Code:
    if (CrossAbove(EMA(5), EMA(11), 1))
                    DrawArrowUp("up arrow" + CurrentBar, false, 0, Low[0] - 2 * TickSize, Color.Green);
    if (CrossBelow(EMA(5), EMA(11), 1))
                    DrawArrowDown("down arrow" + CurrentBar, false, 0, High[0] + 2 * TickSize, Color.Red);
    I actually have a script laying around that does just this.. I've attached it for your convenience.
    Attached Files
    AustinNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    56 views
    0 likes
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    143 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    160 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 05-10-2026, 08:12 PM
    0 responses
    96 views
    0 likes
    Last Post CarlTrading  
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    276 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Working...
    X