Hi to all,
may I ask for your help with the following
code.
The positionsize does not behave as it should.
I am trying to
buy "100" at first occurence of buy
signal and when scalein condition
appears (drawdown),
I want to buy "100000", but backtester does set
positionsize sometimes right and sometimes not,
e.g. it buys "100000",
even if it´s the first occurence
of buy signal, or buys "100", even if
it´s a scalein
signal. But sometime backtester does it correct. I
just
don´t get it. Initial equity in backtestersettings
is 1,000,000, so this
should be no problem.
Thanks for any help finding what is wrong with
the
code.
Regards
robert
******************************************************************
Plot(Close,"",colorwhite,132);
Buy
= Buycondition;
Sell =
C<0;
ApplyStop(stopTypeProfit,stopModePoint,0.0030,1,False,1);
ApplyStop(stopTypeLoss,stopModePoint,0.0080,1,False,1);
e
= Equity(1);
PyramidThreshold = 0.1;
PcntProfit =
100*(e-ValueWhen(Buy,e))/ValueWhen(Buy,e);
InTrade =
Flip(Buy,Sell);
DoScaleIn = ExRem(InTrade AND
PcntProfit<-PyramidThreshold,Sell);
Buy = Buy + sigScaleIn *
DoScaleIn;
PositionSize =
IIf(DoScaleIn,100000,100);
******************************************************************