Stanko

BOX 7 o'clock with CAC40 intraday strategy

Category: Strategies By: Stanko Created: August 21, 2023, 4:50 PM
August 21, 2023, 4:50 PM
Strategies
6 Comments
BOX 7 o'clock with CAC40 intraday strategy

I would like to share a simple intraday strategy with CAC40, but adaptable also with Ftse100 and Eurostoxx.

Improvements and suggestions are welcome, as well as long term backtesting (I get to 100k units)

Main points:

  • 1-minute chart
  • The code works on the 1-hour timeframe to calculate the highs and lows
  • The code works on the 30-minute(long) and 15-minute(short) timeframe to handle the trailing stop
  • The trade still closes by 10 p.m.

There are two codes, one for LONG and one for SHORT.

DEFPARAM CumulateOrders = False
DEFPARAM FLATAFTER = 220000
Timeframe (1 Hour, Updateonclose)
//Once $MAXI[0] = High
//Once $mini[0] = Low
Once COMPRA = High

//Timeframe (1 Hour, Updateonclose)

Timeframe (1 Hour, Updateonclose)
IF Time = 080000 AND not OnMarket THEN
COMPRA = Highest[7](high[1]) + 5*pipsize
BUY 1 CONTRACT AT COMPRA STOP
ENDIF
//ENDIF


Timeframe (30 minutes, Updateonclose)
SET STOP pLOSS 70
//////////////////////////////////////////////////////////////////////////////////////////////////////////
//                                Trailing Stop
//------------------------------------------------------------------------------------
IF Not OnMarket THEN
TrailStart    = 10          //10     Start trailing profits from this point
BasePerCent   = 0.100       //10.0%  Profit to keep
StepSize      = 6           //6      Pips chunks to increase Percentage
PerCentInc    = 0.100       //10.0%  PerCent increment after each StepSize chunk
RoundTO       = -0.5        //-0.5   rounds to Lower integer,  +0.4 rounds to Higher integer
PriceDistance = 7 * pipsize//8.9    minimun distance from current price
y1            = 0
y2            = 0
ProfitPerCent = BasePerCent
ELSIF LongOnMarket AND close > (TradePrice + (y1 * pipsize)) THEN //LONG
x1 = (close - tradeprice) / pipsize                            //convert price to pips
IF x1 >= TrailStart THEN                                       //go ahead only if N+ pips
Diff1         = abs(TrailStart - x1)
Chunks1       = max(0,round((Diff1 / StepSize) + RoundTO))
ProfitPerCent = BasePerCent + (BasePerCent * (Chunks1 * PerCentInc))
ProfitPerCent = max(ProfitPerCent[1],min(100,ProfitPerCent))
y1 = max(x1 * ProfitPerCent, y1)                            //y = % of max profit
ENDIF
ELSIF ShortOnMarket AND close < (TradePrice - (y2 * pipsize)) THEN//SHORT
x2 = (tradeprice - close) / pipsize                            //convert price to pips
IF x2 >= TrailStart THEN                                       //go ahead only if N+ pips
Diff2         = abs(TrailStart - x2)
Chunks2       = max(0,round((Diff2 / StepSize) + RoundTO))
ProfitPerCent = BasePerCent + (BasePerCent * (Chunks2 * PerCentInc))
ProfitPerCent = max(ProfitPerCent[1],min(100,ProfitPerCent))
y2 = max(x2 * ProfitPerCent, y2)                           //y = % of max profit
ENDIF
ENDIF
IF y1 THEN                                        //Place pending STOP order when y>0
SellPrice = Tradeprice + (y1 * pipsize)        //convert pips to price
IF abs(close - SellPrice) > PriceDistance THEN
IF close >= SellPrice THEN
SELL AT SellPrice STOP
ELSE
SELL AT SellPrice LIMIT
ENDIF
ELSE
SELL AT Market
ENDIF
ENDIF
IF y2 THEN                                        //Place pending STOP order when y>0
ExitPrice = Tradeprice - (y2 * pipsize)        //convert pips to price
IF abs(close - ExitPrice) > PriceDistance THEN
IF close <= ExitPrice THEN
EXITSHORT AT ExitPrice STOP
ELSE
EXITSHORT AT ExitPrice LIMIT
ENDIF
ELSE
EXITSHORT AT Market
ENDIF
ENDIF
SET STOP pLOSS 70
DEFPARAM CumulateOrders = False
DEFPARAM FLATAFTER = 220000
Timeframe (1 Hour, Updateonclose)
//Once $MAXI[0] = High
//Once $mini[0] = Low
Once VENDI = Low

//Timeframe (1 Hour, Updateonclose)

Timeframe (1 Hour, Updateonclose)
IF Time = 090000 AND not OnMarket THEN
VENDI = Lowest[7](low[1]) - 5*pipsize
SELLSHORT 1 CONTRACT AT VENDI STOP
ENDIF

