NexusFi: Find Your Edge


Home Menu

 





Referencing an indicator setting within a strategy script


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one ktmdave with 3 posts (0 thanks)
    2. looks_two wccktrader with 3 posts (1 thanks)
    3. looks_3 eman with 1 posts (0 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
    1. trending_up 3,282 views
    2. thumb_up 1 thanks given
    3. group 2 followers
    1. forum 7 posts
    2. attach_file 0 attachments




 
Search this Thread

Referencing an indicator setting within a strategy script

  #1 (permalink)
 ktmdave 
Sacramento, CA
 
Experience: Beginner
Platform: NinjaTrader
Trading: Futures
Posts: 11 since Apr 2011
Thanks Given: 2
Thanks Received: 1

How do I OR what is the best way of referencing a custom indicator in my strategy script (within onbarupdate() function).

For example, say I was using the ADXVMA indicator. In my strategy I would want to reference when the line changes from yelllow to red.

What variables are available to do this?

Is there a way to list out all of the variables I could reference on a certain indicator?

Assume the indicator is already initialized in the strategy as Add(_ADXMVA_V01_5_2(9,True));

Thanks in advance!

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
ZombieSqueeze
Platforms and Indicators
REcommedations for programming help
Sierra Chart
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
How to apply profiles
Traders Hideout
Trade idea based off three indicators.
Traders Hideout
 
  #3 (permalink)
 eman 
Galveston ,TX
 
Experience: Intermediate
Platform: NT7
Broker: Zaner
Trading: Futures
Posts: 386 since Mar 2010
Thanks Given: 364
Thanks Received: 435


sorry for the brief and (likely) incomplete response ...

any public property of an indicator is available to you in the strategy. for example, say you added bollinger bands, you can access Bollinger(Median, 2.0, 21).Upper[0] within OnBarUpdate().
(note: Upper is one of properties of the Bollinger() standard indicator, as is Lower; the number 0 in square-brackets refers to current bar in the series)

so the practical application is: code your custom indicators so you can access the properties in a strategy.

hope this points you in the right direction.

cheers,
-e

Reply With Quote
  #4 (permalink)
 
wccktrader's Avatar
 wccktrader 
Singapore
 
Experience: Intermediate
Platform: NinjaTrader, Sierra Charts
Broker: Thinkorswim, IQFeed
Trading: Options of SPY, IWM, QQQ
Posts: 47 since Nov 2010
Thanks Given: 54
Thanks Received: 149


ktmdave View Post

For example, say I was using the ADXVMA indicator. In my strategy I would want to reference when the line changes from yelllow to red.

ADXVMA changing from yellow to red ....try this:


if (CurrentBar < 2)
return;

if ( _ADXVMA_v01_5_2(9, true).Main[0] < _ADXVMA_v01_5_2(9, true).Main[1]

&& _ADXVMA_v01_5_2(9, true).Main[1] == _ADXVMA_v01_5_2(9, true).Main[2])

{

do something

}

Reply With Quote
  #5 (permalink)
 ktmdave 
Sacramento, CA
 
Experience: Beginner
Platform: NinjaTrader
Trading: Futures
Posts: 11 since Apr 2011
Thanks Given: 2
Thanks Received: 1

What is the reason for
if (CurrentBar < 2)
return;


??

THanks!!!


wccktrader View Post
ADXVMA changing from yellow to red ....try this:


if (CurrentBar < 2)
return;

if ( _ADXVMA_v01_5_2(9, true).Main[0] < _ADXVMA_v01_5_2(9, true).Main[1]

&& _ADXVMA_v01_5_2(9, true).Main[1] == _ADXVMA_v01_5_2(9, true).Main[2])

{

do something

}


Started this thread Reply With Quote
  #6 (permalink)
 
wccktrader's Avatar
 wccktrader 
Singapore
 
Experience: Intermediate
Platform: NinjaTrader, Sierra Charts
Broker: Thinkorswim, IQFeed
Trading: Options of SPY, IWM, QQQ
Posts: 47 since Nov 2010
Thanks Given: 54
Thanks Received: 149

It is to ensure that there are enough bars in data series you are accessing (as the code makes reference to data 2 bars back.

More info in this thread: Make sure you have enough bars in the data series you are accessing - [AUTOLINK]NinjaTrader[/AUTOLINK] Support Forum

Reply With Quote
Thanked by:
  #7 (permalink)
 ktmdave 
Sacramento, CA
 
Experience: Beginner
Platform: NinjaTrader
Trading: Futures
Posts: 11 since Apr 2011
Thanks Given: 2
Thanks Received: 1

Awesome. And I assume that .Main[0] is referencing slope at the current bar?

dave


wccktrader View Post
It is to ensure that there are enough bars in data series you are accessing (as the code makes reference to data 2 bars back.

More info in this thread: Make sure you have enough bars in the data series you are accessing - [AUTOLINK]NinjaTrader[/AUTOLINK] Support Forum


Started this thread Reply With Quote
  #8 (permalink)
 
wccktrader's Avatar
 wccktrader 
Singapore
 
Experience: Intermediate
Platform: NinjaTrader, Sierra Charts
Broker: Thinkorswim, IQFeed
Trading: Options of SPY, IWM, QQQ
Posts: 47 since Nov 2010
Thanks Given: 54
Thanks Received: 149


ktmdave View Post
Awesome. And I assume that .Main[0] is referencing slope at the current bar?

dave

.Main[0] is the ADXVMA line itself. .Main[0] - .Main[1] is the current slope. .Main[1] - .Main[2] is the slope of the previous bar.

Reply With Quote




Last Updated on April 28, 2011


© 2024 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 - Privacy Policy - Downloads - Top
no new posts