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

[amibroker] Re: Does backtester have an initial breakeven stop capability?



PureBytes Links

Trading Reference Links

Hi scourt2000 and Allan

Because I am new to coding
and not confident of my code
I have not posted a response.
But, as no AFL breakeven stop has been posted,
here is the code I use,
which was developed with the help of  Graham,
which you could check for correctness.

//=====B.E. STP STRTS ===============================================
BuyPrice= ValueWhen( Buy, BuyPrice, 1 );
SellPrice = BuyPrice;
//USE ValueWhen OR ATR KEEPS CHANGING FOR EACH SUCCESSIV BAR
Stp_SetThreshold = ValueWhen( Buy, BuyPrice + (1 * ATR(14)), 1 );
Stp_MvToBrkEvn = ValueWhen ( High > Stp_SetThold, 1, 1 );

Sell = Sell OR Stp_MvToBrkEvn = 1 AND Low < BuyPrice;
//=====B.E. STP ENDS  ===============================================

ApplyStop(stopTypeProfit, stopModePoint, 1 * ATR(14), ExitAtStop = 1, 
True);  //Gain  

Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);

britefire