Trade.Shares is a decimal number?

Hi, If I set the position size as…

for( sig = bo.GetFirstSignal( i ); sig; sig = bo.GetNextSignal( i ) )
    sig.PosSize = PosSize;

Where ‘PosSize’ is a positive number, why, when doing a ‘CustomBacktest’, am I seeing decimal values of ‘trade.Shares’ - I was only expecting whole numbers of shares?

In the custom backtest I have…

_TRACE( trade.Symbol + " - EntryPrice: " + trade.EntryPrice + " - Shares: " + trade.Shares);

and in the log I see values like this…

IP - EntryPrice: 49.74 - Shares: 345357.4
IPG - EntryPrice: 24.12 - Shares: 303690.3
IR - EntryPrice: 74.67 - Shares: 250839.2

Just discovered the ‘RoundLotSize’!

Good discovery :slight_smile: … Keep in mind that AmiBroker is universal and handles also other instruments than stocks, like mutual funds that allow fractional units.

Am I right in saying there’s currently no way to set this globally in the AFL code? - I see it’s a property of the ‘trade’ objects.

No, you’re wrong. I find it surprising that people can’t do a simple search. If you just used google you would find that easily, click here:

Second result in Google search result list, Tutorial section of manual:

RoundLotSize = 1; // is that really that hard to find?

Entire Tutorial from manual is a MUST READ for every user.

I apologise for failing to find it, but searching the forum and help failed to locate it, next time I’ll have to remember to search using google.

As for the link to the tutorial, ‘’ I’m currently getting a 404.

I typed too fast the link should be

BTW: Users' Guide search (Help->Search menu from AmiBroker) return very same thing as first item in the result list: