Custom indicator in watchlist opening range

fcastrof

fcastrof

New member
VIP
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.


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);
 
T

tomsk

Well-known member
VIP
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.


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);

@fcastrof Your watchlist code does seem to plot the values you seek. I think the AssignBackgroundColor statement may be preventing you from seeing the plot values so I suggest you comment that out. That's exactly what I did and I did see those values on the watchlist after deleting that statement
 
fcastrof

fcastrof

New member
VIP
@fcastrof Your watchlist code does seem to plot the values you seek. I think the AssignBackgroundColor statement may be preventing you from seeing the plot values so I suggest you comment that out. That's exactly what I did and I did see those values on the watchlist after deleting that statement
Thanks, but the values of the high and the low do not correspond to the present day, that is the real problem, how can i obtain the high and low of the last hour of premarket?
Thanks i hope you can help me.
 
T

tomsk

Well-known member
VIP
Nope, nothing wrong with your premarket high/low values. Running it today on /ES at 1 min, I see a premarket high of 3284 and low of 3277.50. I wrote an independent study, it reported the exact same values as your study. On top of that a visual inspection confirmed those values as well. Hence nothing to fix
 
Last edited:
fcastrof

fcastrof

New member
VIP
Nope, nothing wrong with your premarket high/low values. Running it today on /ES at 1 min, I see a premarket high of 3284 and low of 3277.50. I wrote an independent study, it reported the exact same values as your study. On top of that a visual inspection confirmed those values as well. Hence nothing to fix
Thanks for your help, sorry i do not see your response, let me check it. Thanks!!!
 

Similar threads

Top