1 (edited by tezas 2017-08-16 19:07:33)

Topic: Issue-different FSB results vs own calculation

I have sometimes different results from FSB than from other sources. I provide an example below to illustrate with an example strategy (for simplicity, with no charges and costs).

The idea is to be 100% invested with no leverage. The account settings are 1/1 leverage, the Edit Instrument seettings are 2 digits and lot size 100, and the Strategy properties are 100% invested (in % of invested capital selected, as opposed to constant number of lots), with max. Number of lots = 100.

However, the FSB provides different results than foreseen - I made a calculation of the discrepancies s in Excel (attached). The difference stems from the fact that FSB sometimes „overinvests” (buying more lots than 100% engagement would allow), and sometimes „underinvests” as compared to the „100%” plan..

What should I do to correct it? I know the solution may be very simple, but I could not bypass this.

I attach the strategy, the instrument data and the calculation. Please help!

Post's attachments

mine vs FSB results-test1.xlsx 41 kb, 1 downloads since 2017-08-16 

You don't have the permssions to download the attachments of this post.

Re: Issue-different FSB results vs own calculation

... the data...

Post's attachments

WIGDWA1440.csv 235.92 kb, 1 downloads since 2017-08-16 

You don't have the permssions to download the attachments of this post.

Re: Issue-different FSB results vs own calculation

... and the strategy (used only to find the reason for the difference, almost 'buy and hold' otherwise).

Post's attachments

TESTING DATA ONLY-1.xml 14.84 kb, file has never been downloaded. 

You don't have the permssions to download the attachments of this post.

Re: Issue-different FSB results vs own calculation

It's late, so I will check tomorrow, but possibly the problem comes from Floating P/L - I see if that issue disappears if I change the opening point to Day Closing as opposed to Day Opening.

Re: Issue-different FSB results vs own calculation

Here is how FSB Pro calculates the Required Margin, Trading Size, Normalized Trading Size and Account Exchange Rate.

        private double RequiredMargin(double lots, int bar)
        {
            var amount = lots*DataSet.Properties.LotSize;
            var exchangeRate = DataSet.Close[bar]/AccountExchangeRate(DataSet.Close[bar]);
            var requiredMargin = amount*exchangeRate/Profile.Leverage;

            return requiredMargin;
        }

        private double TradingSize(double size, int bar)
        {
            if (Strategy.UseAccountPercentEntry)
            {
                var maxMargin = Session[bar].Summary.MoneyEquity*size/100.0;
                var exchangeRate = DataSet.Close[bar]/AccountExchangeRate(DataSet.Close[bar]);
                size = maxMargin*Profile.Leverage/(exchangeRate*DataSet.Properties.LotSize);
            }

            return NormalizeEntryLots(size);
        }

        private double NormalizeEntryLots(double lots)
        {
            if (lots <= 0)
                return 0;

            var minlot = DataSet.Properties.MinLot;
            var maxlot = Strategy.MaxOpenLots;
            var lotstep = DataSet.Properties.LotStep;

            var steps = (int) Math.Round((lots - minlot)/lotstep);
            lots = minlot + steps*lotstep;

            if (lots < minlot)
                return 0;

            return lots > maxlot ? maxlot : lots;
        }

        private double AccountExchangeRate(double price)
        {
            double exchangeRate = 0;

            if (DataSet.Properties.PriceIn == Profile.AccountCurrency)
                exchangeRate = 1;
            else if (DataSet.Properties.InstrType == InstrumentType.Forex &&
                     DataSet.Symbol.StartsWith(Profile.AccountCurrency))
                exchangeRate = price;
            else if (Profile.AccountCurrency == "USD")
                exchangeRate = DataSet.Properties.RateToUSD;
            else if (Profile.AccountCurrency == "EUR")
                exchangeRate = DataSet.Properties.RateToEUR;
            else if (Profile.AccountCurrency == "JPY")
                exchangeRate = DataSet.Properties.RateToJPY;
            else if (Profile.AccountCurrency == "GBP")
                exchangeRate = DataSet.Properties.RateToGBP;

            return exchangeRate;
        }

Re: Issue-different FSB results vs own calculation

Thank you! I have corrected my calculation.