What's the Thinkscript code for 3rd candle?

johnnykalsi

New member
I'm looking to build a watchlist scanner with the following condition

3rd 30 min candles crosses above or below the 2.0 Bollingerband

I dont know how to get the 3rd candle
 
Solution
Code:
input BarWanted = 3;
plot IsBarWanted = getTime() - regularTradingStart(GetYYYYMMDD()) - 1 == getAggregationPeriod() * (BarWanted - 1);
IsBarWanted.setPaintingStrategy(paintingStrategy.BOOLEAN_ARROW_UP);

Joshua

Well-known member
VIP
Code:
input BarWanted = 3;
plot IsBarWanted = getTime() - regularTradingStart(GetYYYYMMDD()) - 1 == getAggregationPeriod() * (BarWanted - 1);
IsBarWanted.setPaintingStrategy(paintingStrategy.BOOLEAN_ARROW_UP);
 
Solution

johnnykalsi

New member
Code:
input BarWanted = 3;
plot IsBarWanted = getTime() - regularTradingStart(GetYYYYMMDD()) - 1 == getAggregationPeriod() * (BarWanted - 1);
IsBarWanted.setPaintingStrategy(paintingStrategy.BOOLEAN_ARROW_UP);
Thank you...this is too complicated for me...wasn't expecting such a complex code. I'll to build a scan from above.
Thanks again Joshua for writing this..
 

johnnykalsi

New member
Code:
input BarWanted = 3;
plot IsBarWanted = getTime() - regularTradingStart(GetYYYYMMDD()) - 1 == getAggregationPeriod() * (BarWanted - 1);
IsBarWanted.setPaintingStrategy(paintingStrategy.BOOLEAN_ARROW_UP);
Hi Joshua

I came up with this but it doesnt plot it correctly. I get up arrows on all the bars

plot Data = close;
input BarWanted = 3;
Def IsBarWanted = getTime() - regularTradingStart(GetYYYYMMDD()) - 1 == getAggregationPeriod() * (BarWanted - 1);
#IsBarWanted.setPaintingStrategy(paintingStrategy.BOOLEAN_ARROW_UP);


input price = close;
input displace = 0;
input length = 20;
input Num_Dev_Dn = -2.0;
input Num_Dev_up = 2.0;
input averageType = AverageType.Simple;

def sDev = stdev(data = price[-displace], length = length);

plot MidLine = MovingAverage(averageType, data = price[-displace], length = length);
plot LowerBand = MidLine + num_Dev_Dn * sDev;
#plot UpperBand = MidLine + num_Dev_Up * sDev;
plot Lowercross = IsBarWanted < LowerBand;
Lowercross.setPaintingStrategy(paintingStrategy.ARROW_UP);


I'm trying to setup a scan that will tell me when there are 3 consecutive bars crossing below or above the Bollinger band
 

Similar threads

Top