How to sort alerts according to Position Priority
Author: okirchhof
Creation Date: 6/15/2014 12:12 PM
profile picture

okirchhof

#1
Hi,


In my strategy I defined a Position Priority (LastActivePosition.Priority). So far, so good.

But, when the strategy produces alerts, the values for Position Priority are not shown, which makes it impossible to sort the alerts according to the valuue of my Position Priorty. Is it possible to show the position priority (in my Strategy it is a RSI-Parameter) in the alerts-window?

Thanks for your help!
profile picture

Eugene

#2
Hi,

Yes. If you assign the priority value to the EntrySignal name, it will appear on the Entry Signal column. Note that the sorting order of the field is text-based, not numeric.
profile picture

okirchhof

#3
Actually I don't know how to assign priority value to the EntrySignal name. Can I find an example somewhere? Thank you!
profile picture

Cone

#4
You can probably find lots of examples by using the Strategy Explorer's Search for Strategy Code containing Priority, but the idea is pretty simple... save the priority in a variable and pass it to the signalName parameter and later assign it to the Position's Priority.

CODE:
Please log in to see this code.
profile picture

da42007

#5
Hello Cone,

I am trying to use the above code, absent the minus sign, to give highest priority to the highest RSI.

CODE:
Please log in to see this code.


But it seems to give the lowest RSI in this sample code.

CODE:
Please log in to see this code.


Conditions:
Scale: Weekly
Data Range: 1/1/2016 to 9/23/2016
Position Size: PosSizer Max Entries per Day=1, Pct of Equity=5
Data Set AAPL, ADBE, AMZN

On 9/23/2016, the alert with the highest RSI is AMZN (as indicated in the Signal Name), but the code buys AAPL, which had the lowest RSI.

Can you help please?

Kind regards.







profile picture

Eugene

#6
Hi,

No, this code cannot assign any other priority but the highest. The code is not to blame.

You're probably doing something else than your post says? This code cannot buy anything on 9/23/2016 with these settings applied because it has ran out of capital since June 2016. It only generates three alerts.
profile picture

da42007

#7
Thanks Eugene.

If I change the dates so that it simulates from 9/2/2016 to 9/30/16 to avoid the capital issue, I still get the problem where AMZN has the highest RSI value on 9/23/16, but the code buys AAPL instead. I cannot figure out why it doesn't buy AMZN.

Thank you.
Kind regards.
profile picture

Eugene

#8
QUOTE:
from 9/2/2016 to 9/30/16

David, the test does not make sense with these settings:

1) On weekly data, the 14-period RSI is not valid so the priority will be 0.
2) On daily data, it also doesn't matter which stock is bought on 09/23 for the same reason (value = 0). It's bar #14 and you're using an unstable indicator. Please check out the WealthScript Programming Guide > Indicators > Stability of Indicators.

Anyway, I'm sure there's no issue here - rather a misunderstanding.
profile picture

da42007

#9
Here's the issue Eugene.


These are the alerts on 9-23-16



AMZN has the highest RSI as shown in the Signal Name "69.882"

but it is AAPL that is bought on the next bar, which had the lowest RSI of 62.173



Conditions changed to:
Date Range 1/1/16 to 9/23/16 (to show alerts)
PosSizer Position Options. Max pos. per day = 1, Fixed Dollar = 1000
Starting capital 100000
Scale weekly
profile picture

Eugene

#10
I cannot reproduce your results. In my case, AMZN is bought properly:




Your 2nd screenshot looks unexpected. What you're describing just doesn't line up with what you're showing. How's that possible that there's only one position there? This just can not happen with your settings if you just shift the end date to 09/30/2016. There should be dozens preceding AAPL.

Are you maybe comparing the backtest to an instance of the strategy running in the Strategy Monitor? In this case please see the User Guide > Reference > Data Panel > Position Size Control > Operational difference between the Strategy Monitor and Backtester. They are not born equal.

