Line 29 is not allowed (despite being documented), you cannot combine two kind of SL at the same time and, if you separate them on two lines the second line will overwrite the previous one!
Your right I do apologise as I compared indicator 1 against indicator 1- when it should of been indicator 2. However I fixed this issue. So just to confirm the error is on the automated coding level and not at the indicator level ?
Further I am using the 10 minute time frame. As you can see on the attachments
Even when using the simplified creation tool(code below) I get the same error of orders closing as soon they they are placed.
// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
// Prevents the system from creating new orders to enter the market or increase position size before the specified time
noEntryBeforeTime = 143000
timeEnterBefore = time >= noEntryBeforeTime
// Prevents the system from placing new orders to enter the market or increase position size after the specified time
noEntryAfterTime = 210000
timeEnterAfter = time < noEntryAfterTime
// Conditions to enter short positions
indicator2, indicator1 = CALL aSpec
c1 = (indicator1 >= indicator2)
IF c1 AND timeEnterBefore AND timeEnterAfter THEN
SELLSHORT 4 PERPOINT AT MARKET
ENDIF
// Conditions to exit short positions
indicator4, indicator3 = CALL aSpec
c2 = (indicator3 CROSSES UNDER indicator4)
IF c2 THEN
EXITSHORT AT MARKET
ENDIF
// Stops and targets
SET STOP pTRAILING 14
Thanks again for all the input.
Regards,
Simeon
It seems to be working perfectly, always exiting due to the TRAILING stop. I embedded the indicator in the strategy (but this shouldn’t affect results):
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
currentHigh=High[0]
previousHigh=High[1]
currentClose=close[0]
diffCurrentVSPreviousHigh=previousHigh-currentClose
IF currentHigh>previousHigh THEN
risingHigh=12
else
risingHigh=2
ENDIF
//return risingHigh,diffCurrentVSPreviousHigh
noEntryBeforeTime = 143000
timeEnterBefore = time >= noEntryBeforeTime
noEntryAfterTime = 210000
timeEnterAfter = time < noEntryAfterTime
indicator2 = diffCurrentVSPreviousHigh
indicator1 = risingHigh
c1 = (indicator1 >= indicator2)
c2 = (indicator1 CROSSES UNDER indicator2)
IF c1 AND timeEnterBefore AND timeEnterAfter THEN
SELLSHORT 4 PERPOINT AT MARKET
ENDIF
IF c2 and shortonmarket THEN
EXITSHORT AT MARKET
ENDIF
SET STOP pLOSS 20 pTRAILING 14
Hi Roberto,
I cant thank you enough. Its great to know that my code works.
When I did go through the losers , It seems the issue is still somewhat present as can be seen in the attachment below(I am not sure how clear it is so I have also typed them out below).
Considering that the code works from a technical standpoint. Is this just a byproduct of the code(sometimes it will close orders as soon as they are opened) ?
1 August OPEN: 20:50 CLOSE:20:50
2 August OPEN: 14:50 CLOSE:14:50
2 August OPEN: 15:00 CLOSE:15:00
2 August OPEN: 17:40 CLOSE:17:40
2 August OPEN: 17:50 CLOSE:17:50
2 August OPEN:18:40 CLOSE:18:40
Regards,
Simone
P.S the 2nd attachment showing a chart on IG shows the corresponding price for the 2 August 17:40 close out. As I believe the order shouldn’t of closed as on the following 3 candles the current high is lower than the previous high.
It works perfectly, I rarely experienced 0-bar trades, some are those you posted, but all of then are closed due to trailing stop.
Hi Roberto,
You are right. When I take away the ptrailing the orders don’t seem to close straight away.
But as a trader it is very very rare for a stop to be hit in a second. ptrailing is points correct(because i set ‘ptrailing’ at 20 pips away from buy price) ?
Anyway I thought it best to remove the ptrailing and find another solution as stops/limits seems to do more harm than good.
Regards,
Topic moved to ProOrder forum.
FYI, trailing stop are not allowed for limited risk accounts, if your live or demo account is a limited risk one, the backtest behavior should reflect this limitation.