View Full Version : Major strategy bug...
blarouche
10-05-2009, 05:36 PM
I have a major issue with strategies. All my strategies that were working well in 6.5 are not working and creating exception all over the place.
I tried to send the trace file by email but didn't work. Here is the important part I think from the trace file :
2009-10-05 16:07:11:472 in OnUnhandledThreadException
2009-10-05 16:07:11:566 ********* exception trapped *********
2009-10-05 16:07:11:566 String was not recognized as a valid Boolean.
2009-10-05 16:07:11:566 at System.Boolean.Parse(String value)
at NinjaTrader.Strategy.Parameter.get_Value()
at NinjaTrader.Strategy.Parameter.Clone()
at NinjaTrader.Strategy.ParameterCollection.Clone()
at NinjaTrader.Strategy.StrategyBase.Clone()
at NinjaTrader.Gui.Chart.ChartControl.Add(StrategyBas e strategyTemplate)
at NinjaTrader.Gui.Chart.ChartStrategies.Apply()
at NinjaTrader.Gui.Chart.ChartStrategies.OnApplyButto nClick(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventAr gs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Hope it helps
Bernard
NinjaTrader_Ray
10-05-2009, 05:42 PM
Hi Bernard,
Thanks for reporting. We of course would need to take this step by step. Although the call stack is of value, it may not be enough to trap this particular issue.
Is there any possible way we are able to get a reproducible scenario from you?
blarouche
10-05-2009, 06:45 PM
Ray
I read the email you sent yesterday and I may have a few possibilities. In all my properties I still have the [Category("Parameters")]. I have changed it for
[GridCategory("Parameters")].
No change in the result.
I am also using the .token value in my code like this :
if (entryBOrder1 != null && entryBOrder1.Token == order.Token)
Should I replace that ?
I can send you My strategy template code by email if that could help.
Bernard
NinjaTrader_Josh
10-05-2009, 07:07 PM
Token influences the behavior of your orders and would not necessarily be the cause for the "String was not recognized as a valid Boolean" error.
If you have a reproducible sample strategy we could test with, please attach it and we can try on our end. Thank you.
blarouche
10-05-2009, 07:27 PM
Guys
I've played a bit with the code earsing part of it trying to find a way to get to this exception.
It seems that when I erased the properties I could apply the strategy without exceptions being thrown.
Here are my properties :
[Description("No trades after this time")]
[GridCategory("Parameters")]
public int Last_Trade_Time
{
get { return lastTradeTime; }
set { lastTradeTime = value; }
}
[Description("First Target contracts")]
[GridCategory("Parameters")]
public int Cnts_FirstTarget
{
get { return Cnts_firstTarget; }
set { Cnts_firstTarget = value; }
}
[Description("Second Target Contracts")]
[GridCategory("Parameters")]
public int Cnts_SecondTarget
{
get { return secondTarget_Cnts; }
set { secondTarget_Cnts = value; }
}
[Description("Third Target contracts")]
[GridCategory("Parameters")]
public int Cnts_ThirdTarget
{
get { return thirdTarget_Cnts; }
set { thirdTarget_Cnts = value; }
}
[Description("Stop loss in ticks")]
[GridCategory("Parameters")]
public int StopLoss
{
get { return stopLoss; }
set { stopLoss = value; }
}
[Description("First Target in ticks")]
[GridCategory("Parameters")]
public int Ticks_FirstTarget
{
get { return firstTarget_Ticks; }
set { firstTarget_Ticks = value; }
}
[Description("Second Target in ticks")]
[GridCategory("Parameters")]
public int Ticks_SecondTarget
{
get { return secondTarget_Ticks; }
set { secondTarget_Ticks = value; }
}
[Description("Third Target in ticks")]
[GridCategory("Parameters")]
public int Ticks_ThirdTarget
{
get { return thirdTarget_Ticks; }
set { thirdTarget_Ticks = value; }
}
[Description("Do you need the trailing stop")]
[GridCategory("Parameters")]
public bool TrailingStop
{
get { return trailingStop; }
set { trailingStop = value; }
}
[Description("Number of profitable ticks before the trailing stop is enabled")]
[GridCategory("Parameters")]
public int TrailStopTrigger
{
get { return trailStopTrigger; }
set { trailStopTrigger = value; }
}
[Description("Number of ticks trailing behind market once enabled")]
[GridCategory("Parameters")]
public int TrailStopTicks
{
get { return trailStopTicks; }
set { trailStopTicks = value; }
}
[Description("Filter Setup")]
[GridCategory("Parameters")]
public FilterState Filter_Setup
{
get { return filter_Setup; }
set { filter_Setup = value; }
}
[Description("Filter Stategy")]
[GridCategory("Parameters")]
public FilterCase Filter_Method
{
get { return filter_Method; }
set { filter_Method = value; }
}
Thanks
Bernard
NinjaTrader_Dierk
10-05-2009, 11:11 PM
Looking at our code ... I have an idea what might be going wrong. Could you please go Tools->Options and just close the dialog by pressing OK?
Would that resolve the issue?
blarouche
10-05-2009, 11:34 PM
Dierk
Just did what you said.
The problem is still there.
It was working so well in NT6.5 !
What could have happened ?
Bernard
NinjaTrader_Dierk
10-05-2009, 11:36 PM
Hmm ... no sure then. Could you please post one of your strategies so we could take look? Thanks
blarouche
10-05-2009, 11:39 PM
They are big files that also rely on indicators.
Really complex, difficult to post I think
Bernard
NinjaTrader_Dierk
10-05-2009, 11:40 PM
We needed something to work with. Could you please strip it down to a small sample which would exhibit the issue? Thanks
blarouche
10-05-2009, 11:42 PM
Dierk
I will try to do that.
I am in Montreal and it is 12:41 in the night.
So I'll take some rest and do that tomorrow
Thanks for your help
Bernard
NinjaTrader_Dierk
10-05-2009, 11:43 PM
Thanks for working on that with us. Appreciated. Later...
blarouche
10-06-2009, 07:58 AM
After many tries it seems that it all comes back to this :
[Description("Do you need the trailing stop")]
[GridCategory("Parameters")]
public bool TrailingStop
{
get { return trailingStop; }
set { trailingStop = value; }
}
If I remove that property the strategy is running without exceptions BUT generate nothing.. no trades !!
Bernard
NinjaTrader_Dierk
10-06-2009, 08:05 AM
Looking into ...
blarouche
10-06-2009, 08:17 AM
A few more tests...
If I put a Print("What's up!") to follow code at run time I have found the following :
If I put this statement in the Initialize() method when I click on strategies...
in the context menu I see three print :
What's up!
What's up!
What's up!
If I put the statement at the start of the OnBarUpdate method I see
no Print statement at all
Bernard
NinjaTrader_Dierk
10-06-2009, 08:19 AM
This is a bug. You likely would see that bug with any non integer or double property which is flagged by "GridCategory".
Thanks for reporting.
Aussie2
10-27-2009, 08:40 PM
Looking into ...
Hello Dierk,
I have a similiar issue to blarouche regarding public bool use in NT7B2.
Would appear that NT7B2 is not accepting any public bool code without throwing run time error exceptions.
If a public bool is introduced into any strategy (even a new Strategy created with the Create New Strategy wizard) then two error messages result, including a "Value cannot be null" and "String not recognised as a valid boolean. Error messages in attached pdf.
Is there a solution at this stage?
Thanks.
NinjaTrader_Dierk
10-27-2009, 10:35 PM
>> Is there a solution at this stage?
Sure. Please try NTB3 which is out since a few days.
Aussie2
10-28-2009, 05:00 AM
>> Is there a solution at this stage?
Sure. Please try NTB3 which is out since a few days.
Thanks Dierk - will retest with NT7B3