NinjaTrader's Fibonacci SuperTrend For ThinkOrSwim

john3

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:
@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.

Python:
# Fibonacci SuperTrend
# converted from www.FreeIndicators.com
# 
# 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;
UpArrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);

plot DownArrow = if showArrows and !isTrend && isTrend[1] then yes else no;
DownArrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

# 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:
@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.
 
@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

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
278 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top