# Created by Ricky_Gaspard 7-16-2023
# Buying and Selling Indicator Arrows for Scalping
# Modified to Condition Arrows in relation to VWAP
input SHOW_Vwap_MovAvg_PLOTS = {default "NO", "YES"};
input ARROWS_SHOW_ALL = {default "NO", "YES"};#NO = ONLY SHOW ARROWS above/bwlow VWAP
plot vwap = reference VWAP();
plot sma5 = SimpleMovingAvg("length" = 5)."SMA";
plot ema5 = MovAvgExponential("length" = 5)."AvgExp";
plot ema10 = MovAvgExponential("length" = 10)."AvgExp";
vwap.SetHiding(!SHOW_Vwap_MovAvg_PLOTS);
sma5.SetHiding(!SHOW_Vwap_MovAvg_PLOTS);
ema5.SetHiding(!SHOW_Vwap_MovAvg_PLOTS);
ema10.SetHiding(!SHOW_Vwap_MovAvg_PLOTS);
####################################
# Position of VWAP Matters
# Buying Conditions - All MovingAverages must be above VWAP when Condition Occurs
def buycondition1 =
sma5 > vwap and
ema5 > vwap and
ema10 > vwap and
sma5 is greater than ema10 and
ema5 is greater than ema10 and
ema5 crosses above sma5;
def buycondition2 =
sma5 is greater than ema10 and
ema5 is greater than ema10 and
ema5 crosses above sma5;
#Selling Conditions - All MovingAverages must be below VWAP when Condition Occurs
def sellcondition1 =
ema5 < vwap and
ema10 < vwap and
ema5 crosses below ema10;
def sellcondition2 =
ema5 crosses below ema10;
#Determins Conditions of an UP Arrow
plot bullish = if buycondition1 then 1 else 0;
#Determies Conditions of a Down Arrow
plot bearish = if sellcondition1 then 1 else 0;
#Paints Up Arrow On Chart
bullish.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
#Sets Default UP Arrow Color
bullish.SetDefaultColor(Color.CYAN);
#Paints Down Arrow On Chart
bearish.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
#Sets Default Down Arrow Color
bearish.SetDefaultColor(Color.MAGENTA);
#Sets Thickness of Arrows
bullish.SetLineWeight(5);
bearish.SetLineWeight(5);
#########################
#Position of VWAP NOT considered when plotting Arrows
#Determines Conditions of an UP Arrow
plot bullish2 = if buycondition2 then 1 else 0;
bullish2.SetHiding(!ARROWS_SHOW_ALL);
#Determies Conditions of a Down Arrow
plot bearish2 = if sellcondition2 then 1 else 0;
bearish2.SetHiding(!ARROWS_SHOW_ALL);
#Paints Up Arrow On Chart
bullish2.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
#Sets Default UP Arrow Color
bullish2.SetDefaultColor(Color.WHITE);
#Paints Down Arrow On Chart
bearish2.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
#Sets Default Down Arrow Color
bearish2.SetDefaultColor(Color.YELLOW);
#Sets Thickness of Arrows
bullish2.SetLineWeight(2);
bearish2.SetLineWeight(2);
#