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 ScottWalsh, Today, 04:29 PM
    0 responses
    5 views
    0 likes
    Last Post ScottWalsh  
    Started by rtwave, 04-12-2024, 09:30 AM
    2 responses
    22 views
    0 likes
    Last Post rtwave
    by rtwave
     
    Started by tsantospinto, 04-12-2024, 07:04 PM
    5 responses
    70 views
    0 likes
    Last Post tsantospinto  
    Started by cre8able, Today, 03:20 PM
    0 responses
    7 views
    0 likes
    Last Post cre8able  
    Started by Fran888, 02-16-2024, 10:48 AM
    3 responses
    49 views
    0 likes
    Last Post Sam2515
    by Sam2515
     
    Working...
    X