I'm writing a script to display price action signals. I've got most of it written and working, but I noticed that on some candles, both an up arrow and a down arrow will be printed on the same candle. The solution I want to use is to figure out what color the candle is and use the appropriate arrow. So, if it's a green candle, print a green arrow underneath, if it's a red candle print a red arrow above. I have it all working except for that little caveat. Any help would be appreciated.
-Noob.
Ruby:
# This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
# sonnyjitsu
input largeSpread = 0.60;
input irregularBody = 0.10;
input EMALength = 50;
input volumeMA = 12;
def lowerTail;
def upperTail;
if close > open {
upperTail = (high - close);
lowerTail = (open - low);
} else {
upperTail = (high - open);
lowerTail = (close - low);
}
def e1 = ExpAverage(close, EMALength);
def e2 = ExpAverage(e1, EMALength);
def dema = 2 * e1 - e2;
input showMovingAverage = no;
plot DoubleEMA = if showMovingAverage then dema else Double.NaN;
def candleBody = AbsValue(close - open);
def thePlot = close;
def cond1 = volume >= ExpAverage(volume, volumeMA);
def cond2 = (open < dema and (lowerTail > upperTail));
def cond3 = (open > dema and (upperTail > lowerTail));
def cond4 = candleBody > largeSpread and cond1;
plot priceActionIrregularUp = if open < dema and candleBody < irregularBody and cond1 and lowerTail < upperTail then close else Double.NaN;
priceActionIrregularUp.SetDefaultColor(Color.MAGENTA);
priceActionIrregularUp.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
plot priceActionIrregularDown = if open > dema and candleBody < irregularBody and cond1 and upperTail > lowerTail then close else Double.NaN;
priceActionIrregularDown.SetDefaultColor(Color.MAGENTA);
priceActionIrregularDown.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
plot priceActionArrowUp = if close > open and cond4 or cond1 and cond2 then close else Double.NaN;
priceActionArrowUp.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
priceActionArrowUp.SetDefaultColor(Color.GREEN);
plot priceActionArrowDown = if open > close and cond4 or cond1 and cond3 then close else Double.NaN;
priceActionArrowDown.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
priceActionArrowDown.SetDefaultColor(Color.RED);