NexusFi: Find Your Edge


Home Menu

 





Variable from custom Indicator


Discussion in NinjaTrader

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




 
Search this Thread

Variable from custom Indicator

  #1 (permalink)
 Diamond5 
omaha Nebraska
 
Experience: Intermediate
Platform: ninjatrader
Broker: Ninja
Trading: stocks, Futures ES, Options
Posts: 22 since Sep 2014
Thanks Given: 7
Thanks Received: 12

I am trying to pull in a variable from a custom indicator in to a new strategy.

I get the error "the name "trend" does not exist in the current context.

My code is as such:

PrintWithTimeStamp("," + MyCustomIndicator(trend)[1]);

Trend is a variable, and the indicator works fine. I'm just using the print statement to debug. I will ultimately want to use an IF statement such as:

IF (MyCustomIndicator(trend)[1] == 1)
{
make me money
}

TIA!

Visit my NexusFi Trade Journal Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
ZombieSqueeze
Platforms and Indicators
MC PL editor upgrade
MultiCharts
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
REcommedations for programming help
Sierra Chart
About a successful futures trader who didnĀ“t know anyth …
Psychology and Money Management
 
  #3 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,103


You need to make sure that your custom indicator has a property defined for the trend state that you are trying to access. I suppose that trend is a BoolSeries (or IntSeries). In that case you would define the property as

 
Code
#region Properties

[Browsable(false)]
[XmlIgnore()]		
public BoolSeries Trend
{
    get { return trend; }
}


Now you can access that property of your custom indicator in a strategy as

 
Code
MyCustomIndicator( .... parameters ....).Trend[0]

Reply With Quote
Thanked by:
  #4 (permalink)
 Diamond5 
omaha Nebraska
 
Experience: Intermediate
Platform: ninjatrader
Broker: Ninja
Trading: stocks, Futures ES, Options
Posts: 22 since Sep 2014
Thanks Given: 7
Thanks Received: 12


Fat Tails View Post
You need to make sure that your custom indicator has a property defined for the trend state that you are trying to access. I suppose that trend is a BoolSeries (or IntSeries). In that case you would define the property as

 
Code
#region Properties

[Browsable(false)]
[XmlIgnore()]		
public BoolSeries Trend
{
    get { return trend; }
}


Now you can access that property of your custom indicator in a strategy as

 
Code
MyCustomIndicator( .... parameters ....).Trend[0]


Perfect - that was it! Thank you!

Visit my NexusFi Trade Journal Started this thread Reply With Quote




Last Updated on September 22, 2014


© 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