OrdersTotal() returns 0 after platform reboot

To add comments, please log in or register
BaronWawelski
42
BaronWawelski  

When I launch / reboot platform v4.00 build 1090

indicator doesn't work porperly because OrdersTotal() returns 0 even if the are orders open and pending.

when I open 'Indicators List' and then close it then OrdersTotal() (and indicator) starts to work / display correct values.

The indicator I am talking about is '0 - Open Positions v3a'.


The proof that it is about OrdersTotal() is that I created new indicator with adding   'Print("TEST_total: ", OrdersTotal());    in OnCalculate function  and it prints 0 after reboot.


Is there a way to workaround it and not to have a need of opening 'Indicators List' each time platform is restarted?


thanks

Keith Watford
Moderator
20371
Keith Watford  
Maybe you could count the number of ticks and don't get OrdersTotal until after x ticks. That may give it time to load the data.
GrumpyDuckMan
882
GrumpyDuckMan  
BaronWawelski:

When I launch / reboot platform v4.00 build 1090

indicator doesn't work porperly because OrdersTotal() returns 0 even if the are orders open and pending.

when I open 'Indicators List' and then close it then OrdersTotal() (and indicator) starts to work / display correct values.

The indicator I am talking about is '0 - Open Positions v3a'.


The proof that it is about OrdersTotal() is that I created new indicator with adding   'Print("TEST_total: ", OrdersTotal());    in OnCalculate function  and it prints 0 after reboot.


Is there a way to workaround it and not to have a need of opening 'Indicators List' each time platform is restarted?


thanks

Maybe indicator can't place order?
BaronWawelski
42
BaronWawelski  

hah!   of course! it is Saturday today :) so no ticks coming and I tried with broker offering BTC and it dispalys correctly once tick arrives. thanks!


However, is it a bug or is it intended that OrdersTotal() returns 0 first when no tick arrived yet?  (but OnCalculate() executes regularly) If intended  (to for example block analysis of orders with potentially old orders data???) than why OrdersTotal() works ok when indicator is  reinitialized or reconfigured or even just listed in indicators list (still on Saturday without ticks)? The problem exists after platform reboot only.


Regarding your workaround, I was thinking about it how to implement - OnTick() is not available for indicator.  Then..  was it perhaps iVolume() you had in mind or something even better?

BaronWawelski
42
BaronWawelski  

ok, solved.  onCalculate() for indicators is like onTick() for EA.

On Saturday there is no tick often so onCalculate() wouldn't be called (except initial 6? times after reboot when OrdersTotal() is not ready), but timer should solve the problem. After 15 seconds OrdersTotal() returns non 0 value.



thanks!  :) :)

To add comments, please log in or register