Strategy based on Study with both 'Calculate' and 'CalculateValues'

Spin

Well-known member
Joined
May 22, 2019
Posts
474
Likes
189
Dear fellow-coders,


Another day, another coding issue. ❓❓

I am building a Strategy, based on VWAP. I have built quite a few Strategies before, but they were all based on a Study that only contained 'CalculateValues'.
VWAP is different: it contains both 'Calculate' and 'CalculateValues'.

I altered the (standard) MW VWAP Study lightly and it runs fine by itself in its new form on any chart I drop it on: the VWAP gets drawn and updated on each incoming Tick.

However, from the moment I build a Strategy, based on VWAP, and drop in onto a chart, the underlying VWAP simply freezes. Even when I add it to a 'skeleton'-Strategy (containing nothing more than 'Initialize') the VWAP fails to do its job. :unsure:
486

A little hint perhaps: when I click the 'pencil' icon, to call the Strategy's menu and close it by selecting 'update' or 'apply', the VWAP gets calculated up until the last bar at that moment. This is the behavior I would like to see, but without passing through the menu, obviously.

I believe this has to do with the VWAP 'Calculate' (and 'onTick ?) function no longer getting called. By using a bunch of 'debug'-lines, I established that 'Calculate' only gets executed upon exiting the menu or the very first tick after the Strategy is dropped on a chart. The same seems to be true for 'onTick'.

Why is this ?
Has anyone experienced similar behavior with the same or another Study ?
Did you get it fixed ?
How ?

All help / input welcome !

Thanks in advance !! 😁
 
Last edited:

Spin

Well-known member
Joined
May 22, 2019
Posts
474
Likes
189
Ok, so I investigated a little deeper and noticed the ticks continue to be treated when I use only the Study, but 'treatment' of incoming Ticks stops when I remove the Study and attach the Strategy (that is of course based on the exact same Study) to a chart.

I am puzzled now: what part of my (skeleton-) Strategy would 'break' the treatment / calculation of incoming Ticks ? :unsure::unsure:
 

Spin

Well-known member
Joined
May 22, 2019
Posts
474
Likes
189
Replay Mode is funny when it comes to Ticks:
1653465046204.png

So here is the question: does your browser support tick-based historical data ? If not, MW will 'construct' Ticks.

The question after that would be then: how are these constructed Ticks treated ? I'm afraid only MW staff can answer this ...
My original post in this thread is pretty old already, but I believe I had 'debug-listeners' in both 'onTick' and 'Calculate' to figure out what was going on behind the curtains.

YMMV :)
 
Top