Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Indicator proportional to another
Collapse
X
-
Indicator proportional to another
Perhaps I placed my concern in the wrong place. My request seems simple. I want to allow other indicators to move proportionally with one indicator that has an assigned value for optimization. For example, if I assign the value of 200 to a SMA, I would like the value of the RSI to be (SMA*.25). When the optimized value of the SMA changes, the RSI will also change without having to separately optimize it. Can anyone help me with this. I have searched the help files and videos and forums and internet to no avail. I simply want the value of the RSI to be (SMA*.25) once the value of the SMA is declared. Please advise.Tags: None
-
Hello birdjaguar,
Thanks for your post.
It sounds like then you would want to set a user parameter for the SMA value and then in the code set your RSI to that variable * .25.
You may want to put some code in place to ensure that the RSI period would be no lower than some set minimum level. Such as RSI(Math.Max(5, value)) // uses the maximum of 5 or value if greater than 5.
Please see our reference information on creating user defined inputs:http://ninjatrader.com/support/forum...ead.php?t=5782Paul H.NinjaTrader Customer Service
-
Thank you. I am familiar with creating user defined inputs. I have a user defined input for the SMA. That doesn't help me at all, with my question. Your interpretation of the question is correct.
"set a user parameter for the SMA value and then in the code set your RSI to that variable * .25."
Again, how can I set the value of the RSI to a fraction of the user defined input of the SMA?
Comment
-
Hello birdjaguar,
Thank you for your response.
Likely you have errors because creating a fraction of a whole value is likely creating a double value seeing as the value you multiply has a decimal.
So you need to take a few steps here. Based on the code you provided at the following thread I will provide an example below: http://ninjatrader.com/support/forum...ad.php?t=90904
Code:int RSIPeriod = Convert.ToInt32(SMAPeriod * .25); MySMA = SMA(SMAPeriod); MyRSI = RSI(RSIPeriod, 1);
Education: http://ninjatrader.com/support/helpG..._resources.htm
Comment
-
Thank you for your response. I did peruse the educational resources to no avail. There was nothing there that actually helps with this code. I also tried your code to no avail, or maybe I just don't understand where it goes. I am at a loss as to why this is difficult and I am surprised that this has no come up before. Also, the "ConvertTo." syntax doesn't even come up in the search engine. How do I get from the following code to the RSI calculating as the SMA*.25?
#region Variables
int sMAperiod = 200;
int RSIPeriod = Convert.ToInt32(SMAPeriod * .25);
#region Properties
[Description("")]
[GridCategory("Parameters")]
public int SMAperiod
{
get { return sMAperiod; }
set { sMAperiod = Math.Max(1, value); }
}
[Description("")]
[GridCategory("Parameters")]
public int RSIperiod
{
get { return rSIperiod; }
set { rSIperiod = Math.Max(1, value); }
}
Comment
-
Originally posted by birdjaguar View PostThank you for your response. I did peruse the educational resources to no avail. There was nothing there that actually helps with this code. I also tried your code to no avail, or maybe I just don't understand where it goes. I am at a loss as to why this is difficult and I am surprised that this has no come up before. Also, the "ConvertTo." syntax doesn't even come up in the search engine. How do I get from the following code to the RSI calculating as the SMA*.25?
#region Variables
int sMAperiod = 200;
int RSIPeriod = Convert.ToInt32(SMAPeriod * .25);
#region Properties
[Description("")]
[GridCategory("Parameters")]
public int SMAperiod
{
get { return sMAperiod; }
set { sMAperiod = Math.Max(1, value); }
}
[Description("")]
[GridCategory("Parameters")]
public int RSIperiod
{
get { return rSIperiod; }
set { rSIperiod = Math.Max(1, value); }
}Code:#region Variables private int sMAperiod = 200; private int RSIPeriod = 0; #region Properties [Description("")] [GridCategory("Parameters")] public int SMAperiod { get { return sMAperiod; } set { sMAperiod = Math.Max(1, value); RSIPeriod = Convert.ToInt32(sMAPeriod * .25);} }
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by jomengle, Yesterday, 11:10 PM
|
0 responses
2 views
0 likes
|
Last Post
![]()
by jomengle
Yesterday, 11:10 PM
|
||
Started by kendra, Yesterday, 09:31 PM
|
0 responses
6 views
0 likes
|
Last Post
![]()
by kendra
Yesterday, 09:31 PM
|
||
Started by Skifree, Yesterday, 09:26 PM
|
1 response
11 views
0 likes
|
Last Post
![]()
by Skifree
Yesterday, 09:30 PM
|
||
Started by straderk, Yesterday, 09:25 PM
|
0 responses
6 views
0 likes
|
Last Post
![]()
by straderk
Yesterday, 09:25 PM
|
||
Started by straderk, Yesterday, 09:14 PM
|
0 responses
4 views
0 likes
|
Last Post
![]()
by straderk
Yesterday, 09:14 PM
|
Comment