Hello Roberto,
thanks for the code, unfortunately I get errors again on exit.
The trade is often closed 2 months later.
TF 15 min.
greetings
Suffi
//-------------------------------------------------------------------------
// Suffi TF 15 min
//-------------------------------------------------------------------------
DEFPARAM PreLoadBars = 1000
BuyTime = 0
SellTime = 0
IF (Day = 5) or ((Day > 5) and (Day[1] < 5)) THEN
SellTime = 1
ENDIF
IF (Day = 26) or ((Day > 26) and (Day[1] < 26)) THEN
BuyTime = 1
ENDIF
IF NOT LongOnMarket AND BuyTime AND CurrentTime >=90000 THEN
BUY 1 CONTRACTS AT MARKET
ENDIF
IF LongOnMarket AND SellTime AND CurrentTime >=200000 THEN
SELL AT MARKET
ENDIF
The code detects the selcted DAY when the chosen number is equal to a trading day OR when it wasn’t a trading day.
But at 00:00 the system does NOT change the day (it is still the old day till 01:00am), so when the day changes, if it’s not exactly the chosen day, the day change is not recognized because DAY > YourDay, but DAY[1] is NOT < YourDay!
This is the modified code:
//-------------------------------------------------------------------------
// Suffi TF 15 min
//-------------------------------------------------------------------------
DEFPARAM PreLoadBars = 1000
ONCE BuyTime = 0
ONCE SellTime = 0
IF Month <> Month[1] THEN
BuyTime = 0
SellTime = 0
ENDIF
IF (Day = 5) or ((Day > 5) and (Day[1] < 5)) AND LongOnMarket THEN
SellTime = 1
ENDIF
IF (Day = 26) or ((Day > 26) and (Day[1] < 26)) AND Not LongOnMarket THEN
BuyTime = 1
ENDIF
IF NOT LongOnMarket AND BuyTime AND CurrentTime >=90000 THEN
BUY 1 CONTRACTS AT MARKET
SellTime = 0
ENDIF
IF LongOnMarket AND SellTime AND CurrentTime >=200000 THEN
SELL AT MARKET
BuyTime = 0
ENDIF
//graph SellTime
//graph BuyTime
//graph Day
//graph CurrentTime
//graph DayOfWeek
Hello Roberto,
great and thank you very much, now it works fine.
Greetings
Suffi