Strategy Monitor and Strategy window
Author: haytac
Creation Date: 7/27/2010 9:43 AM
profile picture

haytac

#1
Hi,

On the WL window I am doing two things:
- Use strategy monitor to run strategy A (execute every minute). This always works.
- Run the same strategy A on its own window. This stalls fom time to time. Making the strategy execution time much shorter than 1 minute helps but does not make the stalls go away.

It seems that the instance of strategy A in its window is different than the instance the strategy monitor is running.

Is this correct?

Is there a way to drive the strategy window for A from the strategy monitor?

Thanks,
Hal
profile picture

Cone

#2
QUOTE:
Run the same strategy A on its own window.
Does this mean a Streaming Strategy window?

QUOTE:
Making the strategy execution time much shorter than 1 minute
Assuming Fidelity Streaming, how are you doing that?

QUOTE:
This stalls fom time to time.
If it happens not to be a Streaming window, what does a "stall" look like?

QUOTE:
Is there a way to drive the strategy window for A from the strategy monitor?
Well, there are ways to do just about anything, but there is no direct relationship with a Strategy running in the S. Monitor with one running in a Strategy Window.
profile picture

haytac

#3
Does this mean a Streaming Strategy window?
yes

the stall happens in the streaming window

the monitor seems to be executing another instance of this strategy each minute just fine

I need both:
- the visual input from the streaming window
- the execution of the strategy from the monitor
- these two can be different strategies with visual not doing any buys or sells

Since the streaming window stalls very often I was hoping that updating the window from the monitor could solve my issue,

Here is a question:
- When strategy monitor executes a strategy it must disable the visual content (windowing).
- Is there a clear definition of what functions in a strategy do not execute during monitor based execution?

In other words, it seems that the monitor execution and the execution started by clicking the streaming button on a strategy window are different.
- In what way re they different?

Thanks,
Hal
profile picture

Cone

#4
QUOTE:
Since the streaming window stalls very often
We *think* this is fixed in the upcoming release. It requires more testing, but there's a very good chance that the culprit has finally been identified.

The Strategy Monitor requests static data bars for updates. It looks at the time, waits a few seconds and start asking for the previous bar. Streaming (when working) should always give you a faster update at end of bar (usually within 1 second) and therefore will execute the strategy sooner.

Anyway for the time being, when you see a Streaming window stop, the only way I've found to get it going again is to log out and then back in. There's nothing the S. Monitor can do to kick start a streaming window.
profile picture

haytac

#5
Hi Cone,

Thanks for the fix. That will be a great help.

May I ask how the strategy monitor and streaming strategy window execute the same strategy differently. The only visible difference being that the s monitor does not launch a visible window. In other words the PlotSeries or DrawLine do not execute when the strategy is run by a monitor.

Possibly as the PricePane has not been created the PlotSeries throws an exception?

Is there a list of methods that execute in one case and not the other?

Thanks,
Hal
profile picture

Cone

#6
QUOTE:
Is there a list of methods
I don't have a list, no, but it's clear that anything "visual" are no-op'd for the Strategy Monitor as well as anything that is out-of-context like a ChartStyle. You must always develop a Strategy in the Strategy Window, and if it works there, it's all-but-guaranteed to work in the S. Monitor. The only case I can think of is if the strategy depends on objects from a ChartStyle context.

What do you mean that they "execute the same strategy differently"? Assuming precisely the same data, there's no way you can get different results when running the same [working, bug-free, non-random] Strategy. That said, there are at least 2 ways the data can be different:

1. The Streaming Provider builds the bars based on tick data. We've verified (after a fix in 5.3 I think) that about 99.9% of the time the bars built by Streaming are identical to the bars built by the historical server, which is where the S. Mon. gets it's data.

2. Intraday Pairs strategies will not work correctly in a Streaming window because the most-recent bar of the secondary symbol will be delayed w.r.t. the primary. However, in the S. Mon. that's not the case, so it's recommended that you run these types of Strategies there.
profile picture

haytac

#7
Hi Cone,

While waiting for the next release that fixes the stalls in the 1 minute Strategy Streaming Window, I am trying to use the Strategy Monitor. The monitor indicates that it is running the strategy each minute. To see its heartbeat I added the line:
PrintDebug( Bars.IntradayBarNumber( Bars.Count - 1 ));
This line works from the Strategy Window (when I run it manually with GO) but I do not see anything in the Debug Window from this line of code when the S. Monitor runs the same Strategy.

What cues are poossible from the S. Monitor runs?

Thanks,
Hal
profile picture

Cone

#8
The Strategy Monitor already provides cues through color coding (see User Guide); though for sure they're not intuitive and we're suggesting that it be improved. Also, the last "Action" column has messages that you may or may not be able to decipher, but generally indicates a symbol and some action being done on it.
profile picture

haytac

#9
Hi Cone,

I write to a file in my strategy. I can see it work when running the strategy in a window. Looking at the file itself I can see it has what the strategy wrote to it. However, when the same strategy is run via the Strategy Monitor, there is no file activity.

So now, I cannot use PrintDebug, I cannot write to a file. How can I communicate with my strategy while it is running under the Strategy Monitor?

I do see the messages under the "Action" column.

Thanks,
Hal
profile picture

minourat

#10
QUOTE:
You must always develop a Strategy in the Strategy Window, and if it works there, it's all-but-guaranteed to work in the S. Monitor.


