Adding rebate to AccountBalance()

 

Hi

I've recently opted for a rebate in my trading. I get a rebate of $0.90 per lot traded for my ECN account.


I want to incorporate the rebate in my code for back testing purposes. The rebate is deposited in my Trading account on the 10th of each month

so when I do my back testing I'm going to add the rebate to the account balance on the 10th of each month.


After I work out the rebate for the month how do I add this rebate to the account balance? I've tried;

AccountEquity() += rebate;

AccountBalance() += rebate;

and neither will allow me to do it, as these functions I assume are to obtain information only.

Thanks in Advance

Donex

 
Donex:

Hi

I've recently opted for a rebate in my trading. I get a rebate of $0.90 per lot traded for my ECN account.

I want to incorporate the rebate in my code for back testing purposes. The rebate is deposited in my Trading account on the 10th of each month

so when I do my back testing I'm going to add the rebate to the account balance on the 10th of each month.

You cannot do it, there is no facility to change the account balance during the Strategy Test run.
 

would it not be possible to start Strategy tester with a much larger balance, (to avoid margin call),

and then change all EA moneyManagement functions to use custom customAccountBalance/customAccountEquity/FreeMargin functions, when deciding lot/SL sizes?

 
RaptorUK:
You cannot do it, there is no facility to change the account balance during the Strategy Test run.


Thx for the reply, I thought that might be the case, but was hoping against hope.
 
ydrol:

would it not be possible to start Strategy tester with a much larger balance, (to avoid margin call),

and then change all EA moneyManagement functions to use custom customAccountBalance/customAccountEquity/FreeMargin functions, when deciding lot/SL sizes?


Thx for the reply, but I don't understand how this will help my issue.
 
Donex means that you may start with a balance of 15,000 to avoid margin calls but use a pseudo balance of 10,000 and use this for your calculations. Add profit to the Pseudo balance and subtract losses. Add your rebate to this balance and print it off at the end.
 

Exactly - I was thinking something like ?

double fakeStartBalance=0;    // This will be set to the fake balance.
double realStartBalance=3000; // Set this to your real account size.
double totalRebates=0;

init() 
{
        // Get the starting BIG balance
        if (fakeStartBalance == 0) fakeStartBalance = AccountBalance();
        
}

double realBalance()
{
        return (realStartBalance + totalRebates - (fakeStartBalance - AccountBalance()) );
}
double realEquity()
{
        return (realStartBalance + totalRebates - (fakeStartBalance - AccountEquity()) );
}

// Call this function to add credit to your account
void addCredit(double x)
{
        totalRebates += x;    
}

// Now Replace all OTHER calls to accountBalance() with realBalance() etc.


Or wont this work? If it does, You will probably want to add some additional checks to correctly detect Margin Call/Blown account etc.
 
Just though you probably want to add IsTesting() check in those functions !
double realBalance()
{
        if(IsTesting()) 

            return (realStartBalance + totalRebates - (fakeStartBalance - AccountBalance()) );
        else
            return (AccountBalance());
}
 

Thx for the help, will give it a go.


cheers

 

I still think this solution won't give me the result I'm looking for.

I really need the account balance incremented by the rebate to see the affect of the dynamic risk during the testing. Eg, if I risk 1.6% of the account balance per trade, the compounding of the rebate on the account balance will affect the final result.


The only other way I can think of achieving this would be a tedious but affective way.


I will have to watch the market in visual mode on the 10th of each month for whatever year I'm going to test and find an area where the market moves for eg, 5 - 10 pips in one direction

I will then hard code 12 orders for those dates and times where I'm guaranteed a 5 pip win and make sure I have calculated the correct lot size to send to those orders. and the profit for those trades will be equivalent to the rebate for that month. I will also

make sure I don't add the lots for these orders to the lotSizeTotal for working out the rebate. The profit will be added to the Account Balance each month as if it were the rebate.

The only problem I can foresee for this strategy is that the overall stats will be a little skewed, although I will know that. I only want to see the difference in the profit/loss with the rebate and without the rebate so the other stats don't really matter.


Greatly appreciate the feedback and suggestions. Any other suggestions are still greatly welcomed.

 
Donex:

I still think this solution won't give me the result I'm looking for.

I really need the account balance incremented by the rebate to see the affect of the dynamic risk during the testing. Eg, if I risk 1.6% of the account balance per trade, the compounding of the rebate on the account balance will affect the final result.

Why not simply adjust the dynamic risk profile to use the sum of AccountBalance() and the cumulative rebate?

Lets assume that: AccountBalance = $1200.00; CumulativeRebate = $50.00; and RiskPercent = 1.6%.

The sum of AccountBalance and CumulativeRebate is $1250.00, and $1250.00 x 0.016 = $20.00.

So, your risk profile in dollars is $20.00, which, as a percent, represents ~1.6667 of AccountBalance.

Accordingly, your RiskPercent would be adjusted to 1.6667%.

The above values should be recalculated for each prospective trade.