JohnScher

Buy if the price has fallen

Category: Strategies By: JohnScher Created: February 15, 2022, 9:36 AM
February 15, 2022, 9:36 AM
Strategies
10 Comments
Buy if the price has fallen

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

//-------------------------------------------------------------------------
// 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

Download
Filename: Buy-if-the-price-has-fallen.itf
Downloads: 654
JohnScher
JohnScher Veteran
Operating in the shadows, I hack problems one by one. My bio is currently encrypted by a complex algorithm. Decryption underway...
Author’s Profile

Comments

JohnScher
10 months ago
#

One of my best strategies... very simple, easy to remember, and can be implemented manually. Please run a backtest today... it is “out of sample,” so to speak runs on de40 4H

gatowman
2 years ago
#

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.

thomas2004ch
4 years ago
#

Hi John, Is your strategy suitable for daily SPY? Regards

Darren Nash
4 years ago
#

I found this works well on the DOW

wally
4 years ago
#

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!!

adconsulting
5 years ago
#

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

adconsulting
5 years ago
#

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

JohnScher
5 years ago
#

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

Desastrader
5 years ago
#

Da error en la linea 9 :-(

Richk87
5 years ago
#

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

ProRealCode ProRealCode
Loading...