NexusFi: Find Your Edge


Home Menu

 





Can anyone convert a code from TOS


Discussion in ThinkOrSwim

Updated
      Top Posters
    1. looks_one j8fire with 3 posts (0 thanks)
    2. looks_two Fat Tails with 2 posts (2 thanks)
    3. looks_3 futurestrader1 with 1 posts (0 thanks)
    4. looks_4 Big Mike with 1 posts (1 thanks)
    1. trending_up 5,980 views
    2. thumb_up 3 thanks given
    3. group 4 followers
    1. forum 8 posts
    2. attach_file 2 attachments




 
Search this Thread
  #1 (permalink)
j8fire
texas
 
Posts: 3 since Dec 2009
Thanks Given: 1
Thanks Received: 0

Hi I have a script on TOS that i would like to convert to ninjatrader any help would be great. thanks



#
# (for use with Trading Strategy "DX X-ing 30"
#
declare lower;
input length = 14;
def hiDiff = high - high[1];
def loDiff = low[1] - low;
def plusDM = if hiDiff > loDiff and hiDiff > 0 then hiDiff else 0;
def minusDM = if loDiff > hiDiff and loDiff > 0 then loDiff else 0;
def ATR = WildersAverage(TrueRange(high, close, low), length);
def "DI+" = 100 * WildersAverage(plusDM, length) / ATR;
def "DI-" = 100 * WildersAverage(minusDM, length) / ATR;
def DX = if ("DI+" + "DI-" > 0) then 100 * AbsValue("DI+" - "DI-") / ("DI+" + "DI-") else 0;
plot "DX" = DX;
plot "30-Line" = 30;
"DX".SetDefaultColor(COLOR.White);
"30-Line".SetDefaultColor(COLOR.Red);


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Trump Truth Social Fires Hormuz From 10% to 59% -- Arsen …
Prediction Markets & Event Contracts
Oil Surges ~18% in One Week as Iran Conflict Disrupts Gl …
Commodities
Coinbase Launches Regulated Crypto Futures Across 26 Eur …
Cryptocurrency
Hormuz Normalization Collapses to 19.5% -- Iran Regime F …
Prediction Markets & Event Contracts
SEC Chairman Calls for New Golden Age of SEC-CFTC Regula …
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
23 thanks
2026 Jlab journal
10 thanks
Trying to learn Volume and price action correlation
8 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Lady Vols Primer: Trading Volatility Journal
6 thanks
  #3 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader
Broker: Interactive Brokers
Trading: Futures & Stocks
Posts: 9,887 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,114


Just try the DMI indicator of NinjaTrader. You may want to add one line to the code to display the threshold line.

 
Code
                            
Add(new Line(Color.Red30"30-Line")); 


Reply With Quote
  #4 (permalink)
j8fire
texas
 
Posts: 3 since Dec 2009
Thanks Given: 1
Thanks Received: 0

what i want is a positive value always between 0 and 100 and gives me a arrow on the candle when it crosses 30 it is close but not quite there


Reply With Quote
  #5 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader
Broker: Interactive Brokers
Trading: Futures & Stocks
Posts: 9,887 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,114

Your indicator looks like a simple ADX. If you add a line at 30 and draw a diamond, when ADX exceeds 30 you would be done.


j8fire View Post
what i want is a positive value always between 0 and 100 and gives me a arrow on the candle when it crosses 30 it is close but not quite there


Attached Files
Elite Membership required to download: ADX2.zip
Reply With Quote
Thanked by:
  #6 (permalink)
j8fire
texas
 
Posts: 3 since Dec 2009
Thanks Given: 1
Thanks Received: 0

THANKS,

I dont have any coding skill I did look at the code thinking it would be a easy just to add the equation but got confuse with all the info i saw did not want to jack it up.

so many thanks.


Reply With Quote
  #7 (permalink)
 
futurestrader1's Avatar
 futurestrader1 
New York City, USA
 
Experience: Advanced
Platform: NinjaTrader
Trading: ES, CL, 6E
Posts: 149 since Jun 2010
Thanks Given: 81
Thanks Received: 42