Timeframe (15 minutes, Updateonclose)
SET STOP pLOSS 70
//////////////////////////////////////////////////////////////////////////////////////////////////////////
//                                Trailing Stop
//------------------------------------------------------------------------------------
IF Not OnMarket THEN
TrailStart    = 10          //10     Start trailing profits from this point
BasePerCent   = 0.100       //10.0%  Profit to keep
StepSize      = 6           //6      Pips chunks to increase Percentage
PerCentInc    = 0.100       //10.0%  PerCent increment after each StepSize chunk
RoundTO       = -0.5        //-0.5   rounds to Lower integer,  +0.4 rounds to Higher integer
PriceDistance = 7 * pipsize//8.9    minimun distance from current price
y1            = 0
y2            = 0
ProfitPerCent = BasePerCent
ELSIF LongOnMarket AND close > (TradePrice + (y1 * pipsize)) THEN //LONG
x1 = (close - tradeprice) / pipsize                            //convert price to pips
IF x1 >= TrailStart THEN                                       //go ahead only if N+ pips
Diff1         = abs(TrailStart - x1)
Chunks1       = max(0,round((Diff1 / StepSize) + RoundTO))
ProfitPerCent = BasePerCent + (BasePerCent * (Chunks1 * PerCentInc))
ProfitPerCent = max(ProfitPerCent[1],min(100,ProfitPerCent))
y1 = max(x1 * ProfitPerCent, y1)                            //y = % of max profit
ENDIF
ELSIF ShortOnMarket AND close < (TradePrice - (y2 * pipsize)) THEN//SHORT
x2 = (tradeprice - close) / pipsize                            //convert price to pips
IF x2 >= TrailStart THEN                                       //go ahead only if N+ pips
Diff2         = abs(TrailStart - x2)
Chunks2       = max(0,round((Diff2 / StepSize) + RoundTO))
ProfitPerCent = BasePerCent + (BasePerCent * (Chunks2 * PerCentInc))
ProfitPerCent = max(ProfitPerCent[1],min(100,ProfitPerCent))
y2 = max(x2 * ProfitPerCent, y2)                           //y = % of max profit
ENDIF
ENDIF
IF y1 THEN                                        //Place pending STOP order when y>0
SellPrice = Tradeprice + (y1 * pipsize)        //convert pips to price
IF abs(close - SellPrice) > PriceDistance THEN
IF close >= SellPrice THEN
SELL AT SellPrice STOP
ELSE
SELL AT SellPrice LIMIT
ENDIF
ELSE
SELL AT Market
ENDIF
ENDIF
IF y2 THEN                                        //Place pending STOP order when y>0
ExitPrice = Tradeprice - (y2 * pipsize)        //convert pips to price
IF abs(close - ExitPrice) > PriceDistance THEN
IF close <= ExitPrice THEN
EXITSHORT AT ExitPrice STOP
ELSE
EXITSHORT AT ExitPrice LIMIT
ENDIF
ELSE
EXITSHORT AT Market
ENDIF
ENDIF
SET STOP pLOSS 70

Saluti.

Download
Filename: BOX-ore-7-Long.itf
Downloads: 234
Download
Filename: BOX-ore-7-Short.itf
Downloads: 187
Stanko
Stanko Senior
As an architect of digital worlds, my own description remains a mystery. Think of me as an undeclared variable, existing somewhere in the code.
Author’s Profile

Comments

taklause
3 years ago
#

I was wondering, you said it works on the 1 min Chart, but you never use it in the code as timeframe. Does it in a one minute intervall trigger the other timeframes too? Even if they have UpdateOnClose? I Checked your exists and entries, all are on 15,30,45,00 for short and 00,30 for long.

Stanko
3 years ago
#

Ciao taklause. Utilizzando il grafico a 1 minuto e fino al grafico a 15 minuti il codice funziona regolarmente sia nella versione Long che Short. Nello specifico la versione Long può essere usata solo con grafici da 1 fino a 30 minuti perchè il trailing stop è settato a 30 minuti. La versione Short può essere usata solo con grafici da 1 a 15 minuti perchè il trailing stop è settato a 15 minuti. Il motivo di questa differenza tra le due versioni è solo per un tentativo di ottimizzazione del codice.

Stanko
3 years ago
#

Ciao Crusoe, grazie per il commento: confermo che il trailing stop non funziona bene. Provo a chiedere aiuto a Roberto o Nicolas. Buona giornata.

crusoe76
3 years ago
#

Hi Stanko, thanks to share your strategy, I'm currently testing live, 2 things first trailing stop not working, and second it start long positon today and at 9am had notification that short stratedy failed.

crusoe76
3 years ago
#

Ciao sto testando su uk100 e su cac40. Tutti e due sistemi hanno aperto long alle 8am, poi alle 9am ho ricevuo due notifiche che i due sistemi short erano stoppati. Su tutti e due i sistemi long il trailing stop si e attivato per poi tornare alla posizione iniziale. Il cac40 long e ancora aperto,mentre il uk100 era con un 40 punti di profitto e poi il sitema l'ha chiuso con 3 punti di profitto. Non sono sicuro che il trailing stop funzioni bene. Grazie mille

Stanko
3 years ago
#

Ciao Crusoe76, questa mattina alle ore 8 il mio sistema ha aperto una posizione Long a 7.352,30 ed attualmente la posizione è ancora aperta senza aver ricevuto notifiche. Forse stai testando LARRY CONNOR? Buona giornata

ProRealCode ProRealCode
Loading...