I have a Bollinger band equation that is functioning correctly. However, I am trying to change the last value at the end of the equation to a variable, so that I can optimize it within the strategy analyzer tool, and have been having some trouble.
As I have it set up now, there is a parameter, and it allows me "optimize" it, but nothing actually happens. Somehow it is not interpreting the variable changing. (the variable is "Bbx")
This is the code I have:
This is the function that is working and calculating correctly with a fixed value (backtests produce various results when I change the value), I am trying to optimize the value ".2" at the end of the equation
((((Bollinger(2,20).Upper[0]) - (Bollinger(2,20).Lower[0])) / (Bollinger(2,20).Upper[0])) * 100 >= .2)
This is the function that I have been trying to optimize by: (I have also tried putting "Bbx/100" in its own parentheses)
((((Bollinger(2,20).Upper[0]) - (Bollinger(2,20).Lower[0])) / (Bollinger(2,20).Upper[0])) * 100 >= Bbx/100 )
I have it as (Bbt/100) because I read that only integers can be optimized as custom values, so I used (Bbx/100) to produce the desired decimal value for the strategy
This is the code I have under the properties region for Bbx under strategy parameters:
[NinjaScriptProperty]
[Range(int.MinValue, int.MaxValue)]
[Display(Name="Bbx", Order=5, GroupName="Custom Calculations")]
public int Bbx
{ get; set; }
I have also tried:
[NinjaScriptProperty]
[Range(int.MinValue, int.MaxValue)]
[Display(ResourceType = typeof(Custom.Resource), Name= "Bbx", Order=5, GroupName= "Custom Calculations")]
public int Bbx
{ get; set; }
I also have the default value already set under: if (State == State.SetDefaults)
Whenever I try to optimize, I get the same value for Bbx over and over (even when I make it the only optimizable parameter).
How can I fix this?
Comment