BULLFIZZ
Member
- Platform
-
- Thinkorswim
- Can someone please assist me in adding buy and sell signals / alerts to the script below......... its got White Entry and Yellow as exits
Code:
## START STUDY ## Anchored_VWAP_STOPS
## linus, 2014-03-10, v0.1 #hint: VWAP stops anchored off FractalTrader pivots.
input n = 20; #hint n: Lookback period for finding swing highs, lows.
input ticks = 2.0; #hint ticks: Offset VWAP lines by this number of ticks.
def bnOK = BarNumber() > n;
def isHigher = fold i = 1 to n + 1 with p = 1 while p do high > GetValue(high, -i);
def HH = if bnOK and isHigher and high == Highest(high, n) then high else Double.NaN;
def isLower = fold j = 1 to n + 1 with q = 1 while q do low < GetValue(low, -j);
def LL = if bnOK and isLower and low == Lowest(low, n) then low else Double.NaN;
def PivH = if HH > 0 then HH else Double.NaN;
def PivL = if LL > 0 then LL else Double.NaN;
rec dir = CompoundValue(1, if !IsNaN(PivL) then 1 else if !IsNaN(PivH) then -1 else dir[1], 0);
plot Up = dir crosses above 0;
Up.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
Up.SetLineWeight(3);
Up.SetDefaultColor(Color.WHITE);
plot Dn = dir crosses below 0;
Dn.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
Dn.SetLineWeight(3);
Dn.SetDefaultColor(Color.ORANGE);
def LocH = (high + (TickSize() * ticks)) * volume;
def LocL = (low - (TickSize() * ticks)) * volume;
rec PH;
rec VH;
rec PL;
rec VL;
if Dn {
PH = LocH;
VH = volume;
} else {
PH = CompoundValue(1, LocH + PH[1], Double.NaN);
VH = CompoundValue(1, volume + VH[1], Double.NaN);
}
if Up {
PL = LocL;
VL = volume;
} else {
PL = CompoundValue(1, LocL + PL[1], Double.NaN);
VL = CompoundValue(1, volume + VL[1], Double.NaN);
}
plot VwapH = if Dn then Double.NaN else PH / VH;
plot VwapL = if Up then Double.NaN else PL / VL;
VwapH.SetDefaultColor(Color.DARK_RED);
VwapL.SetDefaultColor(Color.DARK_GREEN);
## END STUDY #Note: /ES 5m chart of the Anchored_VWAP_STOPS study.