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

Clearing previous plot value

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

    Clearing previous plot value

    Hello,

    A NT8 indicator I'm developing is displaying incorrectly when in tick replay mode vs. calculate on close. The indicator plots a triangle up or triangle down based on detected price patterns. The green up triangles should only plot on up bars at pivot bottoms and the red triangles on down bars at pivot tops. As can be seen in the attached images showing correct vs. incorrect rendering, there are arrows plotted on wrong bars (circled a couple only for brevity). I'm assuming in tick replay at one point the bar was in the opposite direction and temporarily satisfied the condition for plotting the triangle, but by close the condition had changed. If so, how do I clear a plot value? I tried setting it to 0 but that just caused it to plot at price value 0 (distorting the chart in the process as it expanded the scale to show 0 at the bottom).

    I'm doing the following to set the values during the current bar:

    Code:
    			if (pivotLong)
    			{
    		        PivotUp[0] = (Low[0] - pivotOffset);
    			}
    			else if (pivotShort)
    			{
    		        PivotDown[0] = (High[0] + pivotOffset);
    			}
    As a precaution I also added tracking of last pivotLong and pivotShort and added the following to set the last bar on new bar:

    Code:
    			if (CurrentBar != activeBar)
    			{
    				if (lastPivotLong)
    				{
    			        PivotUp[1] = (Low[1] - pivotOffset);
    				}
    				else if (lastPivotShort)
    				{
    			        PivotDown[1] = (High[1] + pivotOffset);
    				}
    				activeBar = CurrentBar;
    			}
    I tried PivotUp.Reset() but that didn't make a difference (same for PivotDown).

    Finally, this is how the plots are added:

    Code:
    				AddPlot(new Stroke(Brushes.MediumSeaGreen, 2), PlotStyle.TriangleUp, "PivotUp");
    				AddPlot(new Stroke(Brushes.Red, 2), PlotStyle.TriangleDown, "PivotDown");
    Thanks.
    Attached Files

    #2
    Figured it out. I needed to do Reset(barsAgo). I was doing Rest without any arguments. Problem solved.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by usazencort, Today, 01:16 AM
    0 responses
    1 view
    0 likes
    Last Post usazencort  
    Started by kaywai, 09-01-2023, 08:44 PM
    5 responses
    603 views
    0 likes
    Last Post NinjaTrader_Jason  
    Started by xiinteractive, 04-09-2024, 08:08 AM
    6 responses
    22 views
    0 likes
    Last Post xiinteractive  
    Started by Pattontje, Yesterday, 02:10 PM
    2 responses
    21 views
    0 likes
    Last Post Pattontje  
    Started by flybuzz, 04-21-2024, 04:07 PM
    17 responses
    230 views
    0 likes
    Last Post TradingLoss  
    Working...
    X