Struggling a bit with this, I'm trying to optimize on time - so the system buys @ 9:00am or 10:00am etc
The strategy works fine with default values but once I tried to optimize I realized I could not.
So it seems I can optimize on integers but not time, so I changed the code in if (State == State.SetDefaults)
to go from
OpenTime = DateTime.Parse("09:00", System.Globalization.CultureInfo.InvariantCulture) ;
CloseTime = DateTime.Parse("14:00", System.Globalization.CultureInfo.InvariantCulture) ;
Didnt work:
OpenTime = new DateTime( 2018, 01, 01, OptimStr, 0, 0);
CloseTime = new DateTime( 2018, 01, 01, OptimStp, 0, 0);
I also tried this - but also didnt work
OpenTime = DateTime.Parse("00:00", System.Globalization.CultureInfo.InvariantCulture) .AddHours(OptimStr);
CloseTime = DateTime.Parse("00:00", System.Globalization.CultureInfo.InvariantCulture) .AddHours(OptimStp);
What does work:
OpenTime = new DateTime( 2018, 01, 01, 9, 0, 0);
CloseTime = new DateTime( 2018, 01, 01, 14, 0, 0);
How come if the 14 is changed from 14 to "OptimStp" then it stops working?
The values on the Strategy Analyser is 9 and 14 as well.
Everytime I try to print out anything the Output window clears if I run the backtest so I can never seem to print out to a log.
Indicator code:
[NinjaScriptProperty]
[Range(0, 24)]
[Display(Name="OptimStr", Description="OptimStr", Order=1, GroupName="Parameters")]
public int OptimStr { get; set; }
[NinjaScriptProperty]
[Range(0, 24)]
[Display(Name="OptimStp", Description="OptimStp", Order=2, GroupName="Parameters")]
public int OptimStp { get; set; }
Comment