Compound profits when account doubles(Solid Compounding strategy in my Opinion)

Hi All

I have been trying to run backtest in Amibroker for EURUSD to compounds profit when account doubles but dont know where to start and which settings to use...For example , we are trading a $10,000 account with 1lot and the account doubles to $20,000 .So now we will trade 2lots in the $20,000 account and when $20,000 doubles to $40,000 we will trade 4lots and so on in that order.. So anytime we double the account , we increase the lot size by 2 ..How can I run this kind of backtest in Amibroker?Can anyone point me in the right direction please..I am quite sure this will help a lot of traders make more profit backtesting and trading their system since compounding profits in my opinion is what can grow an account exponentially when done right...I will be very glad if someone can point me in thee right direction.Thank you and green pips to you.

You thought about what will happen if your account doubles, but what will happen if your account goes DOWN? Did you envision such possibility?
What is the leverage you are using? If it is 1:100 (typical forex), then you would use

SetPositionSize( 1, spsPercentOfEquity ); 
RoundLotSize = 1; 

you would also need to set proper margin deposit and other things as explained here

yes I envisioned the DD when the account goes down that is why i always like to keep my DD as low as possible..Leverage i am testing with is 1:500 ..Thanks for the tip ..I will try the code you sent me and see how it goes.Thanks once again for the tip.