windowshopr
Member
I'm working on a High of Day Momentum Breakout type strategy, and would like to be able to plot TODAY's rolling highest high, but I'm running into some issues that I think pertain to bar counting. woohoo......
This is what I have so far:
(Notice how I'm using shifts of [1] here as I will be looking for the current bar's high to breakout from the previous high.)
The problem with this code is the length used for the Highest() function, as I receive the "Only constants expected here" because the length of potentialBarDiff changes as bars progress.
There's a lot of content around getting yesterday's high which I've already done, but as today's high pushes higher, I want to plot the highest high for today, which is (psuedo):
Am I on the right track here, or is there a script already made for this somewhere that I just haven't found yet?
This is what I have so far:
Code:
# Get yesterday's high to use for today
def yesterdaysHigh = DailyHighLow("aggregation period" = AggregationPeriod.DAY, length = 1, displace = -1, "show only last period" = no).DailyHigh;
# Mark the BarNumber() for today's opening bar
def todaysOpeningBarNumber = if GetDay() != GetDay()[1] then BarNumber() else todaysOpeningBarNumber[1];
# Get the difference between the previous bar's BarNumber()
# and todaysOpeningBarNumber to use as the Highest(length)
# parameter next
def potentialBarDiff = BarNumber()[1] - todaysOpeningBarNumber;
# Get the highest high from today's opening bar up to the previous
# bar
def highestHighSinceOpeningBar = Highest(data=high[1], length=potentialBarDiff);
# Plot today's highest high!
plot currentDailyHigh = Max(yesterdaysHigh, highestHighSinceOpeningBar);
currentDailyHigh.SetDefaultColor(Color.YELLOW);
(Notice how I'm using shifts of [1] here as I will be looking for the current bar's high to breakout from the previous high.)
The problem with this code is the length used for the Highest() function, as I receive the "Only constants expected here" because the length of potentialBarDiff changes as bars progress.
There's a lot of content around getting yesterday's high which I've already done, but as today's high pushes higher, I want to plot the highest high for today, which is (psuedo):
Code:
def currentDailyHigh = Max(yesterdaysHigh, Highest(data=high[1], length=BarNumber() - todaysOpeningBarNumber))
Am I on the right track here, or is there a script already made for this somewhere that I just haven't found yet?