NinjaTrader's Fibonacci SuperTrend For ThinkOrSwim


Active member
2019 Donor
Convert Fibonacci SuperTrend from NinjaTrader?

Would someone please convert this from Ninja to Thinkorswim?

I appreciate it.
Last edited by a moderator:


Well-known member
@john3 Try this. I'm not sure how close i was able to get it. Let me know how far it is off. I don't have NinjaTrader to compare.

# Fibonacci SuperTrend
# converted from
# 20200615 - barbaros

input length = 14;
input retrace = 38.2;
input useHighLow = yes;
input showArrows = yes;
input colorBars = yes;
input audioAlerts = yes;

def h = if useHighLow then high else close;
def l = if useHighLow then low else close;
def minL = Lowest(l, length);
def maxH = Highest(h, length);

def hh = if h > maxH[1] then h else hh[1];
def ll = if l < minL[1] then l else ll[1];
def trend = if h > maxH[1] then 1 else if l < minL[1] then -1 else trend[1];
def isTrend = trend == 1;

def MyRange = hh-ll;
def Retracement = retrace/100;
def BuyPrice = ll + (Retracement * MyRange);
def SellPrice = hh - (Retracement * MyRange);

def UpTrend = if isTrend and !isTrend[1] then SellPrice else if isTrend and SellPrice > UpTrend[1] then SellPrice else Uptrend[1];
def DownTrend = if !isTrend && isTrend[1] then BuyPrice else if !isTrend and BuyPrice < DownTrend[1] then BuyPrice else DownTrend[1];

# Plots

plot TrendLine = if isTrend then UpTrend else DownTrend;
TrendLine.assignValueColor(if isTrend then Color.GREEN else Color.RED);

plot UpArrow = if showArrows and isTrend and !isTrend[1] then yes else no;

plot DownArrow = if showArrows and !isTrend && isTrend[1] then yes else no;

# Color Bars

AssignPriceColor(if colorBars and isTrend then Color.GREEN else if colorBars then Color.RED else Color.CURRENT);

# Alerts

Alert(isTrend and !isTrend[1], "Up Trend", Alert.BAR, Sound.Ding);
Alert(!isTrend && isTrend[1], "Down Trend", Alert.BAR, Sound.Ding);
Last edited:


Active member
2019 Donor
@barbaros Thank you very much, but it doesn't seem to match the Ninja's version. Maybe the issue is that changing the settings in the code doesn't seem to change anything. For example, I've changed "length" and "useHighLow," but it didn't seem to do anything.


Well-known member
@john3 I might have messed something up in the translation. I updated the previous post. May be try that version.
Last edited:
  • Like
Reactions: HEC

Similar threads