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 Apple (AAPL) from closing date of 01/14/22.
input Lookback = 10;
def LowMove = Lowest(Low, Lookback);
def HighMove = Highest(High, Lookback);
def SpanLow = if LowMove < LowMove[-Lookback] then LowMove else LowMove[-Lookback];
def PointLow = Low == SpanLow;
def lastPointLow = CompoundValue(1, if IsNaN(PointLow) then lastPointLow[1] else if PointLow then Low else lastPointLow[1], Low);
def SpanHigh = if HighMove > HighMove[-Lookback] then HighMove else HighMove[-Lookback];
def PointHigh = High == SpanHigh;
def lastPointHigh = CompoundValue(1, if IsNaN(PointHigh) then lastPointHigh[1] else if PointHigh then High else lastPointHigh[1], High);
plot Resistance = lastPointHigh;
plot Support = lastPointLow;
Resistance.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Resistance.SetDefaultColor(Color.GREEN);
Support.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Support.SetDefaultColor(Color.RED);
input Lookback = 10;
def LowMove = Lowest(Low, Lookback);
def HighMove = Highest(High, Lookback);
def SpanLow = if LowMove < LowMove[-Lookback] then LowMove else LowMove[-Lookback];
def PointLow = Low == SpanLow;
def lastPointLow = CompoundValue(1, if IsNaN(PointLow) then lastPointLow[1] else if PointLow then Low else lastPointLow[1], Low);
def SpanHigh = if HighMove > HighMove[-Lookback] then HighMove else HighMove[-Lookback];
def PointHigh = High == SpanHigh;
def lastPointHigh = CompoundValue(1, if IsNaN(PointHigh) then lastPointHigh[1] else if PointHigh then High else lastPointHigh[1], High);
plot Resistance = lastPointHigh;
plot Support = lastPointLow;
Resistance.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Resistance.SetDefaultColor(Color.GREEN);
Support.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Support.SetDefaultColor(Color.RED);
Last edited: