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 Waxavi, Today, 02:10 AM
    0 responses
    4 views
    0 likes
    Last Post Waxavi
    by Waxavi
     
    Started by TradeForge, Today, 02:09 AM
    0 responses
    10 views
    0 likes
    Last Post TradeForge  
    Started by Waxavi, Today, 02:00 AM
    0 responses
    2 views
    0 likes
    Last Post Waxavi
    by Waxavi
     
    Started by elirion, Today, 01:36 AM
    0 responses
    4 views
    0 likes
    Last Post elirion
    by elirion
     
    Started by gentlebenthebear, Today, 01:30 AM
    0 responses
    4 views
    0 likes
    Last Post gentlebenthebear  
    Working...
    X