Possible to mix Applystop() and custom for-loop code?

The link below talks about implementing stops using ApplyStop() and custom for-loop code.

Suppose I want to use custom for-loop to implement take profit stop and ApplyStop() to implement worst-case cut-loss stop. If I start using custom for-loop, does it make ApplyStop() ineffective? In other words, once I use custom for-loop for implementing stops, does it mean all forms of stops must be implemented inside this loop and ApplyStop() can't be used anymore?

You can mix these two approaches, and ApplyStop works fine regardless of what you have in your code, but note that ApplyStop() is an instruction for backtester, so ApplyStop triggers inside the backtester, after your formula is executed.

1 Like

I had some experience mixing Applystop() and custom for-loop code. ApplyStop() works fine. However, a few things to note for the for-loop code. ApplyStop() does not update sell or cover variable when it exits. This can cause trouble to for-loop code if it assumes that sell or cover variables are updated when the trade exits.

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.