Convert Thinkscript Trendline to AFL

#1
Using this on the Daily chart in ThinkorSwim. Would like to convert below Thinkscript to Amibroker (AFL) to match exactly as shown on the attached chart of Alcoa (AA) from closing date of 10/18/24. I've searched on https://toslc.thinkorswim.com/center/reference/thinkScript/Functions/Statistical/Inertia and https://www.amibroker.com/guide/afl/linearreg.html and tried AI Chat but can't seem to figure this out. Thank you in advance for your help.

input TrendLineLength1 = 180;

def Inertia = InertiaAll(close, TrendLineLength1);

def TL_Bull = Inertia - (HighestAll(AbsValue(Inertia - close)) * .80);
def TL_Bear = Inertia + (HighestAll(AbsValue(Inertia - close)) * .80);
def slope1a = TL_Bull > TL_Bull[1];
def slope1b = TL_Bear > TL_Bear[1];

plot TrendLine1a = if slope1a > 0 then TL_Bull else TL_Bear;
TrendLine1a.SetLineWeight(5);
TrendLine1a.SetDefaultColor(Color.WHITE);

plot TrendLine1b = if slope1b > 0 then TL_Bear else TL_Bull;
TrendLine1b.SetLineWeight(5);
TrendLine1b.SetDefaultColor(Color.WHITE);

Convert ThinkScript to AFL.png
Convert ThinkScript to AFL.png
 

Similar threads