PosSizer: how to identify signal generated by Strategy
Author: Rebelion
Creation Date: 4/23/2013 4:10 PM
profile picture

Rebelion

#1
Hello, guys.

I have a question - I need to know how to identify a last signal generated by the strategy on the current bar + 1?
I tried to use Position[Position.Count - 1].ExitBar == reflectingBars - 1 and Candidates[Candidates.Count - 1].EntryBar == reflectingBars - 1, where lastbar I get from the reflecting like this:

reflectingBars = (Bars)f.GetType().GetProperty("Bars").GetValue(f, null);

But it's not working correct sometimes when I use renko class...

profile picture

Eugene

#2
Try assigning a Position.Tag in your Strategy, and reading it back in the PosSizer. Since Position is null for Alert sizing, this works for historical backtests; for Alerts, here's a workaround: How to pass a value from Strategy to PosSizer for Alert sizing?

Note that in 6.4, the Candidates list is empty for Alert sizing at Bars.Count (but functions as advertised in historical backtests) - live bug 62853.

If your problem was different, please rephrase your question.
profile picture

Rebelion

#3
Sorry, Eugene, It was badly formulated question...

I have the same problem: I need to pass out the signal, generated on the current minute bar (using bar+1 in BuyAtMaket and SellAtMarket). But I really cannot understand how can I check this correct. I tried to use something like this:

CODE:
Please log in to see this code.

and
CODE:
Please log in to see this code.


as a main conditions for detecting, where reflectingBars - Bars object I took via reflection.
But sometimes I got 3-4 signals, sometimes I got no signals (but It was always worked correct on the charts when I used strategy.

CODE:
Please log in to see this code.


This is dummy code I using now (need to understand a logic of trades identification on the last bar).
What's the better way to write correct code I need?

Thnxs a lot, guys.
profile picture

Eugene

#4
As told in my reply, the Candidates collection is N/A in Version 6.4: it's empty for sizing Alerts. You can not use it for your task until it's fixed in WL 6.5.

Alerts on bar+1 always have their Position property null. This is how you can tell that an Alert is being processed, as opposed to a historical backtest position.
profile picture

Rebelion

#5
Sorry, Eugene, but It's so strange - I have Candidates filled each time PosSizer method called... And have a filled (probably correct - now trying to understand)...
profile picture

Eugene

#6
The Candidates list exists on each bar of the simulation, and works correctly for historical trades. But check its composition on bar == Bars.Count (i.e. sizing Alerts): unless there's something I don't know, it's broken in 6.4.
profile picture

Rebelion

#7
Other question, Eugene - why sometimes (I using streaming mode, checked this through reflection) I get "null valued" currentPos? And ExitBar for Positions is also equal to -1.

Thnxs. Sorry for my stupid questions, but I'm pressed of time in my signals interceptor realization. :-( And can't fully understand the work logic of this method via the documentation. :-(
profile picture

Eugene

#8
As already mentioned in my reply #4, Alerts on bar+1 always have their Position property null. When the PosSizer is called to size Alerts when bar == Bars.Count, there is no Position. That's the answer to your question why sometimes currentPos == null.