Reply

Money Management Bug buys lots > account balance

1 replies

Travis Silvers

Subscriber, bbp_participant, customer, community, sq-ultimate, 3 replies.

Visit profile

3 months ago #284916

Using the builder something goes wrong and strategies are generated which buy the max lot size which exceeds the account balance.

Ex. Using Stock Size by Price, with $25,000 starting capital and a max lot size of 10,000 the strategy will BUY 10,000 lots at $60.52 which exceeds the $25,000 purchase power.

1. This does not happen to all strategies

2. Sometimes only the first BUY will be at the max lot size.

3. I suspect this has to do with the order type, price calculation indicator, but haven’t confirmed.

I’ve attached an example strategy with this weirdness going on. I’m happy to simplify the money management in the short term if that stops the bug / invalid lot size.

Attachments:
You must be logged in to view attached files.

0

Travis Silvers

Subscriber, bbp_participant, customer, community, sq-ultimate, 3 replies.

Visit profile

3 months ago #284933

This is definitely a bug. Looking at the built function for Tradestation:

[code]{

IntPriceLevel = Round2Fraction((SQ_FractalDown(5)[2] + (PriceEntryMult1 * (SQ_BollingerBands(Close, BBRangePeriod1, 2, 0)[0]-SQ_BollingerBands(Close, BBRangePeriod1, 2, 1)[0]))));

}[\code]

We can see that the IntPriceLevel is set using a generated value without limits or checks, theoretically then the limits and checks need to be performed on the function which consumes the value.

We can see later the NumberOfShares to purchase is set via this code:

[code]{

If UseMoneyManagement Then NumberOfShares = SQ_StocksSizeByPrice(IntPriceLevel,mmUseAccountBalance,mmMaxSize,InitialCapital,mmMultiplier)

}[\code]

The IntPriceLevel appears to not be the correct value to use for SQ_StocksSizeByPrice call vs the captial / balance and appears to incorrectly determine the stock size.

In order to avoid this error being created in the builder we need to either:

  1. Adjust the entry blocks used
  2. or only use Market entry order types.

The Market entry order types (what I did and have verified) is hinted as a work around in the StocksSizeByPrice_method.tpl file which is responsible for the code generation of that block. On line 3 we see that the first parameter to SQ_StockSizeByPrice is either Close or IntPriceLevel based on if the order type is MARKET:

[code]{

SQ_StocksSizeByPrice(
<#if orderType == “MARKET”>Close<#else>IntPriceLevel</#if>,
mmUseAccountBalance,
mmMaxSize,
InitialCapital,
mmMultiplier
)

}[\code]

Hence only using MARKET Order Types should prevent this problem from appearing.

**THIS IS ONLY A WORK AROUND**

The developers should absolutely fix SQ_StocksSizeByPrice to be limited by actual price values and account balance.

0

Viewing 1 replies (of 1 total)