Custom indicator in watchlist opening range

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.


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

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

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

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

New member
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!!!
 

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Top