- ago
This strategy generates many signals per candle for the dataset. When I decrease starting capital, closing trades count falls, but not opening signals count.

Is it a bug or can I control this?




0
411
Solved
18 Replies

Reply

Bookmark

Sort
Cone8
 ( 25.05% )
- ago
#1
Another case of NSF (Not Sufficient Funds).
All Signals will be generated (always). Whether or not your portfolio can enter those signals depends on its buying power.

Case in Point -
You have 190 limit orders for tomorrow. Which of them are going to fill?
Answer: If we knew, we'd be rich
0
- ago
#2
Thanks Cone. I'm not sure you got it right), so some more details and usecase:

- These orders are waiting in the orderbook. Triggering orders (with Quotes window) is not appropriate in this case.
- Russian brokers do not allow to send unlimited orders (but according to your money and leverage).
- I need these orders to be sent according to "starting capital" value as the limit for total sum of sent order values. And according to weights. So in screenshots example - it's 3 orders (three top orders - as they are sorted by weight).
- I don't need those other opening orders to be nor sent nor executed! Just these 3. I need all opening order just to sort by weight to get top.


In these example (screenshots) - there are 2 closing signals not because I've thrown 200 signals and only 2 positions were opened. When I change Starting capital it behaves like this now:

15K starting capital 5K per orders: 190 opening orders, 2 closing orders.

150K starting capital 5 per order: 190 opening orders, 25 closing orders.

I expected it to be:
15K starting capital 5K per orders: 3 opening orders, 2 closing orders.

150K starting capital 5 per order: 30 opening orders, 25 closing orders.

So it looks like on every candle but the last it behaves like I expect (closing order count says that and the way it changes with starting capital changing). But the last does not "listen" to starting capital value at all).

Anyway wheather it's a bug or not, I've described my usecase, maybe you could suggest something.
0
- ago
#3
Maybe if I try to place them all (190), only first 3 (by weight) will be executed if starting capital is set to 15K and order value is 5K?
0
Cone8
 ( 25.05% )
- ago
#4
We both think the other misunderstands :)

Weight is not an option for limit or stop orders. The only valid weight is the time-of-day that the price crosses a limit/stop trigger - that's how the granular backtests work.

Aside:
Unless you explicitly set a transaction weight, Wealth-Lab will assign one that is random.
I suspect this is the case since these are all values between 0 and 1.

What you need to do is to send those orders to the Quotes tool and allow it to trigger the limit orders when they become marketable (or just before by making the trigger percent less than 100%). If you do that, a granular backtest will mirror real-life trading.
1
- ago
#5
QUOTE:
Unless you explicitly set a transaction weight, Wealth-Lab will assign one that is random. I suspect this is the case since these are all values between 0 and 1.

What you need to do is to send those orders to the Quotes tool and allow it to trigger the limit orders when they become marketable (or just before by making the trigger percent less than 100%). If you do that, a granular backtest will mirror real-life trading.


No, those [0:1] values are all mine)). It is brobability).
Ok thanks, I'll try Quotes!
0
Cone8
 ( 25.05% )
- ago
#6
Here's a quick demo queued up to part where the order triggers at 90% and Auto-Places it to the broker account

https://youtu.be/lioCWPVg-uQ?t=148
1
Best Answer
- ago
#7
I'm back with some questions after trying Quotes.

Lets come back to Strategy Monitor. So when I set Starting Capital in Strategy Settings, it affects how many trades will be opened, I thought if I set 15K capital and 5K values, this means that most weighted 3 will be send on every candle. But works like all of them will be sent, but first triggered will be executed. Ok, now I know how it works.

Quotes doesn't help me as it looks at price only, not weight.


So let's talk about my use case, maybe it needs an extra feature request or can be handled using current features.


So, your Stratgy Monitor (and backtester, I guess) does not look at limit orders' weights that are set in strategy at all, rights. But I need only my most weighted limit orders to be sent (and executed if I'm lucky). So in your logic - the first to be triggered are the best, others are dummies. In my logic - I don't want orders with low weights to be triggered (or even sent) at all. You may say: you set this weight, why don't you just not generate such orders. The problem is I need TOP weighted orders to be sent, the number of order is known (starting capital / order value), but the strategy doesn't know wheather this order is in top or not (as you should know other orders' weight for that).

I tried to supress orders at the moment all the orders are known (in BacktestComplete() or something), but isActive property is read only)). So if I could supress orders in this way - that would be a good desision for me.

Or maybe I could create a feature request for Strategy Monitor to listen to orders' weights. Or maybe you could suggest something else.


Once again: My weights for limit orders reflect how much I want exact order to be executed. I whant only top weighted orders to be sent to order books. I don't want out-of-topers nor be sent nor executed. When setting a weight in the strategy I don't know wheather this weight is big enough to be in the top. I fully understand that not every order among the top will be triggered. And I want my orders from my top to be armed all the time.


