Adding horizontal dots as a lower study to dynamic MA?

oferwo

New member
Hello, I currently have a simple 9 EMA average script which dynamically changes the color when price above average and when below. Simple. However, in addition to it I'd like to add horizontal dots as a lower study that change colors too (green / red or similar) Not sure how. Any help super appreciated! This is my current code:


Code:
input price = close;
input length = 9;
input displace = 0;
input showBreakoutSignals = no;

plot AvgExp = ExpAverage(price[-displace], length);
plot UpSignal = price crosses above AvgExp;
plot DownSignal = price crosses below AvgExp;

UpSignal.SetHiding(!showBreakoutSignals);
DownSignal.SetHiding(!showBreakoutSignals);

AvgExp.SetDefaultColor(GetColor(1));
UpSignal.SetDefaultColor(Color.UPTICK);
UpSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
DownSignal.SetDefaultColor(Color.DOWNTICK);
DownSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

avgExp.AssignValueColor(if avgExp > avgExp[1] then color.light_green else Color.MAGENTA);


Here is an image of the dots I mean (the indicators on this image are unrelated to mine):

KwN364e.png
 
Last edited by a moderator:

BenTen

Administrative
Staff
VIP
Here you go:

Code:
declare lower;

input price = close;
input length = 9;
input displace = 0;

def AvgExp = ExpAverage(price[-displace], length);

plot Value = 1;

Value.AssignValueColor(if avgExp > avgExp[1] then color.light_green else Color.MAGENTA);
Value.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
 

Similar threads

Top