Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
I am fairly New here How would I go about converting this into a algo

*Hello, I Recently Found this think or swim indicator ( and it serves me well) its a swing high and swing low indicator. I was wondering on how to convert this into an algorithm. It seems to complex for my own understanding. Any information helps (like steps or useful advice).*

Declare once_per_bar;
Def AggTime = if getAggregationPeriod() == aggregationPeriod.MIN or getAggregationPeriod() == aggregationPeriod.three_MIN or getAggregationPeriod() == aggregationPeriod.Five_MIN or getAggregationPeriod() == aggregationPeriod.Fifteen_MIN or getAggregationPeriod() == aggregationPeriod.Twenty_MIN or getAggregationPeriod() == aggregationPeriod.THIRTY_MIN or getAggregationPeriod() == aggregationPeriod.HOUR or getAggregationPeriod() == aggregationPeriod.DAY or getAggregationPeriod() == aggregationPeriod.WEEK or getAggregationPeriod() == aggregationPeriod.MONTH then 1 else 0;

Def BarCount = 2; #Hint BarCount: Sets the number of bars to check in forceIndex swings;
def PivotH = if High >= Highest(High[1], BarCount) and High > Highest(High[-BarCount], BarCount) then 1 else 0;
def HVal = if PivotH and aggtime then High else Double.NaN;
def PivotL = if Low <= Lowest(Low[1], BarCount) and Low < Lowest(Low[-BarCount], BarCount) then 1 else 0;
def LVal = if PivotL and aggtime then Low else Double.NaN;

plot SwingHigh = HVal;
SwingHigh.SetStyle(Curve.Points);
SwingHigh.setLineWeight(3);
SwingHigh.setdefaultColor(Color.CYAN);
plot SwingLow = LVal;
SwingLow.SetStyle(Curve.Points);
SwingLow.setLineWeight(3);
SwingLow.setdefaultColor(Color.CYAN)