Help on referencing Prev Bar being true


Category:
0
0

Hello,

I am NOT a programmer, but I can work / understand previous code and attempt to build my own (until I get stuck). Thanks for sharing all this knowledge in the site which will really help me improve. I looked for a solution here but couldn’t solve it. I think it’s really simple syntax I am not getting, but maybe I am not thinking it correctly.

I created a simple 3 bar pattern, and when true place an arrow on the last bar.

Now I want to add a Point on the NEXT BAR IF the HIGH is taken out. Below the code and attach a snapshot.

# Buy Setup
def IsUp = close > open;
def IsDown = close < open;

#Filters
Input SMAPeriod = 8;
input price = close;
input vwapfilter = yes;

def vwap = reference VWAP().”VWAP”;
def sma = SimpleMovingAvg(price, SMAPeriod);

plot PatternPlot =
IsDown[1] and

high[2] > high[1] and

High[1] > High[0] and

low[2] > low[1] and

high[2] and High[1] > sma and
if vwapfilter == yes then high[0] > sma and high[0] > vwap else high[0] > sma; –> #Filter to plot > VWAP only

PatternPlot.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
PatternPlot.SetDefaultColor(GetColor(6));

#From here is how I thought of referencing previous bar for the PatternPlot = True 
plot Entry =
PatternPlot within 1 bar and  –> # I tried several ways to express it but none of them seem to work
High[0]>High[1];
Entry.SetPaintingStrategy(PaintingStrategy.pointS);
Entry.SetDefaultColor(GetColor(8));

Hope you can help me solve this and keep learning.

Tks so much.

 

 

 

 

Attachments:
Marked as spam
Posted by (Questions: 4, Answers: 8)
Asked on February 21, 2020 2:21 am
71 views
0
Private answer

With your true/false condion variable named "PatternPlot", there are two ways to check if it was true on the previous bars. You can use the array index of [1] or you can use the English language version of that "1 bars ago". Here is what each of those would look like in your code:

plot Entry = PatternPlot[1];

plot Entry = PatternPlot 1 bars ago;

Marked as spam
Posted by (Questions: 37, Answers: 4079)
Answered on February 21, 2020 8:42 am
0
Thanks !!! I was messing up with the Boolean and Numeric Paintbar types. Syntax was ok, but it took some time until I understood how it works.
( at February 21, 2020 11:21 am)