Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Looks good, is there a script available to test?ESU23 9/11/23 17:00
![]()
#Support/Resistance Above
declare once_per_bar;
input Time_Of_First_Bar_Of_Day = 1800;
input spacing = 10;
def ADOpen = CompoundValue(1, if SecondsFromTime(Time_Of_First_Bar_Of_Day) == 0 then open else ADOpen[1], 0);
def BarOpen = CompoundValue(1, if SecondsFromTime(Time_Of_First_Bar_Of_Day) == 0 then AbsValue(BarNumber()) else BarOpen[1], 0);
def SMA100 = reference SimpleMovingAvg(close, 100);
def SMA200 = reference SimpleMovingAvg(close, 200);
def SMA500 = reference SimpleMovingAvg(close, 500);
def a = (SMA100+ SMA200+ SMA500) / 3;
def Cross = if Crosses(SMA100, SMA200, CrossingDirection.ANY) then SMA200 else if Crosses(SMA100, SMA500, CrossingDirection.ANY) then SMA500 else if Crosses(SMA200, SMA500, CrossingDirection.ANY) then SMA500 else if Crosses(SMA100, a, CrossingDirection.ANY) then a else if Crosses(SMA200, a, CrossingDirection.ANY) then a else if Crosses(SMA500, a, CrossingDirection.ANY) then a else Cross[1];
#######################################################################################
#Define/Plot Levels..##################################################################
#######################################################################################
script Targets {
input Time_Of_First_Bar_Of_Day = 0;
input BarOpen = 0;
input Cross = 0;
input ADOpen = 0;
input Spacing = 0;
def TA = if SecondsFromTime(Time_Of_First_Bar_Of_Day) == 0 and !isnan(close) then
fold a = 0 to BarOpen
with inta = Double.POSITIVE_INFINITY
do if IsNaN(GetValue(Cross,a)) then inta
else if GetValue(Cross,a) < ADOpen then inta
else if GetValue(Cross,a) > inta then inta
else if GetValue(Cross,a) < inta and GetValue(Cross,a) > ADOpen + Spacing
then GetValue(Cross,a)
else inta
else TA[1];
plot Targets = TA;
}
################################
plot PAC1 = Targets(Time_Of_First_Bar_Of_Day,BarOpen,Cross,ADOpen,0);
PAC1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PAC1.SetLineWeight(1);
plot PAC2 = Targets(Time_Of_First_Bar_Of_Day,BarOpen,Cross,PAC1,Spacing);
PAC2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PAC2.SetLineWeight(1);
plot PAC3 = Targets(Time_Of_First_Bar_Of_Day,BarOpen,Cross,PAC2,Spacing);
PAC3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PAC3.SetLineWeight(1);
plot PAC4 = Targets(Time_Of_First_Bar_Of_Day,BarOpen,Cross,PAC3,Spacing);
PAC4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PAC4.SetLineWeight(1);
plot PAC5 = Targets(Time_Of_First_Bar_Of_Day,BarOpen,Cross,PAC4,Spacing);
PAC5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PAC5.SetLineWeight(1);
#Support/Resistance Below
declare once_per_bar;
input Time_Of_First_Bar_Of_Day = 1800;
input spacing = 10;
def ADOpen = CompoundValue(1, if SecondsFromTime(Time_Of_First_Bar_Of_Day) == 0 then open else ADOpen[1], 0);
def BarOpen = CompoundValue(1, if SecondsFromTime(Time_Of_First_Bar_Of_Day) == 0 then AbsValue(BarNumber()) else BarOpen[1], 0);
def SMA100 = reference SimpleMovingAvg(close, 100);
def SMA200 = reference SimpleMovingAvg(close, 200);
def SMA500 = reference SimpleMovingAvg(close, 500);
def a = (SMA100 + SMA200 + SMA500) / 3;
def Cross = if Crosses(SMA100, SMA200, CrossingDirection.ANY) then SMA200 else if Crosses(SMA100, SMA500, CrossingDirection.ANY) then SMA500 else if Crosses(SMA200, SMA500, CrossingDirection.ANY) then SMA500 else if Crosses(SMA100, a, CrossingDirection.ANY) then a else if Crosses(SMA200, a, CrossingDirection.ANY) then a else if Crosses(SMA500, a, CrossingDirection.ANY) then a else Cross[1];
#######################################################################################
#Define/Plot Levels..##################################################################
#######################################################################################
script Targets {
input Time_Of_First_Bar_Of_Day = 0;
input BarOpen = 0;
input Cross = 0;
input ADOpen = 0;
input Spacing = 0;
def TA = if SecondsFromTime(Time_Of_First_Bar_Of_Day) == 0 and !IsNaN(close) then
fold a = 0 to BarOpen
with inta = Double.NEGATIVE_INFINITY
do if IsNaN(GetValue(Cross,a)) then inta
else if GetValue(Cross, a) > ADOpen then inta
else if GetValue(Cross, a) < inta then inta
else if GetValue(Cross, a) > inta and GetValue(Cross, a) < ADOpen - Spacing
then GetValue(Cross, a)
else inta
else TA[1];
plot Targets = if !TA then Double.NEGATIVE_INFINITY else TA;
}
################################
plot PBC1 = Targets(Time_Of_First_Bar_Of_Day, BarOpen, Cross, ADOpen, 0);
PBC1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PBC1.SetLineWeight(1);
plot PBC2 = Targets(Time_Of_First_Bar_Of_Day, BarOpen, Cross, PBC1, Spacing);
PBC2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PBC2.SetLineWeight(1);
plot PBC3 = Targets(Time_Of_First_Bar_Of_Day, BarOpen, Cross, PBC2, Spacing);
PBC3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PBC3.SetLineWeight(1);
plot PBC4 = Targets(Time_Of_First_Bar_Of_Day, BarOpen, Cross, PBC3, Spacing);
PBC4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PBC4.SetLineWeight(1);
plot PBC5 = Targets(Time_Of_First_Bar_Of_Day, BarOpen, Cross, PBC4, Spacing);
PBC5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PBC5.SetLineWeight(1);
declare once_per_bar;
input Time_Of_First_Bar_Of_Day = 1800;
def ADOpen = CompoundValue(1, if SecondsFromTime(Time_Of_First_Bar_Of_Day) == 0 then open else ADOpen[1], 0);
def BarOpen = CompoundValue(1, if SecondsFromTime(Time_Of_First_Bar_Of_Day) == 0 then AbsValue(BarNumber()) else BarOpen[1], 0);
def SMA100 = reference SimpleMovingAvg(close, 100);
def SMA200 = reference SimpleMovingAvg(close, 200);
def SMA500 = reference SimpleMovingAvg(close, 500);
def a = (SMA100 + SMA200 + SMA500) / 3;
def Cross = if Crosses(SMA100, SMA200, CrossingDirection.ANY) then Round(Round(SMA200 / TickSize(), 0) * TickSize(),2) else if Crosses(SMA100, SMA500, CrossingDirection.ANY) then Round(Round(SMA500 / TickSize(), 0) * TickSize(),2) else if Crosses(SMA200, SMA500, CrossingDirection.ANY) then Round(Round(SMA500 / TickSize(), 0) * TickSize(),2) else if Crosses(SMA100, a, CrossingDirection.ANY) then Round(Round(a / TickSize(), 0) * TickSize(),2) else if Crosses(SMA200, a, CrossingDirection.ANY) then Round(Round(a / TickSize(), 0) * TickSize(),2) else if Crosses(SMA500, a, CrossingDirection.ANY) then Round(Round(a / TickSize(), 0) * TickSize(),2) else Cross[1];
#######################################################################################
#Define/Plot Levels..##################################################################
#######################################################################################
script TargetsA {
input Time_Of_First_Bar_Of_Day = 0;
input BarOpen = 0;
input Cross = 0;
input ADOpen = 0;
def TA = if SecondsFromTime(Time_Of_First_Bar_Of_Day) == 0 and !isnan(close) then
fold a = 0 to BarOpen
with inta = Double.POSITIVE_INFINITY
do if IsNaN(GetValue(Cross,a)) then inta
else if GetValue(Cross,a) < ADOpen then inta
else if GetValue(Cross,a) > inta then inta
else if GetValue(Cross,a) < inta and GetValue(Cross,a) > ADOpen
then GetValue(Cross,a)
else inta
else TA[1];
plot Targets = TA;
}
#######################################################################################
script TargetsB {
input Time_Of_First_Bar_Of_Day = 0;
input BarOpen = 0;
input Cross = 0;
input ADOpen = 0;
def TA = if SecondsFromTime(Time_Of_First_Bar_Of_Day) == 0 and !IsNaN(close) then
fold a = 0 to BarOpen
with inta = Double.NEGATIVE_INFINITY
do if IsNaN(GetValue(Cross,a)) then inta
else if GetValue(Cross, a) > ADOpen then inta
else if GetValue(Cross, a) < inta then inta
else if GetValue(Cross, a) > inta and GetValue(Cross, a) < ADOpen
then GetValue(Cross, a)
else inta
else TA[1];
plot Targets = if !TA then Double.NEGATIVE_INFINITY else TA;
}
def CAC = TargetsA(Time_Of_First_Bar_Of_Day,BarOpen,Cross,ADOpen);
def CBC = TargetsB(Time_Of_First_Bar_Of_Day, BarOpen, Cross, ADOpen);
def C = CompoundValue(1,if SecondsFromTime(Time_Of_First_Bar_Of_Day) == 0 then if AbsValue(ADOpen - CAC) >= AbsValue(ADOpen - CBC) then ADOpen - AbsValue(ADOpen - CBC) else ADOpen + AbsValue(ADOpen - CAC) else C[1],ADOpen);#TargetsB(Time_Of_First_Bar_Of_Day, BarOpen, Cross, Cross, 0);
plot PC = C;
PC.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PC.SetLineWeight(1);
################################
plot PAC1 = TargetsA(Time_Of_First_Bar_Of_Day,BarOpen,PC,PC);
PAC1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PAC1.SetLineWeight(1);
plot PAC2 = TargetsA(Time_Of_First_Bar_Of_Day,BarOpen,PC,PAC1);
PAC2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PAC2.SetLineWeight(1);
plot PAC3 = TargetsA(Time_Of_First_Bar_Of_Day,BarOpen,PC,PAC2);
PAC3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PAC3.SetLineWeight(1);
plot PAC4 = TargetsA(Time_Of_First_Bar_Of_Day,BarOpen,PC,PAC3);
PAC4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PAC4.SetLineWeight(1);
plot PAC5 = TargetsA(Time_Of_First_Bar_Of_Day,BarOpen,PC,PAC4);
PAC5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PAC5.SetLineWeight(1);
################################
plot PBC1 = TargetsB(Time_Of_First_Bar_Of_Day, BarOpen, PC, PC);
PBC1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PBC1.SetLineWeight(1);
plot PBC2 = TargetsB(Time_Of_First_Bar_Of_Day, BarOpen, PC, PBC1);
PBC2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PBC2.SetLineWeight(1);
plot PBC3 = TargetsB(Time_Of_First_Bar_Of_Day, BarOpen, PC, PBC2);
PBC3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PBC3.SetLineWeight(1);
plot PBC4 = TargetsB(Time_Of_First_Bar_Of_Day, BarOpen, PC, PBC3);
PBC4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PBC4.SetLineWeight(1);
plot PBC5 = TargetsB(Time_Of_First_Bar_Of_Day, BarOpen, PC, PBC4);
PBC5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PBC5.SetLineWeight(1);
was looking over my old watches threads and I forgot about this ! I used to check this everydayESZ23 9/19/23 17:00
![]()
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
![]() |
experimental code: draw 2 rectangles, with start and stop dates/times, and price levels | Playground | 0 | |
K | Recent Changes on TOS Tools?: Trend Lines/Levels on Different Time Frames | Playground | 2 | |
C | Futures Trading Around Key SPX Options Levels | Playground | 0 |
Start a new thread and receive assistance from our community.
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.
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.