Can someone help me add another UP/ DOWN arrow on the attached script. I am looking to have another UP/DOWN arrow populate
if the next candle HIGH / LOW is Greater / Less than the previous populated arrow. See pic for an example. as you can see no 2nd arrow would populate for the GREEN side but a 2nd Arrow would populate for RED side being it made a lower low on next candle.
if the next candle HIGH / LOW is Greater / Less than the previous populated arrow. See pic for an example. as you can see no 2nd arrow would populate for the GREEN side but a 2nd Arrow would populate for RED side being it made a lower low on next candle.
Ruby:
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));
VWAP.SetLineWeight(3);
VWAP.AssignValueColor(if close>=VWAP then Color.Green else Color.Red);
#UpperBand.setDefaultColor(getColor(2));
#LowerBand.setDefaultColor(getColor(4));
#########################################################
def Current_Open = open;
def Current_Close = close;
def Current_High = high;
def Current_Low = Low;
def ASHI_CLOSE = (High+low+open+close)/4;
plot Cross_b = if AsHI_CLOSE > VWAP and AsHI_CLOSE[1] < VWAP then 1 else 0;
Cross_b.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
Cross_b.SetDefaultColor(Color.LIGHT_GREEN);
Cross_b.SetLineWeight(5);
plot Cross_s = if AsHI_CLOSE < VWAP and AsHI_CLOSE[1] > VWAP then 1 else 0;
Cross_s.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
Cross_s.SetDefaultColor(Color.LIGHT_RED);
Cross_s.SetLineWeight(5);