Chicago Ill. US
Posts: 2 since Mar 2017
Thanks Given: 0
Thanks Received: 0
|
Hi all,
I am somewhat of a newbie to thinkscript and have been pulling my hair out trying to get this script to do what I want.
If someone could help, it would be greatly appreciated.
The script plots the ORH & ORL on the chart and alerts when price crosses above the ORH, But I would like to be able to control the time period when the alert triggers. The code is below:
# Automatic Opening Range With ORH/ORL Alerts
#
# This Thinkscript is designed to plot the OR high & low,
# This will only work correctly on time-based charts,
# where the OR timeframe is divisible by the bar period
# e.g. 30 minute OR, 10 min bars.
#
input agg = AggregationPeriod.Fifteen_MIN;
# Show Today only?(Default Yes)
input ShowTodayOnly = Yes;
def today = if !ShowTodayOnly then 1 else GetDay() == GetLastDay();
def lookback = SecondsFromTime(0930) / GetAggregationPeriod() * 1000;
# Plot OR range
plot ORh = if !today then double.nan else GetValue(high(period = agg), lookback);
ORh.Setstyle(curve.Long_DASH);
ORh.SetDefaultColor(color.green);
ORh.SetLineWeight(1);
plot ORl = if !today then double.nan else GetValue(low(period = agg), lookback);
AddCloud(ORH,ORL);
# Color formatting
ORl.SetStyle(curve.Long_DASH);
ORl.SetDefaultColor(color.red);
ORl.SetLineWeight(1);
#Trigger Alerts on breach of Opening Range High
#
alert(close>=ORH,”ORH b/o”,alert.ONCE,sound.DING);
|