Hi guys, I have a nice triple keltner channel that is for TOS i'd like to get it on Ninjatrader and also MT4
can anyone help?

 
Code
declare weak_volume_dependency;
input displace = 0;
input displace2 = 0;
input displace3 = 0;
input factor = 1.75;
input factor2 = 2.5;
input factor3 = 4;
input length = 45;
input price = close;
def shift = factor * AvgTrueRange(high, close, low, length);
def shift2 = factor2 * AvgTrueRange(high, close, low, length);
def shift3 = factor3 * AvgTrueRange(high, close, low, length);
def average = ExpAverage(price, length);
plot Avg = average[-displace];
Avg.SetDefaultColor(GetColor(7));
plot Upper_Band = average[-displace] + shift[-displace];
Upper_Band.SetDefaultColor(GetColor(7));
plot Lower_Band = average[-displace] - shift[-displace];
Lower_Band.SetDefaultColor(GetColor(7));
plot Upper_Band2 = average[-displace] + shift2[-displace];
Upper_Band2.SetDefaultColor(GetColor(7));
plot Lower_Band2 = average[-displace] - shift2[-displace];
Lower_Band2.SetDefaultColor(GetColor(7));
plot Upper_Band3 = average[-displace] + shift3[-displace];
Upper_Band3.SetDefaultColor(GetColor(7));
plot Lower_Band3 = average[-displace] - shift3[-displace];
Lower_Band3.SetDefaultColor(GetColor(7));


Reply With Quote
  #8 (permalink)
 PedroMAN 
Manchester, England
 
Experience: Beginner
Platform: NinjaTrader, Multicharts
Broker: Mirus/Zenfire
Trading: NQ,ES
Posts: 7 since Apr 2010
Thanks Given: 44
Thanks Received: 1

Hi all,

is there anyone who can help me to convert this TOS code into Tradestation, please ?
Basically it is code to show NYSE and Nasdaq breadth into charts.

See picture.


Here is TOS code:

 
Code
#--------------------------------------
#NYSE AND NASDAQ BREADTH BUBBLE SCRIPT
#--------------------------------------

input length = 2;


#NYSE Breath ratio
def NYSEratio =  if (close("$UVOL") >= close("$DVOL")) then (close("$UVOL") / close("$DVOL")) else -( close("$DVOL") / close("$UVOL")) ;
plot NYratio = round(NYSEratio, length);


NYratio.DefineColor("NYSEup", color.UpTICK);
NYratio.DefineColor("NYSEdown", color.DownTICK);
NYratio.AssignValueColor(if NYSEratio >= 0 then NYratio.color("NYSEup") else NYratio.color("NYSEdown"));

AddChartLabel(yes, concat(NYratio, " :1 NYSE"), (if NYSEratio >= 0 then NYratio.color("NYSEup") else NYratio.color("NYSEdown")));



#Nasdaq Breath ratio
def NASDratio =  if (close("$UVOL/Q") >= close("$DVOL/Q")) then (close("$UVOL/Q") / close("$DVOL/Q")) else -( close("$DVOL/Q") / close("$UVOL/Q")) ;
plot Qratio = round(NASDratio, length);

Qratio.DefineColor("NASup", color.UpTICK);
Qratio.DefineColor("NASdown", color.DownTICK);
Qratio.AssignValueColor(if NASDratio >= 0 then Qratio.color("NASup") else Qratio.color("NASdown"));

AddChartLabel(yes, concat(Qratio, " :1 NASD"), (if NASDratio >= 0 then Qratio.color("NASup") else Qratio.color("NASdown")));


#ZeroLine

plot zeroline = 0;
zeroline.assignValueColor(if NYSEratio > NYSEratio[1] then color.GREEN else color.RED);
zeroline.setLineWeight(1);
zeroline.hideTitle();
zeroline.hideBubble();
Thank you.
Peter


Reply With Quote
  #9 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,669 since Jun 2009
Thanks Given: 33,669
Thanks Received: 102,557

@PedroMAN, you might want to also post here:



Mike




We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on X Visit my NexusFi Trade Journal Reply With Quote
Thanked by:




Last Updated on July 18, 2012


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts