Afl with buy/sell with specific percent and reverse

Hi,
I am new to afl coding. I am trying to achieve this:

  1. Buy if close> last bar close --- This is to start for the day
  2. If the last signal is buy, then sell at 2% Profit or Sell if Stop Loss hit at 1% and reverse the trade.
  3. If exit in profit and the earlier signal was buy then sell in next bar close.
    For Short side just similar.
    For example,
    if first entry is Long @300 then sell @306(if profit) or exit and new short entry @297(if SL hit). For profit hit then entry in Short at next candle close.
    If the entry is at short side @300 then buy @294(if profit) or exit and new Long entry@ 303(if(SL hit). For profit then entry in Long at next candle.

Can you pleasehelp me achieve this.

@rajdeep.raut - by the definition help is giving assistance or support to someone to make it easier or possible to do something. For this reason if you expect help, you need to put some effort and start first. Only then someone else might help you ... There is a big difference between helping someone and doing everything (from A to Z) for or instead of someone.

3 Likes

Check out ApplyStop function.
https://www.amibroker.com/guide/afl/applystop.html

https://www.amibroker.com/kb/index.php?s=applystop