thanks vonasi
and thanks to you Paul
eugenio
Thank you Paul for this great strategy !
I noticed that the months of July and August are performing badly and i would like to add something in the code to exclude trading during these months, each year.
Could someone help me with writing the lines of code needed to do that ? I have tried a few things but i am not able to make it work.
Thanks !
PaulParticipant
Master
Hi,
Just replace the existing part with this.
If Excludefirsttwoweeks=1 Then
If Year=2015 And Month=1 And (Day>=1 And Day<=18) Then
Notrading = 1
Elsif Year=2016 And Month=1 And (Day>=1 And Day<=24) Then
Notrading = 1
Elsif Year=2017 And Month=1 And (Day>=1 And Day<=22) Then
Notrading = 1
Elsif Year=2018 And Month=1 And (Day>=1 And Day<=21) Then
Notrading = 1
Elsif Year=2019 And Month=1 And (Day>=1 And Day<=20) Then
Notrading = 1
Elsif month=7 or month=8 then
Notrading = 1
Else
Notrading = 0
Endif
Endif
rebParticipant
Master
Hi
I’ve just found this topic about an interesting strategy,
is somebody using it ?
Reb
I am using it for DAX and also Brent Crude 1 min since the 8th March and its working really well
Which code are you using for brent crude 1min? Could you please share to check?
Or just the same code implemented on 1min?
I am using 3min for DAX in demo live since last 21st march and working well. Some cancelled orders sometimes but these are demo live issues, not real live I think.
And of course thanks to Paul for the strategy!!!
rebParticipant
Master
@Ruark Baker
on Brent 1m , what an interesting idea
Did you also test on other assets ? (just to avoid to check)
I tried all the major indicies and commodities, this was before I had a system for testing so it’s not written down. From memory it worked well on euro50 and MIB but the MIB drawdowns would have been too high for me to run at present, the code I am currently using is:
/-------------------------------------------------------------------------
// Main code : DailyOpen Straddle DAX 3min
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
// Main code : Straddle DayOpen
//-------------------------------------------------------------------------
// common rules
DEFPARAM CUMULATEORDERS = false
DEFPARAM PRELOADBARS = 10000
// optional
ExtraTradeCriteria=1
// positionsize and stops
positionsize = 1
sl = 0.6 // % Stoploss 0.6
pt = 0.4 // % Profit Target 0.4
ts = 0.35 // % MFETrailing
// indicator settigns
NOP=15 //number of points
TimeOpen=080000
// day & time rules
ONCE entertime = TimeOpen
ONCE lasttime = 100000
ONCE closetime = 240000 // greater then 23.59 means it continues position overnight
ONCE closetimeFriday=173000
tt1 = time >= entertime
tt2 = time <= lasttime
tradetime = tt1 and tt2
DayForbidden = 0 // 0=sunday
df = dayofweek <> dayforbidden
// setup number of trades intraday
if IntradayBarIndex = 0 then
longtradecounter = 0
Shorttradecounter = 0
Tradecounter=0
endif
// general criteria
GeneralCriteria = tradetime and df
// trade criteria
tcLong = countoflongshares < 1 and longtradecounter < 1 and tradecounter <1
tcShort = countofshortshares < 1 and shorttradecounter < 1 and tradecounter <1
// indicator criteria
If time = TimeOpen then
DayOpen=open
endif
if IntradayBarIndex = 0 then
lx=0
sx=0
endif
if high > DayOpen+NOP then
lx=1
else
lx=0
endif
if low < DayOpen-NOP then
sx=1
else
sx=0
endif
// trade criteria extra
min1 = MIN(dhigh(0),dhigh(1))
min2 = MIN(dhigh(1),dhigh(2))
max1 = MAX(dlow(0),dlow(1))
max2 = MAX(dlow(1),dlow(2))
If ExtraTradeCriteria then
tcxLong = high < MIN(min1,min2)
tcxShort = low > MAX(max1,max2)
else
tcxLong = high
tcxShort = low
endif
// long entry
If GeneralCriteria then
if lx and tcLong and tcxLong then
buy positionsize contract at market
longtradecounter=longtradecounter + 1
tradecounter=tradecounter+1
endif
endif
// short entry
If GeneralCriteria then
if sx and tcShort and tcxShort then
sellshort positionsize contract at market
shorttradecounter=shorttradecounter + 1
tradecounter=tradecounter+1
endif
endif
// MFETrailing
trailingstop = (tradeprice/100)*ts
if not onmarket then
MAXPRICE = 0
MINPRICE = close
priceexit = 0
endif
if longonmarket then
MAXPRICE = MAX(MAXPRICE,close)
if MAXPRICE-tradeprice(1)>=trailingstop*pipsize then
priceexit = MAXPRICE-trailingstop*pipsize
endif
endif
if shortonmarket then
MINPRICE = MIN(MINPRICE,close)
if tradeprice(1)-MINPRICE>=trailingstop*pipsize then
priceexit = MINPRICE+trailingstop*pipsize
endif
endif
If onmarket and priceexit>0 then
sell at market
exitshort at market
endif
// exit at closetime
If onmarket then
if time >= closetime then
sell at market
exitshort at market
endif
endif
// exit friday at set closetime
if onmarket then
if (CurrentDayOfWeek=5 and time>=closetimefriday) then
sell at market
exitshort at market
endif
endif
// build-in exit
SET TARGET %PROFIT pt
SET STOP %LOSS sl
I got mixed up and the brent strategy is actually this one https://www.prorealcode.com/prorealtime-trading-strategies/dax30-morning-breakout-order-size-increase/
I modified the code to take out the variable unit sizing, code is:
/-------------------------------------------------------------------------
// Main code : DAX 1 min mor steigerung flat
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
// Main code : DAX 1 min mor steigerung
//-------------------------------------------------------------------------
DEFPARAM FLATBEFORE=090100
// Festlegen der Code-Parameter
DEFPARAM CumulateOrders = false // Kumulieren von Positionen deaktiviert
// einmalige werte
once size = 2
//once profi = 20
once in = 1
once korrek = 1
sl = 40
// Verhindert das Trading an bestimmten Wochentagen
daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
noEntryAfterTime = 100000
timeEnterAfter = time < noEntryAfterTime
// einen trade nur
IF (CurrentTime = 010000) then
onetrade = 0
ENDIF
// Bedingungen zum Einstieg in Long-Positionen
IF (CurrentTime = 085900) then
high7 = HIGHEST[120](high)
low7 = LOWEST[120](low)
ENDIF
IF (close > high7) AND (CurrentTime >= 090100) then
onetrade = 2
ENDIF
IF (CurrentTime >= 090100) AND not daysForbiddenEntry AND (onetrade = 0) AND timeEnterAfter THEN
BUY size CONTRACT AT high7 STOP
ENDIF
IF (LONGONMARKET = 1) then
onetrade = 2
in = 1
korrek = 0
//l1 = POSITIONPRICE + 0.0008
l2 = POSITIONPRICE - sl
//sell at l1 LIMIT
sell at l2 stop
ENDIF
// Bedingungen zum Einstieg in Short-Positionen
IF close < low7 AND (CurrentTime >= 090100) then
onetrade = 1
ENDIF
IF (CurrentTime >= 090100) AND not daysForbiddenEntry AND (onetrade = 0) AND timeEnterAfter THEN
SELLSHORT size CONTRACT AT low7 STOP
ENDIF
IF (SHORTONMARKET = 1) then
onetrade = 2
in = 1
korrek = 0
//s1 = POSITIONPRICE - 0.0008
s2 = POSITIONPRICE + sl
//EXITSHORT at s1 LIMIT
EXITSHORT at s2 STOP
ENDIF
// korrektur
IF (LONGONMARKET < 1) AND (SHORTONMARKET < 1) then
in = 0
ENDIF
IF in = 0 and korrek = 0 then
d1 = POSITIONPERF(1) > 0
d2 = POSITIONPERF(1) < 0
IF d1 and size > 1 then
size = size - 1
korrek = 1
ELSIF d2 then
size = 2
korrek = 1
ENDIF
ENDIF
// Stops und Targets
SET STOP pLOSS 30
SET TARGET pPROFIT sl
//// Performance
//IF STRATEGYPROFIT > profi then
//size = 1
//profi = profi + 20
//ENDIF
Ruark Baker – please use the ‘Insert PRT Code’ button when posting code in any future posts as it makes it far easier for others to read. I have tidied up your post for you. 🙂
Hello Paul,
Great Idea with the code and thanks for sharing.
I had a little time to look into your code.
I might have spotted a mistake for your MFE Trailing Stop calculation
tradeprice(1) – maxprice > trailingstop instead of maxprice – tradeprice(1)
You want to start trailing from the moment you have a certain profit level if I am correct.
If Longonmarket Then
Maxprice = Max(Maxprice,close)
If tradeprice(1)-maxprice>=trailingstop*pipsize Then
Priceexit = Maxprice-trailingstop*pipsize
Endif
Furthermore I dont know what the Williams Trailing is doing. Maybe I just dont understand it.
But it seems to make no difference whether it is activated or not.
Kind regards
PaulParticipant
Master
@O-jay8 Thanks for the critical look. I’ve no idea where you found that, but you are correct.
The goal of the wbar 3 trailing stop was not to use an optimized profittarget and a minimal loss of maximum profits.
This doesn’t have an effect if you use a short timeframe like 1 minute. But i.e. 3 minute it makes a difference.
It’s not huge, but just a bit better exit points.
downside with a default trailing stop is that you may surrender some nice points, but upside is you can get bigger profits.
upside with a williams 3 bar trailing stop is that get you out of a trade at a fairly good price….at the time, but downside here is you can miss out on bigger profits.
While it’s a williams 3 bar trailing stop, testing it to 4 or 5 can be usefull.
https://www.prorealcode.com/prorealtime-indicators/williams-3-bar-trailing-stop/
Just add the indicator to the price-chart.
Looks like the strategy works best with high volatility!! and looses with low!!
PaulParticipant
Master
Yes at the moment doesn’t work good enough! Volatility is a different angle, I will give it a look.
Few things to consider;
- higher chance that it doesn’t work if there’s daily gap because of zigzag at opening (and days after)
- holiday 1 mei tag der arbeid in Germany (volatility), check the holidays and perhaps prevent trading.
- exit-time 173000 or 223000 on Friday can make a difference. As always the biggest difference is in the most recent day!
- main criteria uses > instead of crossover, there’s a potential of conflict. That long and short criteria are true at the same time. I use a workaround because I want to use it as is.
- got criteria which prevent entering the market on new high or low in opposite or same direction.
- In ways to prevent losing 1% (my stoplos which I don’t optimise on a short timeframe) I’am trying to prevent losing that number
- when in a position and it breaks previous days dhigh/dlow to close position and not to go on hope. Basically cut losses short but without exiting too much. But there’s more to it then this but that’s the idea.
- the concept to enter a second position when performance < -0.20% and use trailing stop on 2nd better position to close both and maintaining stoploss of 1st position. But there’re a few cave-cats so binned that idea for now.
- (but look at Friday when exiting at 22.30. If you had bought with -0.20% and exited on TS on first or second position it would’ve been interesting again)
All in all, it shows that you should be running more strategy’s at the same time !
But the concept to enter the market in the first hour remains good.
The Williams trailing stop doesn’t work because there are a couple of errors:
- Positionperf is quoted with 4 decimals (0.0050), while WTSMP is set to 0.50 (must be 0.0050)
-
If Onmarket and Mfetrailing=0 and Positionperf>WTSMP then
If Low[1]>ref[1] and High<ref then
ref[1] because the last 2 candles must be one above and the other below the signal line “ref” in that moment.
With these corrections the Williams ts seem to work a little better than the MFE ts