Add(AA01(1,18,55,3));
Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
Calling Indicator into Strategy..but then what if
Collapse
X
-
Calling Indicator into Strategy..but then what if
I have mastered the basic idea...
Code:Tags: None
-
Hello sarasotavince,
Thank you for your post.
You would need to set a user defined variable in the strategy as well and then assign that variable when calling the AA01. For information on user defined variables please visit the following link: http://www.ninjatrader.com/support/f...ead.php?t=5782
-
I see. Seems the public int is the key...or at least the first step. Much appreciated. I now have some direction....
Comment
-
Patrick (or anyone),
I have hit a road block... To keep it simple, here is the code from the Indicator AA01:
Code:FROM Variables..... private int setTicks = 1; FROM Properties... [Description("How many ticks for trade signal")] [GridCategory("Parameters")] public int SetTicks { get { return setTicks; } set { setTicks = Math.Max(1, value); } }
Code:FROM protected override void Initialize() Add(AA01(SetTicks,18,55,3,0,0, etc.));
What am I missing? Please and Thank You. I have also tried "setTicks" but with same results.
Last edited by sarasotavince; 06-16-2014, 11:33 AM.
Comment
-
After reading your first post three (3) times, I tried that and it worked. So, here is my final question: Now I have the same variable in both the indicator and the strategy. I set the default value for the strategy variables at ZERO, since I am pulling all variable values from the indicator. Editing the value from strategy's property box should have no effect correct since the true value of the variable is coming from the property box of the indicator (once applied and saved), via the Add line in the strategy's code. Do I have this correct?
Comment
-
Hello sarasotavince,
When you pass a parameter into the indicator method, that is the value that will be used. So if you set the Strategy's variable to 0 and pass that to the indicator method in the Strategy, the indicator is going to use 0. If you would like an example, please go to Tools > Edit NinjaScript > SampleMaCrossover > and view how the fast and slow variables in the strategy are passed as the period for the SMAs.
Comment
-
I am sorry Patrick but your example was of no help. I thought I was passing a value from an indicator to a strategy. I thought I needed that variable in both the indicator and the strategy. When I look at indicator SMA, there is no input for slow and fast, only a period. I see where SampleSMA uses the ADD line to get slow and fast but how it is getting it from SMA I have no idea, thus I have no example to build upon.
Is there a more more detailed example you can suggest? Sometimes I find only a line or two these posts makes sense....more detailed examples help. I find the NT examples overly simplistic and not very useful...unfortunately. Thanks. I will keep trying.
Comment
-
Originally posted by sarasotavince View PostI am sorry Patrick but your example was of no help. I thought I was passing a value from an indicator to a strategy. I thought I needed that variable in both the indicator and the strategy. When I look at indicator SMA, there is no input for slow and fast, only a period. I see where SampleSMA uses the ADD line to get slow and fast but how it is getting it from SMA I have no idea, thus I have no example to build upon.
Is there a more more detailed example you can suggest? Sometimes I find only a line or two these posts makes sense....more detailed examples help. I find the NT examples overly simplistic and not very useful...unfortunately. Thanks. I will keep trying.
If you want the indicator parameters to be adjustable, those parameters must be specified by the calling object (the strategy), and passed back to the called object (the indicator). The indicators output will always be available to the strategy: you simply have to access that output however you want to do so. In this scenario, you have a dual passing mechanism. The strategy determines what parameters it wants the indicator to use, and the indicator uses those parameters, and passes values back to the strategy.
Comment
-
I now have the same variables in the indicator and the strategy, which seems redundant (but whatever). Since the strategy calls the indicator I only enter the variables values in the strategy, then as you say, pass them back to the indicator (which seems backwards). In any case, I can now change a variable "on the fly" and there is hard no hard coding in the strategy, which was the goal. Thanks All.
Comment
-
Originally posted by sarasotavince View PostI now have the same variables in the indicator and the strategy, which seems redundant (but whatever). Since the strategy calls the indicator I only enter the variables values in the strategy, then as you say, pass them back to the indicator (which seems backwards). In any case, I can now change a variable "on the fly" and there is hard no hard coding in the strategy, which was the goal. Thanks All.
And, yes. When I first started with OOP, it confused the heck out of me too.Last edited by koganam; 06-18-2014, 01:36 PM.
Comment
-
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Brevo, Today, 01:45 AM
|
0 responses
6 views
0 likes
|
Last Post
by Brevo
Today, 01:45 AM
|
||
Started by aussugardefender, Today, 01:07 AM
|
0 responses
3 views
0 likes
|
Last Post Today, 01:07 AM | ||
Started by pvincent, 06-23-2022, 12:53 PM
|
14 responses
242 views
0 likes
|
Last Post
by Nyman
Today, 12:47 AM
|
||
Started by TraderG23, 12-08-2023, 07:56 AM
|
9 responses
384 views
1 like
|
Last Post
by Gavini
Today, 12:29 AM
|
||
Started by oviejo, Today, 12:28 AM
|
0 responses
6 views
0 likes
|
Last Post
by oviejo
Today, 12:28 AM
|
Comment