When a Dot won't Plot!?

netarchitech

Well-known member
VIP
Given the following code:

Code:
def data = if close > close[1] then close - Min(close[1], low) else if close < close[1] then close - Max(close[1], high) else 0;
def AccDist = TotalSum(data);

plot SwingLo = if AccDist == 0 then low else Double.NaN;;
SwingLo.SetPaintingStrategy(PaintingStrategy.POINTS);
SwingLo.SetDefaultColor(CreateColor(0, 102, 204));
SwingLo.SetLineWeight(5);

plot SwingHi = if AccDist == 100 then high else Double.NaN;
SwingHi.SetPaintingStrategy(PaintingStrategy.POINTS);
SwingHi.SetDefaultColor(CreateColor(0, 102, 204));
SwingHi.SetLineWeight(5);

Try as I may, I can't get a Dot to plot...I've tried many variations to no avail...Must be all the late nights catching up with me...

Thanks in advance :)
 
Last edited:

netarchitech

Well-known member
VIP
Hey there @BenTen

Thanks for your inquiry...What I'm trying to do is plot a dot similar to the illustration below:

2020-10-30-17-55-03.png


I am at a loss to figure out where I went wrong...Below is my other best guess:

Code:
def data = if close > close[1] then close - Min(close[1], low) else if close < close[1] then close - Max(close[1], high) else 0;
def AccDist = TotalSum(data);
def Lo = if AccDist == 0 then low else Double.NaN;
def Hi = if AccDist == 100 then high else Double.NaN;

plot SwingLo = Lo;
SwingLo.SetPaintingStrategy(paintingStrategy.POINTS);
SwingLo.SetDefaultColor(CreateColor(0, 102, 204));
SwingLo.SetLineWeight(5);

plot SwingHi = Hi;
SwingHi.SetPaintingStrategy(paintingStrategy.POINTS);
SwingHi.SetDefaultColor(CreateColor(0, 102, 204));
SwingHi.SetLineWeight(5);

Any thoughts? Thanks in advance :)
 

BenTen

Administrative
Staff
VIP
@netarchitech I think I know why it's not plotting. If you hover over to the line from your lower study, you'll see that it never lands at the perfect 100 value. The same goes to the 0 value that you're looking for. As a result, the dot was not plotted.
 

BenTen

Administrative
Staff
VIP
@netarchitech Only way is to set a hard cap at 100 and 0, so that the line does not go beyond 100 or below 0. Until you do that, it would be almost impossible to identify when the AccDist is at exactly either number.
 

Similar threads

Top