Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
I'm fluent in Thinkscript but am still learning ninjascript.
I would like an indicator that I've built in ToS to be converted to Ninjatrader.
I'll post the thinkscript below. It's an oscillator that gets it's data off of 5 different indicators.
The end goal would be an indicator that can be plotted onto the chart and can be built into strategy builder to test for trading.
It's a trend following indicator where you would go long when the 21 ema of the oscillator is going up for two consecutive bars. Then go short when the 21 ema of the oscillator is going down for two consecutive bars.
Labels aren't necessary in the conversion.
Thanks for your help.
Justin Bottum
Thinkscript code:
#Indicator Name Current_State
declare lower;
plot zeroline = 0;
def ema1 = ExpAverage(length = 3, data = close);
def ema2 = ExpAverage(length = 8, data = close);
def location = if if ema1 < ema2 then close > ema1 else close > ema2 then 1 else -1;
def bullbear = if bullish then 1 else if bearish then -1 else 0;
def wave = if IsBullishWave then 1 else if IsBearishWave then -1 else 0;
def JTmulti = if IsNaN(bullbear) then 0 else bullbear + if IsNaN(wave) then 0 else wave;
def momentum = TTM_Squeeze();
def zero = if momentum > 0 then 1 else -1;
def volexpanding = if BolKelDeltaMIDLPlot > BolKelDeltaMIDLPlot[1] then 1 else 0;
#def momorising = if momentum > momentum[1] then 1 else 0;
def direction = if momentum > momentum[1] then 1 + volexpanding else if momentum < momentum[1] then -1 - volexpanding else 0;
ema3p.AssignValueColor(if ema3p > ema3p[1] then Color.GREEN else if ema3p < ema3p[1] then Color.RED else Color.GRAY);
currentstate.AssignValueColor(if currentstate > currentstate[1] then Color.GREEN else if currentstate < currentstate[1] then Color.RED else Color.GRAY);
AssignPriceColor(if ema3p > ema3p[1] then Color.GREEN else if ema3p < ema3p[1] then Color.RED else Color.GRAY);
check out my code, WaveTrend.cs
I convert it from pine script, it calls other indicators, basically, you specify other indicators in the beginning then just refer to them later.
Also check out download section here and on ninja https://ninjatraderecosystem.com/user-app-share/ there should be some codes you can use.
Hi @JBottum, glad you saw that thread. I was going to suggest it.
As to NinjaScript, you'll need a little acquaintance with C#, and then just with the particular ways that NT allows you to call the NT functionality. The C# language is not a big deal to get used to, although you may need to learn about how it uses classes, which I don't think Thinkscript uses (I could be wrong about that; it's been a long time since I did anything in it.)
Your best bet may be going though the Help topics, as well as just opening up the code for particular indicators and reading through them. Source code is included for all the built-NT indicators. Eventually it should start to make sense for you. You can post questions in the forum, including in the free indicator thread, and there will be people who can help out.
I'm going to close this thread as a duplicate because we try to keep the forum fairly organized, and the better place for your indicator conversion question is in the thread that @cory directed you to, the free NT indicator thread.
Good luck in your learning, and I hope you find what you need.
Bob.
When one door closes, another opens.
-- Cervantes, Don Quixote