ALEModerator
Master
Hi Nicolas,
I think that problem could be derivates from code structure. May be trailing stop or something else
The code was started this week so yeah it´s the first time.
I´ve had the same problem with other codes on daily which affects the over all performance of the code alot and it has ended with me scrapping the code.
I don’t see anything in the code that lead me thinking it’s related.. why do you think so? Are you talking about the rejected orders limit reached?
ALEModerator
Master
It happens on daily time frame on saturday, also on cac and dax without reasons
ALEModerator
Master
Also happens that at 00.02 of sunday morning
the stop is removed, and reappears at the next candle in monday morning at 01.00
I´m not sure why it´s happening. I´ve gone through the code many times now and can´t find anything that differates from lets say an 1 hour code that isn´t stopping it self.
My highly non certain conclusion is that it has something to do with IGs pricing.
Mon-Thurs = 1 candle – 24 hours, Fri=1 caandle – 22 hours. I think that´s messing up the code since it can´t read the price when it thinks it should be able to and thats why there´s an error and prt trying to quit the code.
Now my position has closed and I have (as you can see in the picture below) three rejected orders that says=
First rejection = This market is now closed
Second rejection = Sorry, we have been unable to confirm the status of your trading request. Please call us on …..
Third Redjection= Price is no longer available
Ok, now I´m going to dubbelpost again… But I really like this code so I want it to work 🙂
With my limited coding skills this is the only thing I can think of changing (code). No new position on fridays and closes open positions on friday opening.
//--------------------------------------------------------------------------------------------------
//days
notfd = opendayofweek = 1 or opendayofweek = 2 or opendayofweek = 3
// STRATEGY
//--------------------------------------------------------------------------------------------------
IF NOT LongOnMarket AND avgFilterEnterLong AND SvEFilterEnterLong and notfd THEN
BUY 1 CONTRACT AT MARKET
ENDIF
IF NOT ShortOnMarket AND avgFilterEnterShort AND SveFilterEnterShort and notfd THEN
SELLSHORT 1 CONTRACT AT MARKET
ENDIF
IF POSITIONPERF<0 THEN
IF LongOnMarket AND BARINDEX-TRADEINDEX(1)>= barLong THEN
SELL AT MARKET
ENDIF
ENDIF
IF POSITIONPERF<0 THEN
IF shortOnMarket AND BARINDEX-TRADEINDEX(1)>= barshort THEN
EXITSHORT AT MARKET
ENDIF
ENDIF
if opendayofweek = 4 and openhour = 21
sig=1
else
sig=0
endif
IF sig=1 THEN
SELL AT MARKET
EXITSHORT AT MARKET
ENDIF
ALEModerator
Master
@t-rader,
have you already had this strategy open of Friday? It could be a case that is not rarely verified.
I have other strategies with the same code on the indexes and this it happens only rarely me on the European indexes. But I never work on forex.
I had it this friday. Maybe it wont happen again or it will, I dont know but its pretty annoying if it closing a loosing trade that would have been a winner if it was hold over the weekend.
Personally I´m fine with this addition to the code since I don´t like to have FX positions open during NFP, I like trend more than volatility.
When I have experineced this problem in the past it has always been on OMX (Sweden 30).
ALEModerator
Master
To avoid volatily days please consider it:
once countFridays = 0
firstDayOfMonth = (day = 1)
isFriday = (dayOfWeek = 5)
firstWeek = (day < 8)
if firstDayOfMonth then
countFridays = 0
endif
if isFriday and (not isFriday[1]) then
countFridays = countFridays + 1
endif
// Non Farm Payrolls
nfpDay = isFriday and firstWeek
// Triple Witching
isMarch = (Month = 3)
isJune = (Month = 6)
isSept = (Month = 9)
isDec = (Month = 12)
tripleWitchingMonth = isMarch or isJune or isSept or isDec
thirdFriday = isFriday and countFridays = 3
tripleWitching = thirdFriday and tripleWitchingMonth
//////////////////////////////////////////////////////////
IF nfpday or tripleWitching then
sell at market
exitshort at market
endif
ALEModerator
Master
once countFridays = 0
firstDayOfMonth = (day = 1)
isFriday = (dayOfWeek = 5)
firstWeek = (day < 8)
if firstDayOfMonth then
countFridays = 0
endif
if isFriday and (not isFriday[1]) then
countFridays = countFridays + 1
endif
// Non Farm Payrolls
nfpDay = isFriday and firstWeek
// Triple Witching
isMarch = (Month = 3)
isJune = (Month = 6)
isSept = (Month = 9)
isDec = (Month = 12)
tripleWitchingMonth = isMarch or isJune or isSept or isDec
thirdFriday = isFriday and countFridays = 3
tripleWitching = thirdFriday and tripleWitchingMonth
//////////////////////////////////////////////////////////
return tripleWitching COLOURED (200,0,0) STYLE(HISTOGRAM) AS "WHICH" ,nfpDay COLOURED (100,0,0) STYLE(HISTOGRAM)AS "NFP"
Thanks. That´s a good snippet of code for my other strategys but it dosen´t solve the friday stopping problem.
ALEModerator
Master
Yes of course but i don’t understand how your code could resolve this problem
Cause if there´s an open position my code closes it on friday opening 🙂
And it dosent take any trades on friday either.
ALEModerator
Master
//-----------------------------------------------------------------------------------------------
//days
notfd = opendayofweek = 1 or opendayofweek = 2 or opendayofweek = 3
// STRATEGY
//--------------------------------------------------------------------------------------------------
IF NOT LongOnMarket AND avgFilterEnterLong AND SvEFilterEnterLong and notfd THEN
BUY 1 CONTRACT AT MARKET
ENDIF
IF NOT ShortOnMarket AND avgFilterEnterShort AND SveFilterEnterShort and notfd THEN
SELLSHORT 1 CONTRACT AT MARKET
ENDIF
IF POSITIONPERF<0 THEN
IF LongOnMarket AND BARINDEX-TRADEINDEX(1)>= barLong THEN
SELL AT MARKET
ENDIF
ENDIF
IF POSITIONPERF<0 THEN
IF shortOnMarket AND BARINDEX-TRADEINDEX(1)>= barshort THEN
EXITSHORT AT MARKET
ENDIF
ENDIF
if opendayofweek = 4 and openhour = 21 THEN
IF POSITIONPERF>0 THEN
SELL AT MARKET
EXITSHORT AT MARKET
ENDIF
ENDIF
YOU CAN CONSIDER TO TEST IF IT’S BETTER TO CLOSE IT IF POSITION IT’S IN PROFIT OR NOT