P.S. Please use attachments to show pictures. External image hosters tend to lose images when they're not accessed for awhile. Simply click "Add attachment(s)" when replying. Later you can even right click on the attachment link in your post, copy it and edit the post so that the image appears inline. Thanks.

profile picture

da42007

#11
Just sent this before seeing your response.

Ref "How's that possible that there's only one position there?"
I scrolled the view to show one trade so that I could include the header.

Attachments - certainly, my mistake - I expected to see it as an option along with formatting and links and simply missed it at the bottom.

Eugene, I absolutely love WLP and would recommend it to anyone. This piece of code worked exactly as I expected for two years up until some change related to the last two minor releases. If I could install a copy of 6.9.13.0, at least I could be satisfied in my own mind that I had investigated it about as far as I can. Do you know of a way I could do that?
I would really appreciate it if you could take a look at some scripts that you know use this code, or recreate a simple example to double check how it's handling the RSI priority. I appreciate you pointing out that RSI is a so-called "unstable" indicator, but the issue I am trying to highlight looks like it relates to use of the RSI value as a text string.
Anyway, if you think there is nothing more that can be done or learned from this, I submit to your better judgement and thank you for your time.

Thanks for your work on this Eugene. I am definitely getting different results. Is there any information I can provide to compare your setup with mine that might give some clues?

It goes without saying you are using version 6.9.16.0?

Sincere regards.
profile picture

Eugene

#12
One of your screenshots indicates that you're running a "Highest RSI" strategy. I think that we may still be comparing apples to oranges here. The sample code will not demonstrate the anomaly that you're reproducing with your production strategy.

QUOTE:
but the issue I am trying to highlight looks like it relates to use of the RSI value as a text string.

It doesn't have to do with text strings: .ToString is only used here for display purposes. The priority value itself is not affected.

QUOTE:
It goes without saying you are using version 6.9.16.0?

6.9.15 (which is the latest Developer version).

QUOTE:
If I could install a copy of 6.9.13.0

Although I do not support this theory, if you create a support ticket one of us will provide you the download link.
profile picture

superticker

#13
QUOTE:
assign the ... value [to be sorted] to the EntrySignal name, it will appear on the Entry Signal column. Note that the sorting order of the field is text-based, not numeric.
Is it possible to include a numeric column in the Alert table that could be sorted numerically?

It might be nice to place such a numeric column either at the end of the Alert table so those not using it could just cut it off. Or place it just in front of the Signal column.

It would also be nice to include a way to color code the lines of the Alerts. (Not all Alerts are created equal.)
profile picture

Eugene

#14
QUOTE:
Is it possible to include a numeric column in the Alert table that could be sorted numerically?

All built-in visualizers (like the Alerts tab) cannot be modified. Fortunately, you could develop your own customized Alerts tab. The Visualizer API is documented and there are examples to help you on your way:

Demo source code of MS123 Visualizers' previous gen.
Wealth-Lab Version 6 (.NET) Development Guide
Trades+: Open/All trade lists with Priority and Multi-Column Sort
profile picture

pubx101

#15
I am having similar problems with the trades selected from previous alerts.

I run strategy back test in simulation mode day by day. every 'buy' alert has a priority, but the trades selected for the next day are not always as expected in the order of priority values (though it works fine for the most time).

Is it possible that I can download the source code for the simulation framework so I can debug and find the reason?
profile picture

Eugene

#16
Wealth-Lab is not an open source project so troubleshooting works the other way around. Unless this is a continuation of your another issue, could you give us something to work with?

1. Strategy or an "as-small-as-possible" sample code that demonstrates the anomaly. If you're using a un-modified public Strategy, the name is sufficient.
2. Wealth-Lab tool in use (Strategy Window, Strategy Monitor)
3. Single symbol or Multi-symbol mode, Position Sizing, and Data Loading settings
4. Options (F12) > Backtest settings
5. Symbol(s) and Data provider
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).