Monthly Trading with Daily ApplyStop

I have a monthly trading system that uses the month to determine when to buy and sell. The period is set to Monthly in the backtester settings.

Buy = (Month() == 3 OR Month() == 10)
Sell = (Month() == 5 OR Month()==11)

I want to apply a stop on the daily timeframe. I have tried multiple timeframes but it is not working as expected. What is the recommend programming approach ?

Thanks S

Buy = Month() == 3 OR Month() == 10;
Sell = Month() == 5 OR Month()==11;
Buy = ExRem(Buy, Sell);
Sell = ExRem(Sell, Buy);

If you want the stops to be applied on a daily basis, then you will need to set the Periodicity to Daily in the Analysis (Backtester) Settings. Depending on whether you want to enter and exit at the start or end of the month, you can use an approach like @awilson provided or something similar.

Thanks Anderson and Matt,

When I set the period to daily. The exit price is equal to the close price on the first day of the month. How do I configure this to use the close price on the monthly bar ? Appreciate your help.

Susan

If you have not changed your previously posted logic, then your entries and exits will take place on the first trading day of May and the first trading day of November. It sounds like that's not what you want. One of several possible ways to fix the exits would be to use something like this:

m = Month();
Sell = (m == 5 AND Ref(m,1) == 6) OR
       (m == 11 AND Ref(m,1) == 12);

Whenever you use a positive value as the second argument to Ref() you're looking into the future, so that's something to be cautious about if trading in real time. However, it should be OK for a historical back test.

I usually set my BuyPrice and SellPrice from within the AFL as well, but it appears you may be doing it through the Analysis Settings window.

Thanks Matt,

Yes, correct. I want the sell price to be on the last day of the month. The code snippet that you have provided sets the SellPrice to the last day. Much appreciated.

Susan