fcastrof
New member
Hi i have this code to put in a watchlist a cutstomm column with the percent of range of the last hour of premarket range, i obtain the high and the low range in the last hour of premarket and calculate the percent of height of that range taken as base the low price of the range, example, if in the last hour of premarket the low price is 120 and the high price on the last hour is 121.30 the percent that represent the height of taht range is: ((121.30 - 120) * 100) / 120 = 1.0833 i need that value in the column. ia lreade have the next code but do not plotme the value that i need.
I apreciate if sombody can helpme with that.
I apreciate if sombody can helpme with that.
Code:
def na = double.nan;
input soloHoy = yes;
def s = soloHoy;
input inicio2 = 0830;
input fin2 = 0930;
def today = if s == 0 OR getDay() == getLastDay() AND secondsFromTime(inicio2) >= 0 then 1 else 0;
Def ORActive2 = if secondsTillTime(fin2) > 0 AND secondsFromTime(inicio2) >= 0 then 1 else 0;
Rec ORHigh2 = if ORHigh2[1] == 0 or ORActive2[1] == 0 AND ORActive2 == 1 then high else if ORActive2 AND high > ORHigh2[1] then high else ORHigh2[1];
Rec ORLow2 = if ORLow2[1] == 0 or ORActive2[1] == 0 AND ORActive2 == 1 then low else if ORActive2 AND low < ORLow2[1] then low else ORLow2[1];
Def ORWidth2 = ORHigh2 - ORLow2;
def alto = if ORActive2 OR today < 1 then na else ORHigh2;
def bajo = if ORActive2 OR today < 1 then na else ORLow2;
def diferencia = alto - bajo;
def pct = (diferencia * 100) / bajo;
plot scan = pct;
AssignBackgroundColor(if pct < 3 then Color.ORANGE else Color.BLACK);