thiagofnsouza
New member
Hi guys,
i'm trying to color my candles as my HiLo Activator. But, i don't know why only red colors are being ploted and only the first bullish candle are painted. Can you guys help me about it? here's my code:
#Begin Code
input price = close;
input HiLolength = 9;
input length = 21; #apenas para cálculo
input length2 = 72;
input displace = 0;
input Averagetype = AverageType.EXPONENTIAL;
input PaintBars = yes;
def maHigh = Average(high, HiLolength);
def maLow = Average(low, HiLolength);
def state = {default init, short, long};
if (close > maHigh) {
state = state.long;
} else if (close < maLow) {
state = state.short;
} else {
state = state[1];
}
plot BuyStop = if state == state.short or state != state[1] then maHigh else Double.NaN;
plot SellStop = if state == state.long or state != state[1] then maLow else Double.NaN;
BuyStop.SetDefaultColor(GetColor(0));
SellStop.SetDefaultColor(GetColor(1));
def SMA = MovingAverage(AverageType, price[-displace], length);
AssignPriceColor(if PaintBars and price <= BuyStop
then Color.RED
else if PaintBars and price >= SellStop
then Color.GREEN
else Color.CURRENT);
plot AVG = MovingAverage(AverageType, price[-displace], length2);
AVG.AssignValueColor(Color.WHITE);
AVG.SetLineWeight(2);
AVG.SetPaintingStrategy(PaintingStrategy.DASHES);
#End Code
i'm trying to color my candles as my HiLo Activator. But, i don't know why only red colors are being ploted and only the first bullish candle are painted. Can you guys help me about it? here's my code:
#Begin Code
input price = close;
input HiLolength = 9;
input length = 21; #apenas para cálculo
input length2 = 72;
input displace = 0;
input Averagetype = AverageType.EXPONENTIAL;
input PaintBars = yes;
def maHigh = Average(high, HiLolength);
def maLow = Average(low, HiLolength);
def state = {default init, short, long};
if (close > maHigh) {
state = state.long;
} else if (close < maLow) {
state = state.short;
} else {
state = state[1];
}
plot BuyStop = if state == state.short or state != state[1] then maHigh else Double.NaN;
plot SellStop = if state == state.long or state != state[1] then maLow else Double.NaN;
BuyStop.SetDefaultColor(GetColor(0));
SellStop.SetDefaultColor(GetColor(1));
def SMA = MovingAverage(AverageType, price[-displace], length);
AssignPriceColor(if PaintBars and price <= BuyStop
then Color.RED
else if PaintBars and price >= SellStop
then Color.GREEN
else Color.CURRENT);
plot AVG = MovingAverage(AverageType, price[-displace], length2);
AVG.AssignValueColor(Color.WHITE);
AVG.SetLineWeight(2);
AVG.SetPaintingStrategy(PaintingStrategy.DASHES);
#End Code