Hi, I made a mostly price action strategy that also uses some moving averages. The result seems fine but despite having a MA-filter for positions it still longs under the Ma allowed.
The other problem i have is when i forward test the longs disappears, PRT wont execute the trades! If i add some more conditions they disappear aswell.
This is Dax 1h timeframe.
Does anyone know the solution to these problems?
Kind regards,
Anders
DEFPARAM CumulateOrders = false
K = 3
l = 40
Higher =high[k] > highest[l](close)
Lower = low[k] - lowest[l](close)
HigherShort =high[l] - highest[k](close)
LowerShort = lowest[k](close) - low[l]
Ma = exponentialaverage[80]
ma2 = exponentialaverage[50]
ma3 = average[3000]
n = 1.5 //contracts
c1 = close > ma3 and close > ma and Higher and lower > 15 and time => 091500 and time <= 190000
c2 = close crosses under ma2
c3 =close < ma and Highershort <-30 and LowerShort and time => 091500 and time <= 190000 and close < ma3
c4 = close crosses over ma2
If c1 then
buy n contract at market
endif
if c2 and longonmarket then
sell at market
endif
If c3 then
sellshort n contract at market
endif
if c4 and shortonmarket then
buy at market
endif
SET STOP ptrailing 140
SET TARGET PROFIT 300
From the atteched pics I can’t see where your three MA’s are.
Since at line 14 you don’t check MA2, close can be lower than that.
Line 32 should read as below (not Buy to exit a Short trade) …
ExitShort at Market
Thank you both for replying.
I changed the code to exitshort grahal, thank you for the tip! i’ve only been coding for a week so im still learning. That fixed my problem with the longs below the moving average!
ma = powerful enough trend to long/short, ma2 = ema to stop trades that have weak trends, and ma3 should be the one that decides if to short or long, sorry for the confusion.
The Ma visible on the pictures is the long/short filter. The long trades are all visible during regular backtests but during WF almost all of them disappear. 107 trades is missing..
Problem solved by using
DEFPARAM PRELOADBARS = 10000000
Max preload bars is 10K, no matter what you write.