Hello,
In order to create a strategy based on seasonality, I would like to graph a variable that returns the number of trading days per month without including sunday candles.
I can return with the following code the number of trading days including sundays. I have tried to add a “elsif dayofweek=2 then c1=c1” but it doesn”t work.
Can someone help me?
Magifina
defparam cumulateorders=false
IF openday>openday[1] THEN
c1=c1+1
ELSE
c1=1
ENDIF
graph c1
// Conditions pour ouvrir une position acheteuse
IF NOT LongOnMarket THEN
BUY 1 CONTRACTS AT MARKET
ENDIF
// Conditions pour fermer une position acheteuse
If LongOnMarket THEN
SELL AT MARKET
ENDIF
Try this:
if openmonth<>openmonth[1] then
c1 = 0
endif
if openday <> openday[1] and openday <> 0 then
c1 = c1 + 1
endif
Thanks for your quick answer Vonasi. I have found the solution. In fact openday <>0 must be replace by dayofweek <> 2 in order to work.
if openmonth<>openmonth[1] then
c1 = 0
endif
if openday <> openday[1] and dayofweek <> 2 then
c1 = c1 + 1
endif
Sorry – I just realised my typo – we need to use OPENDAYOFWEEK and not OPENDAY. Sunday is OPENDAYOFWEEK zero.
Better to check the open day rather than the day as if there is a bank holiday monday it will mess things up and you will count a Sunday.
if openmonth<>openmonth[1] then
c1 = 0
endif
if opendayofweek <> opendayofweek[1] and opendayofweek <> 0 then
c1 = c1 + 1
endif