I created a strategy that works in a Strategy window. However, it does not generate alerts or stage trade requests. Which ones in the following possible causes are applicable.

1) I am using BuyAtLimit(bar, limitPrice) and not using BuyAtLimit(bar + 1, limitPrice).
2) Is BuyAtLimit(bar + 1, limitPrice) effective only for bar + 1?
Is it possible to issue a limit order that is effective until canceled?
3) I changed parameters by using the Change Settings dialog box. However,
when this dialog box was reopened, the old parameters were displayed.
Were the parameters changed?

profile picture

Eugene

#11
QUOTE:
1) I am using BuyAtLimit(bar, limitPrice) and not using BuyAtLimit(bar + 1, limitPrice).

Bingo. This is what you need to fix to generate Alerts.
QUOTE:
Were the parameters changed?

If only you clicked the "Save parameters" blue link label below.
QUOTE:
2) Is BuyAtLimit(bar + 1, limitPrice) effective only for bar + 1?

Yes.
QUOTE:
Is it possible to issue a limit order that is effective until canceled?

For example, by coding it so it would regenerate on each bar: WealthScript Techniques | Setups, Triggers, Delays, and Timeouts.
profile picture

Cone

#12
Re: fix to generate Alerts
While for sure that not using bar + 1 is about the biggest mistake you can make when programming in Wealth-lab, please note that a bug exists in Version 5.6 that no Alerts are generated for Portfolio Simulation Mode if the Round Lots option is selected without the second Round Lots option to round up fewer than 50 shares.

@haytac -
While it appears that WealthScript's PrintDebug is disabled as an optimization for the S. Monitor, I don't think there's any way that Wealth-Lab can prevent your script from doing anything else ".NET" that you ask it to do, such as writing to a file or even displaying dialog messages, if you so choose. I can confirm that you can write to files, because I've just done that.
profile picture

haytac

#13
Hi Cone,

"I don't think there's any way that Wealth-Lab can prevent your script from doing anything else ".NET" that you ask it to do,"

This is very good to know. Can you please share the example code for file write?

a) It seems that my 1 minute strategy runs reliably (for 1 week without stalls) in a window and in streaming mode now. Thank you and Eugene for acknowledging this issue and having it fixed. It must have been a server side issue as the revision I have did not seem to change (or perhapss it did: 5.6.20.0359653).

b) While running in windows I can write to a file. But I cannot while running the same strategy in a Strategy Monitor. I hope I find out what I am doing wrong soon.

c) If both styles (i.e. run in a window or run within a SMon) work, what is the advantage of one versus the other?

Thanks and Regards,
Hal
profile picture

Eugene

#14
QUOTE:
This is very good to know. Can you please share the example code for file write?

From the Wealth-Lab Wiki:

Save Position Data to a Text File
Data | Exporting data out of WL5 to ASCII and WL4 native binary files

And a more generic one - File examples @ dotnetperls
profile picture

Cone

#15
a) it's not fixed yet, but we hope the next release will have one, along with a new Streaming provider, which will greatly improve Quotes performance.

b) for sure it works

c)
Strategy Monitor:
1. Fidelity Provider polls for updates 10-symbols at a time on a per Strategy-basis (lots of update delay)
2. uses one window for all Strategies (low resources, and organized)

Streaming:
1. streaming updates - the script is executed immediately when the bar ends (less order-entry delay, but..)
2. requires 1 window per symbol per Strategy plus all the post processing overhead (it's a good idea to use minimal Performance Visualizers when trading to reduce post-processing time and memory).
profile picture

bobydesi123

#16
Cone,
U have given a very good explanation above. I have one more question regarding the streaming. Suppose I am using a Strategy Monitor, the strategy on .dji (30 symbols) that calculates EMA10 and generates a trade based on it in 1min scale. Most likely(?) all the data (Ema10) for each of the .dji symbol is stored in memory and gets updated every minute when the SM executes.
1.In a streaming strategy is it possible to access the data(Ema10s of all .dji stocks) created by SM?
2. If in SM i store ema10s in global memory, can strategy access the SM stored global ema10s ?
3. In SM can global memory be shared by the each run of the .dji stock? i.e. suppose during the IBM run i store data in global memory and access it during XOM run?
Thanks
profile picture

minourat

#17
1) Can we edit, compile, and execute a strategy in the Strategy window while the previous copy of that strategy is running under the Strategy Monitor? Assume that the new code is not saved.
2) Does the new strategy code will replace the code being run under the Strategy Monitor when the new code is saved?
profile picture

Eugene

#18
minourat

1) Yes, SM has its own in-memory copy.
2) No, because of #1 - until you close SM and/or restart WLP.
profile picture

Eugene

#19
bobydesi123

1) Note that GetExternalSymbol is delayed in SM (by 1 bar?) due to a live bug.
2) Why not?
3) It's global memory, so yes.
profile picture

minourat

#20
This is not a major problem. I clicked the "Run this strategy now" menu item, then the following information was displayed.
QUOTE:
Strategy Account Last Run Next Run Trades
Dynamic Trade PaperAccount1 8/14/2010 1:23 A 8/14/2010 9:35 AM 63

Until I run this strategy by clicking the "Run this strategy now" menu item, Next Run was 8/16/2010 9:35 AM. The market is closed until 8/16.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).