```
#hint: Charts a Moving Average's OHLC as candles, with customizable Length, and type
#Assembled by @adii8000
#Idea by @BlueRaven
#Thanks to @MerryDay and @RobertPayne
input L_Length = 20;
input Average_Type = AverageType.SIMPLE;
input Chart_Type = ChartType.CANDLE;
def MAO = MovingAverage(Average_Type,open,L_Length);
def MAC = MovingAverage(Average_Type,close,L_Length);
def MAH = MovingAverage(Average_Type,high,L_Length);
def MAL = MovingAverage(Average_Type,low,L_Length);
def UpO;
def UpC;
def UpH;
def UpL;
#Up Bars
if MAC > MAO then {
UpO = MAO;
UpC = MAC;
UpH = MAH;
UpL = MAL;
} else {
UpO = Double.NaN;
UpC = Double.NaN;
UpH = Double.NaN;
UpL = Double.NaN;
}
def DownO;
def DownC;
def DownH;
def DownL;
#Down Bars
if MAC < MAO then {
DownO = MAO;
DownC = MAC;
DownH = MAH;
DownL = MAL;
} else {
DownO = Double.NaN;
DownC = Double.NaN;
DownH = Double.NaN;
DownL = Double.NaN;
}
#Doji Bars
def DojiO;
def DojiC;
def DojiH;
def DojiL;
if MAC == MAO then {
DojiO = MAO;
DojiC = MAC;
DojiH = MAH;
DojiL = MAL;
} else {
DojiO = Double.NaN;
DojiC = Double.NaN;
DojiH = Double.NaN;
DojiL = Double.NaN;
}
#Green Bars
AddChart(UpH, UpL, UpO, UpC, Chart_Type, Color.UPTICK);
#Red Bars
AddChart(DownH, DownL, DownO, DownC, Chart_Type, Color.DOWNTICK);
#Gray Bars
AddChart(DojiH, DojiL, DojiO, DojiC, Chart_Type, Color.GRAY);
#Outlines: Don't seem to work, they color all candles fully black
#AddChart(UpH, UpL, UpO, UpC, Chart_Type, Color.BLACK);
#AddChart(DownH, DownL, DownO, DownC, Chart_Type, Color.BLACK);
#AddChart(DojiH, DojiL, DojiO, DojiC, Chart_Type, Color.BLACK);
#AddChart(MAH, MAL, MAO, MAC, Chart_Type, Color.BLACK);
```