How to write stop_loss-aflcode

#1
Dear Amibroker-Users,

i have just a simple question how to write stop-los funktion into my
tradingsystem

I want so set stop-loss one tick below prev. barslow (Low of the day before
buysetup)

Endclosed pdf-file will show the pattern.


Thanks for help

Regards

Martin
 

Attachments

#2
This would be simple Cover/Sell code.

Code:
Cover = Cross(Close, Ref(High, -1)+0.05);
Sell = Cross(Close, Ref(Low, -1)-0.05);
thank u for the code. i need one help. i want to backtest some systems on amibroker. how to put stoploss for last 3 candle low for buy and vice versa for sell. but stoploss should be fixed not trailing.. please check below image..

 
#4
how to incorporate both tgt and sl code in the same afl as blow:

1. sl: as mentioned by masiegp at previous bar low.(for tht u hv answered. but does it need any chng if tgt also included as blow)

2. tgt : buyprice plus previous bar range(of whose low is the sl) for long and sell price minus previous bar range for short .

Thanks in adv.

You r of great help.

with warm regards,
 
#5
This is something near to what I have been trying to achieve whole day. If your Buy/Short signals do not repeat until Sell/Cover signals are hit then you can just use this:

Code:
range = High - Low;  //if this is what you meant by range
trg  = BuyPrice + range;
cover = xcover or cross(trg, close); // xcover would be your original cover condition
But if the signals are coming on every candle it ruins your whole day. :annoyed:
thank you so much.:)