Last Minute Bar strategy (DAX,FTSE,DOW)

Category: Strategies By: Leo Created: March 9, 2018, 10:54 AM
March 9, 2018, 10:54 AM
Strategies
12 Comments

I have an strategy that I usually trade manually, the following is the code for its automatisation.  I tested in 100K bar with no WF, I do not use WF because this scenario happens very seldom. Since now I will activated for trading live.

Here is the description for short entries (long entries are opposite):

  • The markets is overbought at 17:29 (european last minute market). I define overbought market when the market is moving with a very strong trend: one moving average has been above another one for a long period of time without crossing each other
  • Many traders are willing to close positions in the last minutes for not let open positions overnight
  • We short entry in the last minute.

I know that this strategy is catching a knife that is falling but very reliable somehow.

These are the settings for DAX, FTSE and DOW JONES:

For DAX:

  • P1=5 //period for the fist moving average. From 3 to 15
  • P2=33 //period for the second moving average. From 20 to 30
  • Pi=70  // numbers of periods without crossing the moving average
  • maxrisk0=12 //pips per trade to risk
  • Kp=3 // risk-reward  ratio from 1 to 3
  • Kt=0 // extra time for closing positions. From 0 to 3

For FTSE:

  • P1=2 //period for the fist moving average. From 3 to 15
  • P2=25 //period for the second moving average. From 20 to 30
  • Pi=60  // numbers of periods without crossing the moving average
  • maxrisk0=7 //pips per trade to risk
  • Kp=3 // risk-reward  ratio from 1 to 3
  • Kt=0 // extra time for closing positions. From 0 to 3

For Dow Jones (another time):

  • P1=8 //period for the fist moving average. From 3 to 15
  • P2=17 //period for the second moving average. From 20 to 30
  • Pi=40  // numbers of periods without crossing the moving average
  • maxrisk0=12 //pips per trade to risk
  • Kp=3 // risk-reward  ratio from 1 to 3
  • Kt=0 // extra time for closing positions. From 0 to 3

Hope you like it and improved.  Since now I will activate it for trading live.

//LAST MINUTE BAR
//Autor: LEO

DEFPARAM CumulateOrders = false // Cumulating positions deactivated
DEFPARAM PreLoadBars = 5000 //cargar informacion


//VARIABLES TO BE OPTIMIZED
P1=6 //period for the fist moving average. From 3 to 15
P2=23 //period for the second moving average. From 20 to 30
Pi=50 // numbers of periods without crossing the moving average
maxrisk0=6 //pips per trade to risk
Kp=2 // risk-reward ratio from 1 to 3
Kt=0 // extra time for closing positions. From 0 to 3

IF time > 150000 and time < 180000 then

 SMA1=average[P1](close)
 SMA2=average[P2](close)

 a0= SMA1 > SMA2
 a1= lowest[Pi](a0) =1

 b0= SMA1 < SMA2
 b1= lowest[Pi](b0) =1

 myATR=average[Pi](range)+2*STD[Pi](range)

 IF time=172900 then
  IF b1 Then
   stoplosslong=min( (close-low+myATR)/pipsize , maxrisk0)
   BUY 1 CONTRACTS AT MARKET
   SET STOP pLOSS stoplosslong
   SET TARGET pPROFIT Kp*stoplosslong
  ENDIF

 IF a1 then
  StopLossShort=min( (high-close+myATR)/pipsize , maxrisk0)
  SELLSHORT 1 CONTRACTS AT MARKET
  SET STOP pLOSS StopLossShort
  SET TARGET pPROFIT Kp*StopLossShort
 ENDIF
ENDIF

// ---> exit long
IF longonmarket then

 IF (Barindex-TRADEINDEX)>5+Kt and (close-TRADEPRICE)/pipsize > stoplosslong THEN
  SELL AT MARKET
 ENDIF

 IF (Barindex-TRADEINDEX)>7+Kt and (close-TRADEPRICE)/pipsize > 0.5*stoplosslong THEN
  SELL AT MARKET
 ENDIF

 IF (Barindex-TRADEINDEX)>9+kt and (close-TRADEPRICE)/pipsize > 0 THEN
  SELL AT MARKET
 ENDIF

 IF (Barindex-TRADEINDEX)>11+Kt and (close-TRADEPRICE)/pipsize < 0 THEN
  SELL AT MARKET
 ENDIF

endif

// ---> exit short
IF shortonmarket then

 IF (Barindex-TRADEINDEX)>5+Kt and (TRADEPRICE-close)/pipsize > StopLossShort THEN
  EXITSHORT AT MARKET
 ENDIF

 IF (Barindex-TRADEINDEX)>7+Kt and (TRADEPRICE-close)/pipsize > 0.5*StopLossShort THEN
  EXITSHORT AT MARKET
 ENDIF

 IF (Barindex-TRADEINDEX)>9+Kt and (TRADEPRICE-close)/pipsize > 0 THEN
  EXITSHORT AT MARKET
 ENDIF

 IF (Barindex-TRADEINDEX)>11+Kt and (TRADEPRICE-close)/pipsize < 0 THEN
  EXITSHORT AT MARKET
 ENDIF

 ENDIF

ENDIF

Download
Filename: LastMinuteBar-Strategy.itf
Downloads: 946
Leo Veteran
" IF YOU HAVE WEALTH , IT'S A DUTY TO HELP THOSE WHO DON'T " Manoj Bhargava
Author’s Profile

Comments

Logo Logo
Loading...