Sorry for such a big non native English text)
0
- ago
#8
I think I can use custom PositionSizer for this, can I?

From custom PositionSizer docs (https://www.wealth-lab.com/Support/ExtensionApi/PositionSizer):

QUOTE:

A List of Transaction instances that contains the orders that have already been sized and processed on this bar of processing.

public List<Position> OpenPositions
A List of Position objects that contains the positions still open in the simulation.

public List<Position> ClosedPositions
A List of Position objects that contains the positions that have already been closed in the simulation.

public List<Position> Positions
A List of Position objects that contains all positions, open and closed, in the simulation.

public List<Transaction> Candidates
A List of Transaction instances that contains all of the signals that are being processed (sized) on this bar of the simulation.

One of these can help to find out how many orders were generated (and see their weights) for this bar, right?

Still, can I only set quantity or maybe I can suppress orders here? At least I can set zero Quantity, I guess...
0
- ago
#9
Yes, you should be able to leverage PositionSizer to filter out signals based on their Transaction.Weight. Initially we researched such option but it's not on the drawing board currently.
1
- ago
#10
QUOTE:
Yes, you should be able to leverage PositionSizer to filter out signals based on their Transaction.Weight. Initially we researched such option but it's not on the drawing board currently.


Great! Is there a way I can suppress orders I don't want to be sent... rather than setting Quantity to 0? I mean it was generated by the strategy, but I have this kind of postprocessing to delete/suppress some of them.
0
- ago
#11
QUOTE:
rather than setting Quantity to 0?

That's the idea.
1
- ago
#12
Ok, I'll make a custom PositionSizer for this then. At least I'll try to).

There is an example, so I guess it's possible for non native programmer).


P.S. If you remember how to do it easier, please share).
0
Cone8
 ( 25.05% )
- ago
#13
QUOTE:
Quotes doesn't help me as it looks at price only, not weight.
You're trading a limit system. The ONLY weight that is valid is inverse Time-Of-Day. Now, you could make it so that your system only enters the 3 limit orders with the greatest (or smallest) weight. That's different altogether.


QUOTE:
So in your logic - the first to be triggered are the best,
It's not "my" logic. It's typical limit order strategy logic.


QUOTE:
I tried to supress orders at the moment all the orders are known
A PosSizer isn't required for this. Just do it in PreExecute. Sort the signals there and place only the limit orders you want to go live.

For trading Quotes is still a good way to auto-trade the signals.. just send the orders you want to trigger.

1
- ago
#14
QUOTE:
It's not "my" logic. It's typical limit order strategy logic.

Typical doesn't mean good), I don't like anything typical). Especially in trading where losing money is quite typical actually)).

Ok, thanks Cone. I get what I need on this iteration (I'll try PreExecute first). So I'll keep on moving forward.

But if you want to keep on discussing limit strategies, I'm here).
0
- ago
#15
QUOTE:
A PosSizer isn't required for this. Just do it in PreExecute. Sort the signals there and place only the limit orders you want to go live.

So, I need help, again), much appreciated.

I used Signals prperty. But in PreExecute() it's always empty, so mayby you mean PostExecute()?

In PostExecute() there are signals in this collection. I could sift orders according to weight, I also could set Quantity == 0 to orders I don't want to be placed.

What I get as a result: in Strategy Monitor some orders were with 0 Quantity, some - with non 0. Then I tried to Place orders of both groups. But all of them were placed as a result. Those with 0 were placed with 1 in Quantiny - I think it's Quik (Russian Extension) broker provider that does this? Anyway this method of marking orders does'nt work by now. I also tried to find something else - IsActive and OrderStatus - were read only, IsNSF was the only one that looked relative but was not read only. It marked orders but did not affect being sent.

I also tried things like this:
Signals.Clear() and then Signals.Insert() inserting only signals needed - no effect. I also tried Signals.Remove(), Signals.RemoveAt() - no effect, the same orders number.


What am I doing wrong or what else can I try? Much appreciated.
0
- ago
#16
If there are options. Being able to delete orders I don't want to be placed would be a better option, rather than setting 0 quantity or something. As this spams the dashboards.
0
Cone8
 ( 25.05% )
- ago
#17
As we say, "there's more than one way to skin a cat." So, sure, you can do this in PostExecute too. Your comment about removing orders, reminded me of one of Glitch's posts that does precisely what you're looking for (I think). Check it out here -
https://www.wealth-lab.com/Discussion/Using-Spread-Equity-Equally-sizer-after-signals-prioritizing-6732
0
- ago
#18
Thanks Cone, let the new iteration begin!)
0

Reply

Bookmark

Sort