I try to manage the following scenario through a formula in amibroker:
my system/strategy has a fix StopLoss of, let's say 30 points/pips, and I risk a certain pecentige of equity each trade(2%). Therefore it's necessery to have an adapting position size.
How can I achieve this?
In help , look for SetPositionSize (spsPercentOfEquity)
Yes, I tried this out already.
SetPositionSize (2, spsPercentOfEquity);
But with the 'initial equity' of '100000', in the backtest, each positions that hit the StopLoss, caused a loss of ~27.00, wich is not 2% of the initial equity. Also in the further course of the backtest the individual losses decrease, while the equity increase!?
That statement is setting your entire position size to 2% of equity. To use the risk as a percentage of equity, you may want to start here: http://www.amibroker.com/kb/2014/10/12/position-sizing-based-on-risk/
I think I got this. But I want it for optimization purposes. So if I want to optimize my Stopploss, so I had to implement the 'Applystop' (stopTypeLoss) as a pointbased variable value in HERE:
PositionRisk = 2;
TradeRisk = *HERE*
PctSize = 100 * PositionRisk / TradeRisk;
Hope that make sense. Is that possible?