NexusFi: Find Your Edge


Home Menu

 





TradeStation Volume Ratio - for Ninja 6.5


Discussion in NinjaTrader

Updated
    1. trending_up 5,221 views
    2. thumb_up 0 thanks given
    3. group 1 followers
    1. forum 2 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
 
Todd's Avatar
 Todd 
Alpharetta, GA
 
Experience: Intermediate
Platform: ninja
Broker: Mirus / Zenfire
Trading: ES
Posts: 232 since Jun 2009
Thanks Given: 28
Thanks Received: 40

I use TradeStation and Ninja Trader. I found the following code for something called Volume Ratio. I'm thinking that this is an indicator that comes with their standard package. Can someone tell me if something exists like this for ninja? This seems like a great indicator. It was very easy to see the volume divergence on ES today.. see screenshot.
2010-03-25_1423


Here is the code for the indicator...
 
Code
                            
inputs: 
 
AvgLength( 14 ), 
 
UpVolAlertPct( 5 ), { UpVol alert if Avg( UpVolPct - DnVolPct ) > UpVolAlertPct }
 
DnVolAlertPct( -5 ), { DnVol alert if Avg( UpVolPct - DnVolPct ) <
  
DnVolAlertPct }
 
ColorNormLength( 14 ), { Number of bars over which to normalize the indicator
  
for gradient coloring.  See also:  comments in function NormGradientColor. }
 
UpColor( Yellow ), { Color to use for indicator values that are relatively high
  over ColorNormLength bars
. }
 
DnColor( Cyan ) ;  { Color to use for indicator values that are relatively low
  over ColorNormLength bars
. }
   
 { 
Set either UpColor and/or DnColor to -1 to disable gradient plot coloring.
 
When disabled, Plot1 color is determined by settings in indicator properties
 dialog box
.  Plot2 (ZeroLine) color always comes from indicator properties
    dialog box
. }
variables:
 
TotalTicks( 0 ), 
 
VolRatio( 0 ),
 
VolRatioAvg( 0 ),
 
ColorLevel( 0 ) ;
 
if 
BarType <= 1 then { ie, if tick or minute bars }
 
begin
 TotalTicks 
= UpTicks + DownTicks ;
 if 
TotalTicks > 0 then
  VolRatio 
= 100 * ( UpTicks - DownTicks ) / TotalTicks 
 
else
  
VolRatio = 0 ;
 
VolRatioAvg = XAverage( VolRatio, AvgLength ) ; 
 
Plot1( VolRatioAvg, "VolRatioAvg" ) ;
 
Plot2( 0, "ZeroLine" ) ;
 { 
Gradient coloring }
 if 
UpColor >= 0 and DnColor >= 0 then
  begin
  ColorLevel 
= NormGradientColor( VolRatioAvg, true, ColorNormLength, UpColor,
   
DnColor ) ;
  
SetPlotColor( 1, ColorLevel ) ;
  
end ;
 { 
Alert criteria }
 if 
VolRatioAvg crosses over UpVolAlertPct then
  Alert
( "UpVol alert" )
 else if 
VolRatioAvg crosses under DnVolAlertPct then
  Alert
( "DnVol alert" ) ;
 
end ; 


Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Building a free browser DOM/SMC simulator - need some ad …
Platforms and Indicators
No book, only a stair: journaling fills where price move …
Cryptocurrency
AI for Traders — Agents, Memory, Tools & Real-Worl …
Elite Quantitative GenAI/LLM
Bitcoin’s 2022 low, 2025 high and 2026 low so far arou …
Cryptocurrency
[WTS] ATAS Lifetime ULTRA license – EU buyers only – …
Platforms and Indicators
 
  #3 (permalink)
 tulanch 
Salt Lake City, UT
 
Experience: Intermediate
Platform: SC, NT, MT
Broker: AMP
Trading: NQ ES YM Bonds
Posts: 286 since Mar 2010
Thanks Given: 51
Thanks Received: 405


I know Ninja, I don't know TS. There are versions similar to this for Ninja (but without the alerts). I say similar because I don't understand how TS defines an uptick verus a downtick....knowing this defintion defines the behavior of the indicator. For example is an uptick defined as a sale at or above the ASK or is an uptick simply above the last sale - or something other? Another consideration is the tic value based on trades (number of orders ) or on contracts/trade (this is what typical volume is, total number of contracts)...for example 1 trade can be for 10 contracts - so does TS use a value of 1 or a value of 10 when it adjusts the the uptick or downtic variables? The term tic gets used interchangeably here.

I have created a number of indicators for Ninja focused on this. One simply overrides the OnMarketData method to access this level of information. You then decide how you want to accumulate the values based on your defined logic.

The logic within this TS code looks to be: defines alert factors based on +-5%, define totaltics as uptics+downtics, the volume ratio is defined as ((uptics-downtics)/totaltics ) normalized to fit in a +-100 value range, this is calculated for each bar and averaged over a 14 bar period to smooth out spikes. Gradient color is applied with + values moving towards blue and - values moving towards red.

I assume the TS XAverage is an eXpoential average?

if I read this correctly, it would be relatively easy to duplicate in ninjascript, but I am certain there are similar version in the indicator download area of the support forum.


Reply With Quote




Last Updated on March 26, 2010


© 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