cBot allways crashed
cBot allways crashed
17 Jan 2017, 14:20
I allways get the following message (some hours later after start) :
17/01/2017 11:30:46.828 | c52, EURUSD, h1 | Crashed in OnTick with InvalidOperationException: Nullable object must have a value.
How can I get deeper information about the problem? It would be great if the system tells me the line number where the problem occurs like other programmer languages (Metatrader, c++ etc.)
My OnTick function simpliest as I can. Where is the problem?
Thanks,
//------------------------------------------------------------------------------------
protected override void OnTick()
{
//------------------------------------------------------------------------------------
if (!bAuth)
{
Print("Invalid account!!! EA stopped!");
Stop();
return;
}
if (bWeekend)
{
// var positions = Positions.FindAll(Label, Symbol);
// if (positions.Length > 0)
ClosePos();
if (PendingOrders.Count > 0)
{
CloseOrders(TradeType.Buy);
CloseOrders(TradeType.Sell);
}
}
else
WorkWithPositions();
} //EndTick
Replies
FMogyi
19 Jan 2017, 13:52
Hi, thanks, your answer but I think your advice is wrong. bAuth is initialised bool variables at OnStart and bWeekend gets value at every OnBar function.
The cBot runs for an hours well for a while. The OnTick function was called well more hundreds or more thousands times before the problem occurs.
@FMogyi
andi21
17 Jan 2017, 14:55
Hello f.mogyi,
i think your variable bAuth OR bWeekend is a nullable bool ( bool? ), but it does not have a value. So either you check that with bAuth.HasValue / bWeekend.HasValue before your access your variables or you change your logic in code (no nullables etc.).
Best Regards,
Andi21
@andi21