petergluis
Active member
I convert Price Average Zones in Pine Script to Thinkscript.
https://www.tradingview.com/script/7CQCUk3t-Price-Average-Zones/
https://www.tradingview.com/script/7CQCUk3t-Price-Average-Zones/
Ruby:
declare upper;
input length = 50;
input length80 = 80;
input avgLength = 10;
def hma1 = HullMovingAvg(low, length);
def hma2 = HullMovingAvg(high, length);
def h50 = Highest(high, length);
def l50 = Lowest(low, length);
def h80 = Highest(high, length80);
def l80 = Lowest(low, length80);
def highesta = (h50 + h80) / 2;
def lowesta = (l50 + l80) / 2;
plot Shorts1 = hma1;
Shorts1.SetDefaultColor(Color.RED);
Shorts1.SetLineWeight(2);
Shorts1.SetPaintingStrategy(PaintingStrategy.LINE);
plot Shorts2 = lowesta;
Shorts2.SetDefaultColor(Color.RED);
Shorts2.SetLineWeight(2);
Shorts2.SetPaintingStrategy(PaintingStrategy.LINE);
AddCloud(Shorts1, Shorts2, COLOR.DOWNTICK);
plot Longs2 = hma2;
Longs2.SetDefaultColor(Color.GREEN);
Longs2.SetLineWeight(2);
Longs2.SetPaintingStrategy(PaintingStrategy.LINE);
plot Longs1 = highesta;
Longs1.SetDefaultColor(Color.GREEN);
Longs1.SetLineWeight(2);
Longs1.SetPaintingStrategy(PaintingStrategy.LINE);
AddCloud(Longs1, Longs2, COLOR.UPTICK);
def average = (highesta + lowesta) / 2;
def avrg = SimpleMovingAvg(average, avgLength);
plot Avrg1 = avrg;
Avrg1.SetDefaultColor(Color.YELLOW);
Avrg1.SetLineWeight(2);
Avrg1.HideBubble();