Hello
I wounder if someone could help with code for this turn of month strategy?
Does multitimeframe solve the problem to buy at close with daily bars?
Entry conditions for TOM
Buy from the 18th trading day of the month and 4 days ahead if the closing price is lower than yesterday.
Exit condition for TOM
The strategy sells on the first day after the end of the month if the profit is at least 1%, alternatively on the 6th trading day regardless of the profit.
Thanks for a great forum!
You want to buy on or after the 18th trading day of each month AND 4 days ahead or IF 4 days ahead… (provided the closing price of the 4th prior day is lower than the closing price of the 5th prior day)?
I want to buy on or after the 18th trading day of each month and 4 days ahead if the closing price is lower then yesterday.
Example 18th trading day, close today higher then yesterday, no entry.
19th trading day, close today lower than yesterday, entry.
There you go:
DEFPARAM CumulateOrders = False
ONCE DayCount = 0
ONCE Tally = 0
IF Month <> Month[1] THEN
DayCount = 0
Tally = 0
IF OnMarket AND ((PositionPerf * 100) >= 1) THEN
SELL at Market
ENDIF
ENDIF
DayCount = DayCount + 1
IF (DayCount = 6) AND OnMarket THEN
SELL at Market
ENDIF
IF DayCount = 18 THEN
Tally = Tally + 1
ENDIF
IF Not OnMarket AND (Tally > 0) AND (Tally <= 4) THEN
BUY 1 Contract at Market
ENDIF