To Apply to ThinkorSwim by TDAmeritrade
Choose 'New' in the Edit Studies Dialog Box
Name the Study Appropriately
Paste Code
Apply, Ok
Done!
Each day input the VAL, VAL, POC, and Pivot from ShadowTrader either from the Tools, MyTrade subtab in the ThinkorSwim platform, or directly from their site at ShadowTrader.net
*Hint: Set the opening time to '1' instead of '9:30' to have the study plot after hours...
dWbValueArea
#Inputs
input Pivot = 0.00;#Hint Pivot: Must be manually entered
daily, tinyurl.com/3lbmu4o
input VAH =
0.00;#Hint VAH: Must be manually entered daily, tinyurl.com/3lbmu4o
input POC =
0.00;#Hint POC: Must be manually entered daily, tinyurl.com/3lbmu4o
input VAL =
0.00;#Hint VAL: Must be manually entered daily, tinyurl.com/3lbmu4o
input Automate = yes;#Hint Automate: This will calc &
dispaly pivot values automatically with “Pivot” input. Value Area will always
display.
input ProximityPlot = no;#Hint ProximityPlot: Only plots
pivots when applicable. If “Automate” is “no”, this option doesnt matter. Value
Area will always display.
input PivotBubbles = yes;#Hint PivotBubbles: Shows bubbles
on pivot plot lines. If ProximityPlot= yes, bubbles are always off.
input Labels = { default “Proximity”, “Off”, “All”};#Hint
Labels: Labels at top of chart. Proximity=labels will display only when
applicable.
input ShowPivot = no;#Hint ShowPivot: Some people do not use
the pivot point and do not want it displayed.
input ShowLevel4 = no;#Hint ShowLevel4: Will display S4 and
R4 for volatile days.
input CloudStartTime = 0530;#Hint CloudStartTime: Move to an
earlier time to shift bubbles to the left if bubbles are interfering with chart
view.
input ShowCloud = yes;#Hint ShowCloud: Shows the value area
as a cloud.
input LabelEsChartOnly = yes;#Hint LabelEsChartOnly: Removes
Value Labels(“Above Value”etc.) from chart when another symbol is entered(ex.
GOOG).
#Value Area Functions
def VArea = if close >= VAL and close <= VAH then 1
else 0;
def VAreaabove = if close > VAH then 1 else 0;
def VAreabelow = if close < VAL then 1 else 0;
def EStest = if close > close (“/es”) – 15 and close <
close (“/es”) + 15 then 1 else 0;
def ESchartonly = if LabelEsChartOnly then EStest else 1;
def NotZero = if VAH > 0 and VAL > 0 then 1 else 0;
def PNotZero = if Pivot > 0 then 1 else 0;
#Previous Day Functions
def Day =
GetDayOfWeek(GetYYYYMMDD() );
def RegHrs = SecondsTillTime(1545) >= 0 and
SecondsFromTime(0930) >= 0;
rec PLow = CompoundValue(1, if Day == Day[1] and RegHrs
and low < PLow[1] then low else if SecondsFromTime(0930) <= 0 and RegHrs
then low else PLow[1], low);
rec PHigh = CompoundValue(1, if Day == Day[1] and RegHrs and
high > PHigh[1] then high else if SecondsFromTime(0930) <= 0 and RegHrs
then high else PHigh[1], high);
rec PrevLow = if Day
!= Day[1] then PLow[1] else PrevLow[1];
rec PrevHigh = if Day != Day[1] then PHigh[1] else
PrevHigh[1];
#Time Functions
def AfterHours = no;
def MarketCloseTime =
1615;
def secondsFromOpen =
SecondsFromTime(CloudStartTime);
def secondsTillClose = SecondsTillTime(MarketCloseTime);
def OpenTest = if secondsFromOpen >= 0 and
secondsTillClose > 0 then yes else no;
def MarketOpen = if AfterHours or OpenTest then 1 else 0;
def closeByPeriod = close(period = “DAY”)[-1];
def newDay = if !IsNaN(closeByPeriod) then 0 else 1;
def today = if
GetDay() == GetLastDay() and SecondsFromTime(CloudStartTime) >= 0 then 1
else 0;
#Pivot Functions
def RI = (2 * Pivot)
– PrevLow;
def SI = (2 * Pivot)
– PrevHigh;
def RII = Pivot + (RI
– SI);
def SII = Pivot – (RI
– SI);
def RIII = PrevHigh + 2 * (Pivot – PrevLow);
def SIII = PrevLow – 2 * (PrevHigh – Pivot);
def RIV = PrevHigh +
3 * (Pivot – PrevLow);
def SIV = PrevLow – 3
* (PrevHigh – Pivot);
#Plots
plot VH;
plot PC;
plot VL;
plot R1;
plot S1;
plot R2;
plot S2;
plot R3;
plot S3;
plot R4;
plot S4;
plot PP;
plot R_1;
plot S_1;
plot R_2;
plot S_2;
plot R_3;
plot S_3;
plot R_4;
plot S_4;
plot P_P;
if !IsNaN(close(period = “DAY”)[-1])
then {
VH = Double.NaN;
PC = Double.NaN;
VL = Double.NaN;
R4 = Double.NaN;
R3 = Double.NaN;
R2 = Double.NaN;
R1 = Double.NaN;
PP = Double.NaN;
S1 = Double.NaN;
S2 = Double.NaN;
S3 = Double.NaN;
S4 = Double.NaN;
R_4 = Double.NaN;
R_3 = Double.NaN;
R_2 = Double.NaN;
R_1 = Double.NaN;
P_P = Double.NaN;
S_1 = Double.NaN;
S_2 = Double.NaN;
S_3 = Double.NaN;
S_4 = Double.NaN;
} else {
VH = if MarketOpen and newDay and today and VAH
> 0 then VAH else Double.NaN;
PC =
if MarketOpen and newDay and today and POC > 0 then POC else Double.NaN;
VL = if MarketOpen and newDay and today and VAL
> 0 then VAL else Double.NaN;
R4 = if MarketOpen and newDay and today and
Automate and !ProximityPlot and
ShowLevel4 and RIV > 0 then RIV else Double.NaN;
R3 = if MarketOpen and newDay and today and
Automate and !ProximityPlot and RIII
> 0 then RIII else Double.NaN;
R2 = if MarketOpen and newDay and today and
Automate and !ProximityPlot and RII >
0 then RII else Double.NaN;
R1 = if MarketOpen and newDay and today and
Automate and !ProximityPlot and RI >
0 then RI else Double.NaN;
PP = if MarketOpen and newDay and today and
ShowPivot and !ProximityPlot and Pivot > 0 then Pivot else Double.NaN;
S1 = if MarketOpen and newDay and today and
Automate and !ProximityPlot and SI >
0 then SI else Double.NaN;
S2 = if MarketOpen and newDay and today and
Automate and !ProximityPlot and SII >
0 then SII else Double.NaN;
S3 = if MarketOpen and newDay and today and
Automate and !ProximityPlot and SIII
> 0 then SIII else Double.NaN;
S4 = if MarketOpen and newDay and today and
Automate and !ProximityPlot and
ShowLevel4 and SIV > 0 then SIV else Double.NaN;
R_4 = if
MarketOpen and newDay and today and Automate
and ProximityPlot and close >
(RII + ((RIII - RII) / 2)) then RIV else Double.NaN;
R_3 = if
MarketOpen and newDay and today and Automate
and ProximityPlot and close >
(RI + ((RII - RI) / 2)) then RIII else Double.NaN;
R_2 = if
MarketOpen and newDay and today and Automate
and ProximityPlot and close >
VH then RII else Double.NaN;
R_1 = if
MarketOpen and newDay and today and Automate
and ProximityPlot and close >
VL then RI else Double.NaN;
P_P = if
MarketOpen and newDay and today and Automate
and ShowPivot and ProximityPlot and close > SI and close < RI then
Pivot else Double.NaN;
S_1 = if
MarketOpen and newDay and today and Automate
and ProximityPlot and close <
VH then SI else Double.NaN;
S_2 = if
MarketOpen and newDay and today and Automate
and ProximityPlot and close <
VL then SII else Double.NaN;
S_3 = if
MarketOpen and newDay and today and Automate
and ProximityPlot and close <
(SI - ((SI - SII) / 2)) then SIII else Double.NaN;
S_4 = if
MarketOpen and newDay and today and Automate
and ProximityPlot and close <
(SII - ((SII - SIII) / 2)) then SIV else Double.NaN;
}
VH.SetPaintingStrategy(PaintingStrategy.LINE);
VH.SetDefaultColor(Color.RED);
VH.SetLineWeight(1);
PC.SetPaintingStrategy(PaintingStrategy.LINE);
PC.SetDefaultColor(Color.YELLOW);
PC.SetLineWeight(1);
PC.SetStyle(Curve.LONG_DASH);
VL.SetPaintingStrategy(PaintingStrategy.LINE);
VL.SetDefaultColor(Color.GREEN);
VL.SetLineWeight(1);
R4.SetPaintingStrategy(PaintingStrategy.LINE);
R4.SetDefaultColor(Color.WHITE);
R4.SetLineWeight(1);
R3.SetPaintingStrategy(PaintingStrategy.LINE);
R3.SetDefaultColor(Color.WHITE);
R3.SetLineWeight(1);
R2.SetPaintingStrategy(PaintingStrategy.LINE);
R2.SetDefaultColor(Color.WHITE);
R2.SetLineWeight(1);
R1.SetPaintingStrategy(PaintingStrategy.LINE);
R1.SetDefaultColor(Color.WHITE);
R1.SetLineWeight(1);
PP.SetPaintingStrategy(PaintingStrategy.LINE);
PP.SetDefaultColor(Color.WHITE);
PP.SetLineWeight(1);
S4.SetPaintingStrategy(PaintingStrategy.LINE);
S4.SetDefaultColor(Color.WHITE);
S4.SetLineWeight(1);
S3.SetPaintingStrategy(PaintingStrategy.LINE);
S3.SetDefaultColor(Color.WHITE);
S3.SetLineWeight(1);
S2.SetPaintingStrategy(PaintingStrategy.LINE);
S2.SetDefaultColor(Color.WHITE);
S2.SetLineWeight(1);
S1.SetPaintingStrategy(PaintingStrategy.LINE);
S1.SetDefaultColor(Color.WHITE);
S1.SetLineWeight(1);
R_4.SetPaintingStrategy(PaintingStrategy.LINE);
R_4.SetDefaultColor(Color.WHITE);
R_4.SetLineWeight(1);
R_4.HideBubble();
R_3.SetPaintingStrategy(PaintingStrategy.LINE);
R_3.SetDefaultColor(Color.WHITE);
R_3.SetLineWeight(1);
R_3.HideBubble();
R_2.SetPaintingStrategy(PaintingStrategy.LINE);
R_2.SetDefaultColor(Color.WHITE);
R_2.SetLineWeight(1);
R_2.HideBubble();
R_1.SetPaintingStrategy(PaintingStrategy.LINE);
R_1.SetDefaultColor(Color.WHITE);
R_1.SetLineWeight(1);
R_1.HideBubble();
P_P.SetPaintingStrategy(PaintingStrategy.LINE);
P_P.SetDefaultColor(Color.WHITE);
P_P.SetLineWeight(1);
P_P.HideBubble();
S_4.SetPaintingStrategy(PaintingStrategy.LINE);
S_4.SetDefaultColor(Color.WHITE);
S_4.SetLineWeight(1);
S_4.HideBubble();
S_3.SetPaintingStrategy(PaintingStrategy.LINE);
S_3.SetDefaultColor(Color.WHITE);
S_3.SetLineWeight(1);
S_3.HideBubble();
S_2.SetPaintingStrategy(PaintingStrategy.LINE);
S_2.SetDefaultColor(Color.WHITE);
S_2.SetLineWeight(1);
S_2.HideBubble();
S_1.SetPaintingStrategy(PaintingStrategy.LINE);
S_1.SetDefaultColor(Color.WHITE);
S_1.SetLineWeight(1);
S_1.HideBubble();
#Value Area Cloud
plot cloudhigh = if MarketOpen and newDay and today and
ShowCloud then VAH else Double.NaN;
plot cloudlow = if
MarketOpen and newDay and today and ShowCloud then VAL else Double.NaN;
AddCloud (cloudhigh, cloudlow, Color.GRAY, Color.GRAY);
#Labels
AddLabel(MarketOpen and newDay and today and ESchartonly and
VArea and NotZero, “Inside Value Area”, Color.WHITE);
AddLabel(MarketOpen and newDay and today and ESchartonly and
VAreaabove and NotZero, “Above Value Area”, Color.GREEN);
AddLabel(MarketOpen and newDay and today and ESchartonly and
VAreabelow and NotZero, “Below Value Area”, Color.RED);
def ChartLabels;
switch (Labels) {
case “Proximity”:
ChartLabels = 1;
case “Off”:
ChartLabels = 0;
case “All”:
ChartLabels = 2;
}
AddLabel(ChartLabels == 1 and MarketOpen and newDay and
today and ESchartonly and close > VL and close < RII, Concat(“VH=”, VH),
Color.RED);
AddLabel(ChartLabels == 1 and MarketOpen and newDay and
today and ESchartonly and close > SI and close < RI, Concat(“POC=”, PC),
Color.YELLOW);
AddLabel(ChartLabels == 1 and MarketOpen and newDay and
today and ESchartonly and close < VH and close > SII, Concat(“VL=”, VL),
Color.GREEN);
AddLabel(ChartLabels == 1 and MarketOpen and newDay and
today and ESchartonly and close > VL, Concat(“R1=”, RI), Color.RED);
AddLabel(ChartLabels == 1 and MarketOpen and newDay and
today and ESchartonly and close > VH, Concat(“R2=”, RII), Color.RED);
AddLabel(ChartLabels == 1 and MarketOpen and newDay and
today and ESchartonly and close > (RI + ((RII - RI) / 2)), Concat(“R3=”,
RIII), Color.RED);
AddLabel(ChartLabels == 1 and MarketOpen and newDay and
today and ESchartonly and close > (RII + ((RIII - RII) / 2)), Concat(“R4=”,
RIV), Color.RED);
AddLabel(ChartLabels == 1 and MarketOpen and newDay and
today and ESchartonly and close > SI and close < RI and ShowPivot,
Concat(“PP=”, PP), Color.WHITE);
AddLabel(ChartLabels == 1 and MarketOpen and newDay and
today and ESchartonly and close < VH, Concat(“S1=”, SI), Color.GREEN);
AddLabel(ChartLabels == 1 and MarketOpen and newDay and
today and ESchartonly and close < VL, Concat(“S2=”, SII), Color.GREEN);
AddLabel(ChartLabels == 1 and MarketOpen and newDay and
today and ESchartonly and close < (SI - ((SI - SII) / 2)), Concat(“S3=”,
SIII), Color.GREEN);
AddLabel(ChartLabels == 1 and MarketOpen and newDay and
today and ESchartonly and close < (SII - ((SII - SIII) / 2)), Concat(“S4=”,
SIV), Color.GREEN);
AddLabel(ChartLabels == 2 and MarketOpen and newDay and
today and ESchartonly and NotZero, Concat(“VH=”, VH), Color.RED);
AddLabel(ChartLabels == 2 and MarketOpen and newDay and
today and ESchartonly and NotZero, Concat(“POC=”, PC), Color.YELLOW);
AddLabel(ChartLabels == 2 and MarketOpen and newDay and
today and ESchartonly and NotZero, Concat(“VL=”, VL), Color.GREEN);
AddLabel(ChartLabels == 2 and MarketOpen and newDay and
today and ESchartonly and PNotZero, Concat(“R1=”, RI), Color.RED);
AddLabel(ChartLabels == 2 and MarketOpen and newDay and
today and ESchartonly and PNotZero, Concat(“R2=”, RII), Color.RED);
AddLabel(ChartLabels == 2 and MarketOpen and newDay and
today and ESchartonly and PNotZero, Concat(“R3=”, RIII), Color.RED);
AddLabel(ChartLabels == 2 and MarketOpen and newDay and
today and ESchartonly and PNotZero and ShowLevel4, Concat(“R4=”, RIV), Color.RED);
AddLabel(ChartLabels == 2 and MarketOpen and newDay and
today and ESchartonly and PNotZero and ShowPivot, Concat(“PP=”, PP),
Color.WHITE);
AddLabel(ChartLabels == 2 and MarketOpen and newDay and
today and ESchartonly and PNotZero, Concat(“S1=”, SI), Color.GREEN);
AddLabel(ChartLabels == 2 and MarketOpen and newDay and
today and ESchartonly and PNotZero, Concat(“S2=”, SII), Color.GREEN);
AddLabel(ChartLabels == 2 and MarketOpen and newDay and
today and ESchartonly and PNotZero, Concat(“S3=”, SIII), Color.GREEN);
AddLabel(ChartLabels == 2 and MarketOpen and newDay and
today and ESchartonly and PNotZero and ShowLevel4, Concat(“S4=”, SIV),
Color.GREEN);
AddLabel(!MarketOpen, ”NoPlotAfterHours”, Color.WHITE);
#Bubbles
AddChartBubble (!IsNaN(S1) and IsNaN(S1[1]) and
PivotBubbles, S1, “S1”, Color.WHITE, no);
AddChartBubble (!IsNaN(S2) and IsNaN(S2[1]) and
PivotBubbles, S2, “S2”, Color.WHITE, no);
AddChartBubble (!IsNaN(S3) and IsNaN(S3[1]) and
PivotBubbles, S3, “S3”, Color.WHITE, no);
AddChartBubble (!IsNaN(S4) and IsNaN(S4[1]) and PivotBubbles
and ShowLevel4, S4, “S4”, Color.WHITE, no);
AddChartBubble (!IsNaN(PP) and IsNaN(PP[1]) and ShowPivot
and PivotBubbles, PP, “PP”, Color.WHITE, no);
AddChartBubble (!IsNaN(R1) and IsNaN(R2[1]) and
PivotBubbles, R1, “R1”, Color.WHITE, no);
AddChartBubble (!IsNaN(R2) and IsNaN(R2[1]) and
PivotBubbles, R2, “R2”, Color.WHITE, no);
AddChartBubble (!IsNaN(R3) and IsNaN(R3[1]) and
PivotBubbles, R3, “R3”, Color.WHITE, no);
AddChartBubble (!IsNaN(R4) and IsNaN(R4[1]) and PivotBubbles
and ShowLevel4, R4, “R4”, Color.WHITE, no);
#Opening Range Breakout Functions
input ShowORB = No;#Hint ShowORB: Displays 2 small, dashed
lines at the top/bottom of the opening range.
input OrbTime = 30;#Hint OrbTime: Defines the time range for
the ORB.
def Market_Open_Time
= 945;
def Market_Close_Time = 1600;
def Day1 = GetDay();
def pastOpen =
If((SecondsTillTime(Market_Open_Time) > 0), 0, 1);
def pastClose = If((SecondsTillTime(Market_Close_Time) >
0), 0, 1);
def IsMarketOpen = If(pastOpen and !pastClose, 1, 0);
def firstBar = If (Day1[1] != Day1, Day1 – 1, 0);
def secondsUntilOpen = SecondsTillTime(Market_Open_Time);
def regularHours = SecondsTillTime(Market_Close_Time);
def secondsFromOpen1 = SecondsFromTime(Market_Open_Time);
def pastOpeningRange = If(secondsFromOpen1 >= ((OrbTime -
15) * 60), 1, 0);
rec displayedHigh = If(high > displayedHigh[1] and
IsMarketOpen and ShowORB, high, If(IsMarketOpen and !firstBar,
displayedHigh[1], high));
rec displayedLow =
If(low < displayedLow[1] and IsMarketOpen and ShowORB, low, If(IsMarketOpen
and !firstBar, displayedLow[1], low));
rec ORHigh = If(pastOpeningRange, ORHigh[1], displayedHigh);
rec ORLow =
If(pastOpeningRange, ORLow[1], displayedLow);
plot ORBHigh = If(MarketOpen and newDay and today and
pastOpeningRange and IsMarketOpen and ShowORB, ORHigh, Double.NaN);
plot ORBLow =
If(MarketOpen and newDay and today and pastOpeningRange and IsMarketOpen and
ShowORB, ORLow , Double.NaN);
ORBHigh.SetDefaultColor(Color.GRAY);
ORBHigh.SetLineWeight(1);
ORBHigh.SetStyle(Curve.SHORT_DASH);
ORBHigh.HideBubble();
ORBLow.SetDefaultColor(Color.GRAY);
ORBLow.SetLineWeight(1);
ORBLow.SetStyle(Curve.SHORT_DASH);
ORBLow.HideBubble();
No comments:
Post a Comment