- Platform
-
- Thinkorswim
- TradingView
This was converted to TradingView from Thinkscript.
Original code in Thinkscript:
Converted to Pinescript:

Original code in Thinkscript:
Code:
# MTF Moving Average Slope Histogram
# DaysOff
declare lower;
input price = close;
input length = 10;
input agperiod = { "1 min", "2 min", "5 min", default "10 min", "15 min", "30 min", "60 min", "4 hours"};
def avg = ExpAverage(close(period = agperiod), length);
plot height = avg - avg[length];
height.setPaintingStrategy(PaintingStrategy.HISTOGRAM);
height.DefineColor("height >= 0" , Color.GREEN);
height.DefineColor("height < 0", Color.RED);
height.assignValueColor(if height >= 0 then height.color("height >= 0") else height.color("height < 0"));
Converted to Pinescript:
Code:
// MTF Moving Average Slope Histogram
// Converted from
// barbaros - initial version
//@version=5
indicator("MTF Moving Average Slope Histogram")
price = input.source(close, "Price")
length = input.int(10, "Length")
agprerid = input.timeframe("10", "Aggregation Period")
avg = ta.ema(price, length)
price_mtf = request.security(syminfo.tickerid, agprerid, avg)
height = price_mtf - price_mtf[length]
plot(height, "Height", height >= 0 ? color.green : color.red, 2, plot.style_columns)
Last edited: