Bonjour à tous, voici un petit programme que j’ai codé. J’aimerai savoir s’il y a des erreurs ou non.
Dans mon idée voilà ce que j’aimerai faire.
Si l’on a une bougie baissière suivie de 3 haussières alors j’achète 5 lots si je ne suis pas déjà en position acheteuse (sinon je ne fais rien), si je suis en position vendeuse (-5 lots) alors j’achète 10 lots de manières à avoir +5 lots.
Inversement à la vente, si l’on a une bougie haussière suivie de 3 baissières alors je short 5 lots si je ne suis pas déjà en position vendeuse (sinon je ne fais rien), si je suis en position acheteuse (+5 lots) alors je vends 10 lots de manière à avoir -5 lots.
Dans tous les cas stop loss à 20 points et take profit à 7 points
Je trade uniquement de 8h03 à 17h00 avec une coupure le midi.
Merci par avance pour votre aide.
//4bougies
bougie4 = open[3]>close[3]
bougie3 = open[2]<close[2]
bougie2 = open[1]<close[1]
bougie1 = open[0]<close[0]
bougie44 = open[3]<close[3]
bougie33 = open[2]>close[2]
bougie22 = open[1]>close[1]
bougie11 = open[0]>close[0]
//heure de trading
if time>080300 and time<170000 then
timer=1
else
timer=0
endif
//coupure midi
if time>120000 and time<150000 then
timer2=0
else
timer2=1
endif
//conditions signal
if bougie4 and bougie3 and bougie2 and bougie1 then
position = 1
elsif bougie44 and bougie33 and bougie22 and bougie11 then
position = -1
else
position = 0
endif
//Contre signal achat
IF NOT LongOnMarket AND Shortonmarket and position=1 and timer=1 and timer2=1 then
EXITSHORT 5 CONTRACTS AT MARKET
BUY 5 CONTRACTS AT MARKET
Set stop ploss 20
set target pProfit 7
endif
// Signal achat
if not onmarket and position=1 and timer=1 and timer2=1 then
BUY 5 CONTRACTS AT MARKET
Set stop ploss 20
set target pProfit 7
endif
// Contre signal vente
IF NOT ShortOnMarket AND Longonmarket and position=-1 and timer=1 and timer2=1 then
SELL 5 CONTRACTS AT MARKET
SELLSHORT 5 CONTRACTS AT MARKET
Set stop ploss 20
set target pProfit 7
endif
// Signal vente
if not onmarket and position=-1 and timer=1 and timer2=1 then
SELLSHORT 5 CONTRACTS AT MARKET
Set stop ploss 20
set target pProfit 7
endif
Je n’ai pas testé mais suite à une lecture rapide du code, cela me semble être ok, mais si on pourrait bien sûr simplifier un peu le code.
Qu’est ce qui te fait penser qu’il y a un problème quelque-part ?