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
-
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.
Leave a 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.
Leave a 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.
Leave a 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.
Leave a 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.
Leave a 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?
Leave a comment:
-
Hello sarasotavince,
Thank you for your response.
The variable needs to be created within the strategy as well, not just the indicator.
Leave a 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.
Leave a comment:
-
I see. Seems the public int is the key...or at least the first step. Much appreciated. I now have some direction....
Leave a comment:
-
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
Leave a comment:
-
Calling Indicator into Strategy..but then what if
I have mastered the basic idea...
Code:Add(AA01(1,18,55,3));
Tags: None
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Johndc, Today, 04:39 AM
|
0 responses
2 views
0 likes
|
Last Post
by Johndc
Today, 04:39 AM
|
||
Started by johntraderuser2, Today, 02:34 AM
|
0 responses
7 views
0 likes
|
Last Post Today, 02:34 AM | ||
Started by IanS00, 03-27-2024, 11:24 AM
|
2 responses
12 views
0 likes
|
Last Post Today, 02:00 AM | ||
Started by Mariawilcoxi, Today, 01:32 AM
|
0 responses
5 views
0 likes
|
Last Post
by Mariawilcoxi
Today, 01:32 AM
|
||
Started by gleichnerany, Today, 01:17 AM
|
0 responses
5 views
0 likes
|
Last Post
by gleichnerany
Today, 01:17 AM
|
Leave a comment: