Draw Horizontal Line

twelvester

New member
I am trying to draw a horizontal line about 5 bars long. But am only able to draw it at the current bar.

Background:
  • To show the break out price level when an Inside Bar occurs
  • The Price Line is the Mother Bar High
  • The Price Line should start at the Mother Bar and end 3 bars later

Current code:
Code:
def RangeMax = Max(high, low);
def RangeMin = Min(high, low);

def IsMotherBarBullish3 = if close[2] > open[2] then 1 else 0;
def IBB3 = if RangeMax[1] < RangeMax[2] and RangeMin[1] > RangeMin[2]
    and IsMotherBarBullish3
    then 1 else 0;
plot IBB3_ = if IBB3 then high[2] else Double.NaN;
IBB3_.setPaintingStrategy(PaintingStrategy.HORIZONTAL);
IBB3_.setLineWeight(1);
IBB3_.setDefaultColor(Color.ORANGE);

Issue:
- The horizontal line is showing only on the 3rd bar

I think it needs to be a recursion but i'm not sure how to make it recursive.
 
Last edited by a moderator:

Tweak155

New member
Code:
def mostRecentBar = !IsNaN(close) and IsNaN(close[-1]);
def mostRecentBarNumExtract = If mostRecentBar Then BarNumber() else Double.NaN;
def mostRecentBarNum = HighestAll(mostRecentBarNumExtract);
plot someStuff = If BarNumber() > (mostRecentBarNum - 5) Then high + 2 else Double.NaN;

EDIT: I see now this thread is 3+ months old :)
 

Similar threads

Top