create a trialing stoploss in Amibroker

#1
How to write a correct AFL to create a trialing stoploss using the following logic?
Can anyone suggest....

stopprice = ltp -5
If buy = 1
If stopprice < stopprice (-1) then sell

:confused:
 

abcpankaj

Active Member
#2
have you tried the combination of ApplyStop & stopTypeTrailing , like :

ApplyStop(stopTypeTrailing, stopModePoint, ltp-5, True, True );
 

mastermind007

Well-Known Member
#6
ApplyStop is only for BackTesting - it wont generate Exit signals.
Thank U n Rgrds
--ShiraJ--
For visual confirmation of ApplyStop function, you need to add following lines to your code after the ApplyStop formula in Indicator Builder:

Equity(1);
Plot(Sell== 4,"ApplyStop Sell",colorRed,1 | styleOwnScale);
Plot(Cover== 4,"ApplyStop Cover",colorGreen,1 | styleOwnScale);
 

shirajroz

Active Member
#7
For visual confirmation of ApplyStop function, you need to add following lines to your code after the ApplyStop formula in Indicator Builder:

Equity(1);
Plot(Sell== 4,"ApplyStop Sell",colorRed,1 | styleOwnScale);
Plot(Cover== 4,"ApplyStop Cover",colorGreen,1 | styleOwnScale);
Thanks a Ton MasterMindJi & TrashJi,
Experimented wid the above a year back when saw on the Comments Section of the Function reference Page.But, Unfortunately, the RoboTrader i use, does not Pick Exit Signals those generated by Built-In ApplyStop function of AMIBROKER (Dont know why, the RobTrader Neither does pick Exit Signals which involve or initiated wid Null Statements and/or Statements like Sell=0; or Cover=0; etc. ).
Sorry TrashJi n MasterMindJi,
for my that rather hasty comment in post#3 above --> wht i actually Meant was that the standalone APPLYSTOP function does not Automatically generate Exit Signals as one would assume seeing the BackTest Report of an "APPLYSTOP function included AFL". and my intention was to nullify any such assumtion/impression from the mind of the Thread Starter if so implied by the Post#2 by AbcPankaj Bro above.
Thank U n Apologies Sirs,
Rgrds
--ShiraJ--
 

trash

Well-Known Member
#8
wht i actually Meant was that the standalone APPLYSTOP function does not Automatically generate Exit Signals as one would assume seeing the BackTest Report of an "APPLYSTOP function included AFL". and my intention was to nullify any such assumtion/impression from the mind of the Thread Starter if so implied by the Post#2 by AbcPankaj Bro above.
Thank U n Apologies Sirs,
Rgrds
--ShiraJ--
Well, you can do that also (if I understand your English correctly).

If you mean HTML backtest report then you can add info on first page "Applystop function was used" via CBT (custom backtest code).

And in result list's Trade column of analysis window you already have trade info when Applystop was used.

 

mastermind007

Well-Known Member
#9
Well, you can do that also (if I understand your English correctly).

If you mean HTML backtest report then you can add info on first page "Applystop function was used" via CBT (custom backtest code).

And in result list's Trade column of analysis window you already have trade info when Applystop was used.

Trash

what is needed is a simple way to show the arrows of trade on screen, such as populating of Sell/Cover arrays and then using that to feed to the robotrade or any other algorithmic trading terminal engine.

Additional info revealed in the backtesting results is excellent but one needs to see stops applied in real-time for the ApplyStop function to be useful practically.
 
#10
Trash

what is needed is a simple way to show the arrows of trade on screen, such as populating of Sell/Cover arrays and then using that to feed to the robotrade or any other algorithmic trading terminal engine.

Additional info revealed in the backtesting results is excellent but one needs to see stops applied in real-time for the ApplyStop function to be useful practically.
Shouldn't it be simple for e.g. implementing TSL for Buy . . .

Sell = Cross(HHV(H,Barssince(Buy))-TSL_Points,L);


Thanks
 

Similar threads