I have set up only one use for each transaction
SetPositionSize( 1 , spsShares ) ;
But backtesting, there will still be a contract number of 0.699999, I do not know how to amend it
I have set up only one use for each transaction
SetPositionSize( 1 , spsShares ) ;
But backtesting, there will still be a contract number of 0.699999, I do not know how to amend it
Turn OFF "Allow position shrinking" option
i am already turn off the position size shrinking
or any other place to turn off it
You may be turning this option ON in your FORMULA using SetOption call. Whatever is set in the formula takes precedence. You did not post entire formula. Without formula you are playing guessing games with us. But we don't play guessing games. Also if you don't want fractional shares you should be setting round lot size to 1.
I have similar problem.
All below is for EURUSD.
general condition:
SetOption("AllowPositionShrinking",True);
SetOption("FuturesMode", 1);
SetOption("InitialEquity", 100000);
SetOption("InterestRate",0);
SetOption("MinShares", 0.1);
SetOption("PriceBoundChecking", false);
SetOption("UsePrevBarEquityForPosSizing", True);
SetOption("AccountMargin",100);
PointValue = 100000;
Ticksize = 0.00001;
SetPositionSize (1.2,spsShares);
RoundLotSize = 0;
Buy = 1;
Sell = 1;
BuyPrice = 1.15600;
SellPrice = 1.15700;
Short=Cover=0;
For what is above I've received contracts quantity = 1.199951.
..but ,when I've changed:
SetPositionSize (1.2,spsShares);
RoundLotSize = 0.1;
I've received ----> 1.1 Contracts.
and next when if changes:
SetPositionSize (1.2,spsShares); RoundLotSize = 0.1; ---> I got 1.1 contract
SetPositionSize (1.3,spsShares); RoundLotSize = 0.1; ---> I got 1.3 contract
SetPositionSize (1.4,spsShares); RoundLotSize = 0.1; ---> I got 1.4 contract
SetPositionSize (1.5,spsShares); RoundLotSize = 0.1; ---> I got 1.4 contract
and if RoundLotSize is 0:
SetPositionSize (1.2,spsShares); RoundLotSize = 0.1; ---> I got 1.199951 contract
SetPositionSize (1.3,spsShares); RoundLotSize = 0.1; ---> I got 1.300049 contract
SetPositionSize (1.4,spsShares); RoundLotSize = 0.1; ---> I got 1.400024 contract
SetPositionSize (1.5,spsShares); RoundLotSize = 0.1; ---> I got 1.5 contract
SetPositionSize (1.5,spsShares); RoundLotSize = 0.1; ---> I got 1.599976 contract
....and as I checked SetOption("AllowPositionShrinking",False/True); has no impact for this problem.
Where is the problem?
Any idea please ?
I suggest you start by reading about floating point math in AmiBroker: http://www.amibroker.com/kb/2010/07/20/about-floating-point-arithmetic/
Thanks, but it doesn't solve any problem.
like below:
SetPositionSize(1,spsShares);RoundLotSize=0; result: contract 1- Profit is 371,50 - ok
SetPositionSize(1.1,spsShares);RoundLotSize=0; result: contract 1.09.. Profit is 408,65 - ~ok
SetPositionSize(1.1,spsShares);RoundLotSize=0.1; result: contract 1. Profit is 371,50 - not ok (should be 408.70)
... I can stay with this SetPositionSize(1.1,spsShares);RoundLotSize=0; Profit's difference is not high but I can't round position size x0.1 (as I would like ---> RoudLotSize=0.1)
As @mradtke told you, decimal fractions often are subject to rounding as per IEEE rules and spsShares mode is intended to be used for integer number of shares / contracts (as typically share/contract is not divisible, except mutual funds).
The solution to your problem is not using fractional number of contracts, but using SMALLER contracts. If you changed your PointValue to 10000 (10 time less than you have) you will be able to use 12 small contracts. See http://www.amibroker.com/kb/2006/08/09/amibroker-for-forex/
PointValue = 10000; // SMALL contract
SetPositionSIze( 12, spsShares ); // 12 small contracts
Thank You, but....
...it introduces some confusion to my live.
I would like to take PointValue from my broker and put it to afl without any modification.
...but If there is no easier way it's ok for me.