Draw Horizontal Line

T

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:
inthefutures

inthefutures

Active member
plot IBB3 = if high[2],and high[3] and high[4] else Double.NaN;

this might fix it
 
S

scriptorswim

New member
How to auto draw a horizontal line in an indicator?
 
Last edited by a moderator:
M

MrDrB

New member
VIP
plot my_line = 1; #change 1 to whatever static value or variable you want it to plot
 
S

scriptorswim

New member
plot my_line = 1; #change 1 to whatever static value or variable you want it to plot

how about the value of the first 1m candle each day opening? day.open types dont work
 
T

Tweak155

New member
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