Im hoping someone can assist me with a problem I am having trouble solving, I should mention I am developing a system for forex trading, and I am trying to get the system to work on during backtesting and walk forward testing.
I am having some difficulty achieving the desired results in coding a money management system. This basic issue that I have is that I cant access the account balance or available equity to dynamically adjust the lot size. At present I have been cycling through the trade history, to collect the result of the last trade and then either subtracting or adding the result to a running balance variable.
Here is an example of what I am currently running.
if(Performance.AllTrades.Count!=last_number_of_trade s)
{
last_number_of_trades++;
running_balance += (Math.Round(Performance.AllTrades[last_number_of_trades-1].ProfitPoints,4)*(1/TickSize))*pip_value;
}
if(Performance.AllTrades.Count==0)
{
running_balance = account_start_balance;
}
I also you a File.AppendText snippet further on that allows me to print a log of each trade, the results, profit/loss, and the running balance ect...
The problem is that I have defined the account start balance at $10,000. When the strategy is finished back testing I review the performance report and the result is something like -8000 which is fine because im working on the money management not the trade logic, but the log I have printed shows that the running balance falls from $10,00 to $8,000 a drop of only 2000. Why is this happening?
Is there some way that I can define the account balance at the start of the back test, so that I don’t have to go through this process of cycling through the trade history after each trade to collect the results? I am aware of AccountSize, however will this result in the system discarding my dynamic lot sizing and simply allocate a lots based on the defined margin requirements for the instrument and the account size? I have tried GetAccountValue but this doesn’t work, can I ask what its purpose is if it cant be back tested?
Also is there someway that I can get the available equity if I was to consider opening another position? It needs to work in back testing though.
Finally, in the instrument manager, if I was define EUR/USD margin requirements as 200, given that I intend to trade with FXCM Australia who over 200:1 leverage. Would this be the correct setting? Would the backtest respect this value, so that if I already had one lot open, it would understand the available margin not simply the account value. If I adjust the point value to 1, would this be the value of 1 dollar traded which has moved one pip? For example one standard lot of 100,000 has a value of 10 dollars for each pip, whereas a mini lot of 10 000 has a value of 1 dollar for each pip. So to replicate these conditions do I need to set the point value to 0.0001, so that in back testing a mini lot of 10000 would earn 1 dollar for each pip movement?
I have included the code im working with, its nothing fancy but it may give you a better understanding of what I have tried so far.

Comment