SCALPING CAC40 10 SECONDS

Category: Strategies By: WE ARE SOCIETY Created: November 3, 2023, 10:15 AM
November 3, 2023, 10:15 AM
Strategies
99 Comments

Here is a Supertrend strategy for very short term trading on French CAC40. Let’s break it down for you. Let’s take a step-by-step look at what this algorithm does.

1. Setup:

  • Timeframes: The primary timeframe for this script is set to 10 seconds, meaning it processes price data every 10 seconds. However, the code switches between various timeframes – from 30 seconds up to 10 minutes – depending on the calculations.
  • Capital & Position Sizing: Your initial capital is set at 500 units, and the position size (the number of shares/contracts to trade) is calculated based on a percentage of the closing price. There’s also a mechanism (MM) to adjust position size based on the strategy’s profit, ensuring you don’t overcommit or underutilize your capital.

2. Identifying Trading Conditions:

The algorithm uses several indicators and conditions to decide when to trade:

  • Supertrend: A common trend-following indicator, this script calculates the Supertrend on multiple timeframes.
  • Day & Time Conditions: The script checks the time of day and day of the week. There are very specific conditions – for instance, a particular hour on a Tuesday or a certain timeframe on Fridays.

3. Trade Execution:

  • Buy Conditions:
    • If the current price is lower than the price 80 bars ago (close[80]).
    • It’s within the trading hours (from 9:10 AM to 5 PM).
    • The stopa condition (a complex mix of time and Supertrend) is not active.

    If all these conditions are met, the algorithm buys n shares at the market price.

  • Sell Conditions:
    • If the current price is higher than the price 30 bars ago (close[30]).
    • It’s within the trading hours (from 9 AM to 5 PM).
    • The stopv condition (another complex mix of time and Supertrend) is not active.

    When these are met, the algorithm sells short n shares at the market price.

4. Risk Management:

  • Stop Loss: After entering a trade, if the price goes against the trade by 38 units, the position will be automatically closed to limit the loss.
  • Target Profit: If the trade reaches a profit of 5 units, it will be closed. This target increases to 6 units if the time is between 4 PM and 5 PM.

Conclusion:

This trading algorithm is built on a combination of trend-following techniques, specific time conditions, and risk management rules. By looking at the current price in relation to past prices and the Supertrend, it makes buy or sell decisions. The added time conditions likely aim to avoid certain market anomalies that can occur at specific times.

It’s essential to test any trading strategy on historical data and in a simulated environment before going live. Remember, past performance doesn’t guarantee future results. Stay safe, and happy trading!

