Ema crossover Vwap


Category:
0
0

Hello

Can you help me with the chart study for thinkorswim that alert and addlabel both when ema9 crossover vwap.

looking for script that show BUY when Ema9 crossover Vwap and show Sell when Ema9 cross below vwap. Did try to use this script

 

input EMAPeriod9 = 09;

plot Ema9 = ExpAverage(price, EMAPeriod9);

Ema9.SetDefaultColor(Color.violet);

def Positive = if EMA9 >= vwap then 1 else 0;

 

 

Please help

 

Marked as spam
Posted by (Questions: 12, Answers: 5)
Asked on August 24, 2019 11:53 pm
1521 views
0
Private answer

Here you go. You need to use the full code from the VWAP study. Not just 'vwap'. Screenshot below shows the result.

input maType = AverageType.EXPONENTIAL;
input maPrice = close;
input maLength = 9;
input numDevDn = -2.0;
input numDevUp = 2.0;
input timeFrame = {default DAY, WEEK, MONTH};
def cap = getAggregationPeriod();
def errorInAggregation =
timeFrame == timeFrame.DAY and cap >= AggregationPeriod.WEEK or
timeFrame == timeFrame.WEEK and cap >= AggregationPeriod.MONTH;
assert(!errorInAggregation, "timeFrame should be not less than current chart aggregation period");
def yyyyMmDd = getYyyyMmDd();
def periodIndx;
switch (timeFrame) {
case DAY:
periodIndx = yyyyMmDd;
case WEEK:
periodIndx = Floor((daysFromDate(first(yyyyMmDd)) + getDayOfWeek(first(yyyyMmDd))) / 7);
case MONTH:
periodIndx = roundDown(yyyyMmDd / 100, 0);
}
def isPeriodRolled = compoundValue(1, periodIndx != periodIndx[1], yes);
def volumeSum;
def volumeVwapSum;
def volumeVwap2Sum;
if (isPeriodRolled) {
volumeSum = volume;
volumeVwapSum = volume * vwap;
volumeVwap2Sum = volume * Sqr(vwap);
} else {
volumeSum = compoundValue(1, volumeSum[1] + volume, volume);
volumeVwapSum = compoundValue(1, volumeVwapSum[1] + volume * vwap, volume * vwap);
volumeVwap2Sum = compoundValue(1, volumeVwap2Sum[1] + volume * Sqr(vwap), volume * Sqr(vwap));
}
def price = volumeVwapSum / volumeSum;
def deviation = Sqrt(Max(volumeVwap2Sum / volumeSum - Sqr(price), 0));
plot VWAP = price;
plot UpperBand = price + numDevUp * deviation;
plot LowerBand = price + numDevDn * deviation;
VWAP.setDefaultColor(getColor(0));
UpperBand.setDefaultColor(getColor(2));
LowerBand.setDefaultColor(getColor(4));
plot ma = MovingAverage(maType, maPrice, maLength);
ma.SetStyle(Curve.MEDIUM_DASH);
plot crossAbove = ma[1] < VWAP[1] and ma > VWAP;
crossAbove.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
crossAbove.SetLineWeight(3);
crossAbove.SetDefaultColor(Color.CYAN);
plot crossBelow = ma[1] > VWAP[1] and ma < VWAP;
crossBelow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
crossBelow.SetLineWeight(3);
crossBelow.SetDefaultColor(Color.MAGENTA);

Attachments:
Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on August 25, 2019 10:30 am
0
Hello, I am trying to "turn off" some of the plots. I'm wanting do save a Crosses Above scan, and a Crosses Below scan. But when I turn off (#) the plot script I get error messages. I'm not sure what I'm doing wrong. Can you post the Above and also Below scan script for me. Thanks
( at January 26, 2022 3:10 pm)
0
Turn off the plots you don't want through the Edit Studies view.
( at January 26, 2022 5:39 pm)