Keep Position Open If New Buy Signal

Hello everyone,

I have been using Amibroker for many years now for charting and simple indicators and am trying to dip a toe in systematic trading and back-testing. I would appreciate it if you guys could take a look at this and let me know if I am doing this correctly.

Let's say I have a simple strategy that looks for a signal on bar N and trades on Bar N+1 at the open and a N-Bar stop that generates a decision to sell on N+3 for execution at the next open (N+4).

What I would like to know is if there is simple way to tell the back-tester NOT to take the sell signal on bar N+3 if a new Buy signal was issued on that same bar.

The first code snip below is the general gist of the strategy and the second is what I came up with but I suspect that BarsSince is using raw signals instead of actual signals. Am I correct in assuming this?

If yes, is this something that ExRem would solve?

General Idea

SetTradeDelays(1,1,0,0);

Buy=Cross(RSI(2),20);
Sell=False;

BuyPrice=Open;
SellPrice=Open;

ApplyStop(stopTypeNBar,stopModeBars,3);
SetTradeDelays(1,1,0,0);

Buy=Cross(RSI(2),20);
Sell=!Buy && BarsSince(Buy)==3;

BuyPrice=Open;
SellPrice=Open;

ApplyStop(stopTypeNBar,stopModeBars,3);

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