Signal based on last bar closing outside prior day range


Category:
0
0

Hi Pete

Using a 1 hour timeframe:
1-Draw a blue dot below Last hour bar of the day if CLOSE > Previous Day High
2-Draw a purple dot above Last Hour Bar of the day if CLOSE < Previous Day Low

Any help is appreciated

Marked as spam
Posted by (Questions: 12, Answers: 1)
Asked on October 3, 2020 12:59 pm
69 views
0
Private answer

Very important detail to note. There is a user input that need to be checked anything you place this study on any intraday chart. You need to check the time stamp on the last bar of the regular trading session and make sure the user input is adjusted to match the time on that bar. The time frame you select and some other chart setting can impact how those time stamps are computed.

input higherTimeFrame = AggregationPeriod.DAY;
input closingBarTime = 1500;
def priceHigh = high(period = higherTimeFrame)[1];
def priceLow = low(period = higherTimeFrame)[1];
def lastBar = SecondsTillTime(closingBarTime) == 0;
plot closeAbove = if lastBar and close > priceHigh then low else Double.NaN;
closeAbove.SetPaintingStrategy(PaintingStrategy.POINTS);
closeAbove.SetLineWeight(4);
closeAbove.SetDefaultColor(Color.BLUE);
plot closeBelow = if lastBar and close < priceLow then high else Double.NaN;
closeBelow.SetPaintingStrategy(PaintingStrategy.POINTS);
closeBelow.SetLineWeight(4);
closeBelow.SetDefaultColor(Color.PLUM);

The code reads the previous day high and low from the daily time frame. Which means the code does not include extended hours session when determining the previous day's high and low.

Marked as spam
Posted by (Questions: 37, Answers: 4091)
Answered on October 3, 2020 1:19 pm