Percent change from premarket low to premarket high


Category:
0
0

Hey Pete, I am struggling to create a simple chart script that shows the percent change from the premarket low to premarket high (4am-9:29am est)

A simple chart label would work fine.

 

An example ticker to use would be $BOF 4/24/24. Where the value would be 93%

 

Best

Marked as spam
Posted by (Questions: 1, Answers: 0)
Asked on April 24, 2024 3:59 pm
13 views
0
Private answer

We can steal most of the code for this solution from a previous post which displays labels for the premarket high and low:

https://www.hahn-tech.com/ans/premarket-highlow-label/

That solution also include user inputs so you can adjust the start and end time to suit your own preferences.

Here is that same exact solution with two new lines of code added to display a third label for the percent change from premarket low to premarket high:

input startTime = 400;
input endTime = 929;
def timeUntilClose = SecondsTillTime(endTime);
def timeUntilOpen = SecondsTillTime(startTime);
def targetPeriod = timeUntilClose > 0;
rec targetPeriodHigh = if targetPeriod and !targetPeriod[1] then high else if targetPeriod and high > targetPeriodHigh[1] then high else targetPeriodHigh[1];
rec targetPeriodLow = if targetPeriod and !targetPeriod[1] then low else if targetPeriod and low < targetPeriodLow[1] and low > 0 then low else targetPeriodLow[1];
AddLabel(yes, Concat("Period High: ", targetPeriodHigh), Color.GREEN);
AddLabel(yes, Concat("Period Low: ", targetPeriodLow), Color.RED);
def percentChange = Round(100 * (targetPeriodHigh / targetPeriodLow - 1), 2);
AddLabel(yes, Concat("Low To High: ", Concat(percentChange, "% ")), Color.WHITE);

Marked as spam
Posted by (Questions: 37, Answers: 4087)
Answered on April 24, 2024 4:06 pm