Please help to use ApplyStop function

Hi All;

I have my simple MA crossover (EMA 5 & EMA 13) strategy. So, the buy and short logic is simple and I am able to code it easily.

Now, the next thing is that ----once in a trade either BUY or SHORT is executed once , I want to close the trade with either lets say 10 points profit (profit booking logic) or 5 points loss (stop loss logic), which ever happens first.

Can it be achieved by using applystop function?

If, yes ----the please give me a starting point for the coding.

Otherwise , also please let me have the starting codes to achieve it alternatively.

Thanking you in advance for your guidance / help.

Hi @santy. You will need to call ApplyStop() twice in your AFL: once for the stop loss, and again for the profit target. Documentation (with examples) for this function can be found here: https://www.amibroker.com/guide/afl/applystop.html

So, does it mean that we do not need to use coding for sell and cover strategy if we use Applystop function i an afl?

I encourage you to try it yourself and see what happens. You will learn very little if you just keep asking others to solve all your problems and answer all your questions.

1 Like