fred99998
 ( 20.51% )
- ago
I want to clarify. Is it true that when placing the "Basic Price" -- "Market Open next bar" during a portfolio backtest should have enough money to open a position even with a gap at the next session opening?

In my portfolio backtest, many transactions are not executed, for example, with this configuration.



But if increase the margin, for example, to 1.2, then missed trades appear
0
639
Solved
12 Replies

Reply

Bookmark

Sort
Glitch8
 ( 11.74% )
- ago
#1
Think about it Fred. You're setting position size to 100% of equity and trading 30 symbols. What if two or more symbols trigger a buy on the same bar?
0
fred99998
 ( 20.51% )
- ago
#2
I understand that the ticker must be chosen randomly. But I set the weight, so everything is clear here.
0
fred99998
 ( 20.51% )
- ago
#3
That is, this is not a bug in the program and it should be so? Then what is the difference between the choice between "Market Close this Bar" and "Market Open this bar" if in any case the gap at the opening of the session does not allow opening positions?

Or does it only work on a single symbol and not on a portfolio?
0
Cone8
 ( 6.71% )
- ago
#4
Explained in Help > Strategy Settings > Basis Price
0
fred99998
 ( 20.51% )
- ago
#5
Okay, read help:

QUOTE:
By changing the Basis Price selection to Market Open next Bar, you can practically eliminate NSF Positions due to price gaps.


To check, we create a simple strategy:



We receive signals for May 25th.



On May 25, at the opening of the session, we must sell the GS and buy the MCD instead.



Now we are testing the system until the end of May



And we see that the GS was sold on May 25, but the MCD was not bought. Apparently, because there was not enough money due to the gap, despite the settings of the "Basic Price":



And the backtest result does not correspond to real trading





0
Cone8
 ( 6.71% )
- ago
#6
2 more concepts for you to read about:
1. NSF Positions, and,
2. Transaction.Weight

In short, if you don't assign a t.Weight and there are NSF positions, the hypothetical positions taken by the backtest will be random - different nearly every run.

You can work with the "Live Positions" Trading Preference only in the Strategy Monitor or a Streaming Chart.
0
fred99998
 ( 20.51% )
- ago
#7
QUOTE:
if you don't assign a t.Weight and there are NSF positions, the hypothetical positions taken by the backtest will be random - different nearly every run.


And what's that?

0
Cone8
 ( 6.71% )
- ago
#8
Sorry, I'm skipping around so missed the beginning. I'll run the backtest and let you know what I find...
0
Cone8
 ( 6.71% )
- ago
#9
The problem appears to be due to a high precision comparison error. For now, if you set the margin to anything greater than 1, even 1.0000000001, you'll get the trade. I'll try to fix that for Build 36, which I think will finally be ready next week with Multi-Currency!
0
Cone8
 ( 6.71% )
- ago
#10
I looked at this in more detail. What's happening is:

1. the MCD share basis (Transaction.Quantity) is calculated by dividing the closing equity on 5/24 ($95,816.33731) by the opening price the next day (286.85).

2. Transaction.Quantity = $95,816.33731 / 286.85 = 334.029 => 334

3. However, GS opens on 5/25 and is sold at $318.92, a price $1.47 less than the previous close, $320.39.

4. That causes buying power to drop by the GS share quantity (299) * 1.47 = $439.53, which leaves $95,376.81

5. However, the transaction for MD requires 334 *286.85 = $95,807.90, which is more than the buying power => NSF position.

This is why the Help states, "you can practically eliminate NSF Positions due to price gaps." In other words, price gaps for the trade symbol won't cause an NSF position, but it's a portfolio backtest, so other things are going on too.

Bottom line -
Do realistic backtests. Don't rely on 100% Equity and Market Open Basis. You can't trade that way anyway. Use a little margin or drop size to 98% or even 95%.
0
Best Answer

Reply

Bookmark

Sort