[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bug in sellprice for some stocks



PureBytes Links

Trading Reference Links

Tomacz,

> The problem is that sellprice array is not for storing
> targets. Sellprice should be used exclusively to control
> the price at which trade actually takes place.
for a long position , if I want exit for the same trade on a target ( 
or Profit) or on a stopLoss (or trailingstop) and controll the exit 
price, the sellprice is the only solution.
because I can write a target or a stop loss with ATr value .
Xb/*exit bar*/=Sl/*stoploss*/ or sp/*stopProfit*/;



> Therefore, if you (ab)use sellprice for storing target
> prices you have to add the following at the end of your formula
> sellprice = IIF( sell, sellprice, close );
> 
> This ensures that for all bars where sell signal is *not* generated
> the sellprice array equals to close.

as you the system tester keeps the open position in the result of a 
backtest
your solution to add the close when the position is opened must be 
good . I'll try it.
following must be correct?

Xp/*Exit Price*/=
IIf(Xb/*exit bar*/,IIf(Sp/*stop profit*/,Spp/*stop profit price*/
,IIf(Sl/*Stoploss*/,Slp/*stoplossprice*/,0)),close);
Xp=ValueWhen(Xb,Xp);

Stephane