We buy when the price is below the EMA200 and above the EMA50 (sik!).
As a filter we use a simple linear regression slope.
We sell when the price is above the EMA28 and below the EMA7.
It really couldn’t be easier
thats all for today
until then
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
//------------------------------------------------------------------------- // maincode : everytimelong g50 k100 lrs //------------------------------------------------------------------------- // ger40 longonly strategie // timezone europe, berlin // timeframe 4h // created and coded by johnscher defparam cumulateorders = true // false is working well once ordersize = 1 TradingDay = Opendayofweek = 1 or Opendayofweek = 2 or Opendayofweek = 3 or Opendayofweek = 4 or Opendayofweek = 5 TradingTime = time >= 090000 and time <= 170000 c1 = close > Exponentialaverage [50] (close) c2 = close < Exponentialaverage [100] (close) c3 = close > close [1] c4 = LinearRegressionSlope[100] (close) < 0 IF TradingDay and TradingTime then If c1 and c2 and c3 and c4 then buy ordersize contract at market Endif ENDIF c5 = close < Exponentialaverage [7] (close) c6 = close > Exponentialaverage [28] (close) IF longonmarket then If c5 and c6 then sell at market Endif Endif Set Stop %Loss 10 //as insurance Set Target %profit 2.75 |
Share this
No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.
ProRealTime ITF files and other attachments :
Filename : download the ITF files
How to import ITF files into ProRealTime platform?
PRC is also on YouTube, subscribe to our channel for exclusive content and tutorials
Hi John, I like the code a lot, but i can only get it to work cumulateorders in backtesting. It doesn’t do it in live situation. Any reason why?
Many thanks
Rich
Da error en la linea 9 🙁
If you import the itf.file the code works very well, with a big loss at the end based to the attack of Russia on Ukraine
Ciao John. grazie per la condivisione. Sul DAX A 4 H HO FATTO PICCOLE MODIFICHE E RISULTATI SONO OTTIMI ANCHE CON NOTIZIE NEGATIVE COME LA GUERRA IN UCRAINA, TI COPIO DI SEGUITO IL CODICE:
defparam cumulateorders = true // false is working well
once ordersize = 1
TradingDay = ((dayofweek=1 and (time=050000 or time=090000 or time=130000 or time=170000)) or (dayofweek=2 and (time=010000 or time=050000 or time=130000 or time=170000)) or (dayofweek=3 and (time=090000 or time=130000 or time=210000)) or (dayofweek=4 and time=050000) or (dayofweek=5 and (time=010000 or time=090000 or time=130000 or time=170000)))
//TradingTime = time >= 090000 and time Exponentialaverage [45] (close)
c2 = close close [1]
c4 = LinearRegressionSlope[95] (close) < 0
IF TradingDay then
If c1 and c2 and c3 and c4 then
buy ordersize contract at market
Endif
ENDIF
c5 = close Exponentialaverage [21] (close)
IF longonmarket then
If c5 and c6 then
sell at market
Endif
Endif
Set Stop %Loss 5.50 //as insurance
Set Target %profit 2.75
//*****************************************************************
if close>open then
marginebv=low-130
elsif close<open then
marginebv= low-115
endif
//tp=300
//stopbv=200
//acquistobreck= LOW-margine
//acquistobv= close -marginebv
if longonmarket then
sell at marginebv stop
endif
SCUSA . ECCO IL CODICE
defparam cumulateorders = true // false is working well
once ordersize = 1
TradingDay = ((dayofweek=1 and (time=050000 or time=090000 or time=130000 or time=170000)) or (dayofweek=2 and (time=010000 or time=050000 or time=130000 or time=170000)) or (dayofweek=3 and (time=090000 or time=130000 or time=210000)) or (dayofweek=4 and time=050000) or (dayofweek=5 and (time=010000 or time=090000 or time=130000 or time=170000)))
//TradingTime = time >= 090000 and time <= 170000
c1 = close > Exponentialaverage [45] (close)
c2 = close < Exponentialaverage [100] (close)
c3 = close > close [1]
c4 = LinearRegressionSlope[95] (close) < 0
IF TradingDay then
If c1 and c2 and c3 and c4 then
buy ordersize contract at market
Endif
ENDIF
c5 = close < Exponentialaverage [9] (close)
c6 = close > Exponentialaverage [21] (close)
IF longonmarket then
If c5 and c6 then
sell at market
Endif
Endif
Set Stop %Loss 5.50 //as insurance
Set Target %profit 2.75
//*****************************************************************
if close>open then
marginebv=low-130
elsif close<open then
marginebv= low-115
endif
//tp=300
//stopbv=200
//acquistobreck= LOW-margine
//acquistobv= close -marginebv
if longonmarket then
sell at marginebv stop
endif
Hola soy nuevo en el mudo robots. Alguien seria tan amable de poner el archivo itf.file ya que sin él no sé como poner el código en el PRT. GRACIAS!!
I found this works well on the DOW
Hi John,
Is your strategy suitable for daily SPY?
Regards
Hi, ich bin leider Anfänger, habe den Code zwar importiert, aber scheinbar läuft er nicht auf D1, was muss ich ändern, oder kann jemand den code auf D1 oder W1 umschreiben, danke.