I am referring to NAS-2m-HULL-SAR-v5.3L and NAS-2m-HULL-SAR-v5.3-L, it happened the same on both versions (at least in my account). Did you have the same problem?
No, I haven’t seen that. I’m running v5.5, it opened 2 positions, still open with the trail in place, behaving as it should.
What I have found is that the Target Profit doesn’t register, and maybe has to be entered after each buy instruction, but that won’t effect the Trail.
// Conditions to enter long positions
if tradetype=1 or tradetype=2 then
IF not longonmarket and CB and Flag THEN
BUY positionsize CONTRACT AT MARKET
SET STOP %LOSS sl
SET TARGET %PROFIT tp
elsif Ctime and longonmarket and CB2 and COUNTOFLONGSHARES < MaxPos and Flag then
BUY positionsize CONTRACT AT MARKET
SET STOP %LOSS sl
SET TARGET %PROFIT tp
Flag = 0
elsif longonmarket and CB2 and positionperf <0 and COUNTOFLONGSHARES < MaxPos2 and Flag1 then
BUY positionsize CONTRACT AT MARKET
SET STOP %LOSS sl
SET TARGET %PROFIT tp
Flag1 = 0
elsif longonmarket and CB2 and positionperf <0 and COUNTOFLONGSHARES < MaxPos2 and Flag2 then
BUY positionsize CONTRACT AT MARKET
SET STOP %LOSS sl
SET TARGET %PROFIT tp
Flag2 = 0
elsif longonmarket and CB2 and positionperf <0 and COUNTOFLONGSHARES < MaxPos2 and Flag3 then
BUY positionsize CONTRACT AT MARKET
SET STOP %LOSS sl
SET TARGET %PROFIT tp
Flag3 = 0
ENDIF
ENDIF
Is anyone running v5.3 SHORT (Tradetype = 3 to go Short) on a real account, in any market, without problems?
See #165505 for what i´m struggeling with.
I had a quick look at DJ 2m HULL-SAR v5.3S and I think there’s something wrong with the trail – try replacing it with this. Backtests ok but I haven’t tried running it.
The DJ looks like it might have some potential going short, I don’t think the NAS is worth the effort.
// %trailing stop function incl. cumulative positions
once trailingstoptype1= 1
if trailingstoptype1 then
//====================
trailingpercentlong = .28 // %
trailingpercentshort = TP02 // %
once acceleratorlong = .029 // [1] default; always > 0 (i.e. 0.5-3)
once acceleratorshort= ACC0022 // 1 = default; always > 0 (i.e. 0.5-3)
ts2sensitivity = 2 // 1 = close 2 = High/Low 3 = Low/High 4 = typicalprice (not use once)
//====================
once steppercentlong = (trailingpercentlong/10)*acceleratorlong
once steppercentshort = (trailingpercentshort/10)*acceleratorshort
if onmarket then
trailingstartlong = positionprice*(trailingpercentlong/100)
trailingstartshort = positionprice*(trailingpercentshort/100)
trailingsteplong = positionprice*(steppercentlong/100)
trailingstepshort = positionprice*(steppercentshort/100)
endif
if not onmarket or ((longonmarket and shortonmarket[1]) or (longonmarket[1] and shortonmarket)) then
newsl = 0
mypositionprice = 0
endif
positioncount = abs(countofposition)
if newsl > 0 then
if positioncount > positioncount[1] then
if longonmarket then
newsl = max(newsl,positionprice * newsl / mypositionprice)
else
newsl = min(newsl,positionprice * newsl / mypositionprice)
endif
endif
endif
if ts2sensitivity=1 then
ts2sensitivitylong=close
ts2sensitivityshort=close
elsif ts2sensitivity=2 then
ts2sensitivitylong=high
ts2sensitivityshort=low
elsif ts2sensitivity=3 then
ts2sensitivitylong=low
ts2sensitivityshort=high
elsif ts2sensitivity=4 then
ts2sensitivitylong=typicalprice
ts2sensitivityshort=typicalprice
endif
if longonmarket then
if newsl=0 and ts2sensitivitylong-positionprice>=trailingstartlong*pipsize then
newsl = positionprice+trailingsteplong*pipsize
endif
if newsl>0 and ts2sensitivitylong-newsl>=trailingsteplong*pipsize then
newsl = newsl+trailingsteplong*pipsize
endif
endif
if shortonmarket then
if newsl=0 and positionprice-ts2sensitivityshort>=trailingstartshort*pipsize then
newsl = positionprice-trailingstepshort*pipsize
endif
if newsl>0 and newsl-ts2sensitivityshort>=trailingstepshort*pipsize then
newsl = newsl-trailingstepshort*pipsize
endif
endif
if barindex-tradeindex>1 then
if longonmarket then
if newsl>0 then
sell at newsl stop
endif
if newsl>0 then
if low crosses under newsl then
sell at market
endif
endif
endif
if shortonmarket then
if newsl>0 then
exitshort at newsl stop
endif
if newsl>0 then
if high crosses over newsl then
exitshort at market
endif
endif
endif
endif
mypositionprice = positionprice
endif
Thanks nonetheless!
For me the algo has stopped within a few seconds after start, so no positions then. But maybe still can be problems with the trail? I will try your code!
I have cumulative = false, but maybe that doesn´t matter with your code above?
I tried you code on DOW 5.3S but I get:
“The trading system was stopped because the historical data loaded was insufficient to calculate at least one indicator during the evaluation of the last candlestick.”
I got the same after changing to Preloadbars = 15000
in backtest or autotrading?
autotrading
Well, if you (or anyone else) gets 5.3 to work for shorts on any market I would be very interested to test it!
I will try DJ 2m HULL-SAR v5.3S and tell you back
Here is the backtest of Dow 2m Hull SAR v5.3S.
Looks good in 200k in short only
I curiously has trouble when i want launch in autotrading the Dow 2m Hull SAR v5.3S
Line 24. Message say end of code ?
I curiously has trouble when i want launch in autotrading the Dow 2m Hull SAR v5.3S
Line 24. Message say end of code ?
You can’t launch the system in autotrading because there are variables in the optimization boxes; you have first to define the values through the code, delete the optimization boxes and then you can run it.
Here is the backtest of Dow 2m Hull SAR v5.3S.
And looks good too in 1M barres
You can’t launch the system in autotrading because there are variables in the optimization boxes; you have first to define the values through the code, delete the optimization boxes and then you can run it.
I don’t think i have to do it with the last version of prorealtime V11.
The problem doesn’t come from it in my opinion
Line 24. Message say end of code ?
It may be that the code needs an extra Endif adding as the last line of the code?