DEFPARAM cumulateOrders = False
//defparam flatafter = 174000
timeframe (10 second)
capital=500
taille=(capital/(close*5.5/100))
MM = 1 // = 1 for optimization
if MM = 0 then
positionsize=taille
ENDIF
if MM = 1 then
ONCE startpositionsize =taille
ONCE factor = 1 // factor of 10 means margin will increase/decrease @ 10% of strategy profit; factor 20 = 5% etc
ONCE factor2 = 2 // tier 2 factor
ONCE margin = (close*.08) // tier 1 margin value of 1 contract in instrument currency; change decimal according to available leverage
ONCE margin2 = (close*.08)// tier 2 margin value of 1 contract in instrument currency; change decimal according to available leverage
ONCE tier1 = 200 // NAS €1 IG first tier margin limit
ONCE maxpositionsize = 2000 // NAS €1 IG tier 2 margin limit
ONCE minpositionsize = 1 // enter minimum position allowed
IF Not OnMarket THEN
positionsize = startpositionsize + Strategyprofit/(factor*margin)
ENDIF
IF Not OnMarket THEN
IF startpositionsize + Strategyprofit/(factor*margin) > tier1 then
positionsize = (((startpositionsize + (Strategyprofit/(factor*margin))-tier1)*(factor*margin))/(factor2*margin2)) + tier1 //incorporating tier 2 margin
ENDIF
IF Not OnMarket THEN
if startpositionsize + Strategyprofit/(factor*margin) < minpositionsize THEN
positionsize = minpositionsize //keeps positionsize from going below allowed minimum
ENDIF
IF (((startpositionsize + (Strategyprofit/(factor*margin))-tier1)*(factor*margin))/(factor2*margin2)) + tier1 > maxpositionsize then
positionsize = maxpositionsize// keeps positionsize from going above IG tier 2 margin limit
ENDIF
ENDIF
ENDIF
ENDIF
n=positionsize
if time=090000 then
ouverture=close
endif
timeframe(10 minute)
if (supertrend[3,10]-6)=<close then
haut10=1
endif
if (supertrend[3,10]+3)>close then
haut10=0
endif
TIMEFRAME(3 minute)
if (supertrend[3,3]-3)=<close then
haut3=1
endif
if (supertrend[3,3]+1)>close then
haut3=0
endif
timeframe (30 second)
if (supertrend[3,6]-1)=<close then
haut30s=1
endif
if (supertrend[3,6]+7)>close then
haut30s=0
endif
timeframe (5 minute)
if (supertrend[3,10]-3)=<close then
haut5m=1
endif
if (supertrend[3,10]+3)>close then
haut5m=0
endif
timeframe (10 second)
rem avant 190 10
if (time>100000 and time<110000) or (time>123500 and time<133000) or (dayofweek=2 and ((time>110000 and time<144000)or time>165000))  or (dayofweek=3 and ((time>121500 and time<131500) or haut3=0)) or (time>160000 and time<161500)  or (dayofweek=1 and time<100000) or (dayofweek=4 and ((haut10=0 or haut3=0) or (time>093000 and time<100000))) or (dayofweek=1 and (haut3=0 or close>(highest[40][1]-10))) or (dayofweek=2 and haut3=0 and time<110000) or (dayofweek=4  and (close>(highest[60][1]-10))) or (dayofweek=5 and close>(highest[60][1]-10)) or (dayofweek=4 and time>153000 and time<170000) or (dayofweek=5 and time<110000) or (haut10=0 and close>(highest[40][1]-15)) or (dayofweek=5 and (haut30s=0 or haut3=0) and time<120000)or (dayofweek=1 and ((haut10=0)  or close>(highest[40][1]-15))) or (dayofweek=3  and time>143000 and haut30s=0) or ((dayofweek=4 or dayofweek=1) and haut5m=0) or ((dayofweek=4) and (close>(highest[50][1]-15)) and time<153000) or (dayofweek=5 and time>152900 and time<154000) or (dayofweek=5 and haut30s=0 and time>140000 and time<153500) or ((dayofweek=2 or dayofweek=3) and (time>150000 and time<153500)) or (dayofweek=2 and time>152900 and time<154500)or (dayofweek=3 and  time>110000 and time<113500) or (time>=161500 and time<163000) or (dayofweek=5 and haut30s=0) then
stopa=1
else
stopa=0
endif
rem
if (time>=100000 and time<103000) or (time>130500 and time<140000) or (dayofweek=5 and (time>103000 and time<121000)) or (dayofweek=4 and close<(lowest[45][1]+12)) or (dayofweek=2 and (haut3=1 or haut30s=1)) or (dayofweek=4 and haut3=1) or ((dayofweek=5 or dayofweek=3) and (close<(lowest[150][1]+19) or (close<(lowest[60][1]+25))))  or (time>162500 and time<170000) or (dayofweek=1 and (close<(lowest[40][1]+10) or (time>=091000 and time<104500))) or (time>093000 and time<100000) or (dayofweek=2 and time>120000 and time<130000) or (dayofweek=4 and ((time>111500 and time<130000) or (time>144500 and time<150000))) or (dayofweek=1 and haut3=1) or ((dayofweek=4 or dayofweek=5) and ((close<(lowest[150][1]+21)) or (time>151000 and time<153000))) or (dayofweek=4 and time<091000) or (dayofweek=4 and (close<(lowest[50][1]+15))) or (dayofweek=2 and ((time>110000 and time<111500) or (time>142500 and time<150000))) or (dayofweek=1 and time>133000 and time<143000) or (dayofweek=2 and time>161000 and time<163000) or (close<lowest[90][1]+10) or (dayofweek=2 and time>150000 and time<153000) or (dayofweek=1 and ((haut10=1) or (time>120000 and time<130000 and close<(lowest[40][1]+15)))) then
stopv=1
else
stopv=0
endif
REM and  close<(close[80])
IF (time>=091000 and time<170000) and  close<(close[80]) then
feuvert=1
else
feuvert=0
endif
rem and (medianprice+1)=<bollingerup[17](close)
REM and close>(close[20])
if (time>=090000 and time<170000) and close>(close[30]) then
feurouge=1
else
feurouge=0
endif
if feuvert=1  and not onmarket and stopa=0 then
buy n share at market
endif
if feurouge=1   and not onmarket and stopv=0 then
sellshort n share at market
endif
set stop loss 38
set target profit 5
if time>160000 and time<170000 then
set target profit 6
endif

Download
Filename: SCALPING-CAC40-10-SECONDES.itf
Downloads: 674
WE ARE SOCIETY Senior
I usually let my code do the talking, which explains why my bio is as empty as a newly created file. Bio to be initialized...
Author’s Profile

Comments

Logo Logo
Loading...