ProRealTime
Pour partager sur nos trades en direct en Day Trading et en Scalping ainsi que nos informations ou réactions sur l'Actualité Boursière. Ces sont les files du jour pour partager sur notre trading. Files du jour
Répondre • Page 1 sur 1

problème clôture trade auto dès objectif journalier atteint

par bentrading10 » 28 mai 2020 20:55

bonjour à tous je suis tout nouveau sur le forum et c'est mon premier post.
Je suis trader amateur sur prorealtime et ig en compte démo depuis maintenant trois mois.
Je souhaite me lancer dans le trade auto mais j'ai quelque difficultés sur deux lignes de code.

Je compte sur votre aide :D :D :D :D :D

Voici ma problématique:
En trade auto je souhaites deux variantes importantes, respecter mes horaires définies et arrêter le trade auto des que l'objectif de gain ou de perte est atteint.

Mon code pour l’arrêt des trade entre midi et 13h fonctionne parfaitement
(ce code est important car c'est le moment ou mon ration de perte /gain est le plus défavorable)
jusqu'au moment ou j’intègre mon nouveau code de startegie journaliére.
A ce moment la plus aucun de ces 2 codes ne fonctionne.

SI vous pouviez m'aider, voici mon code complet
Merci Beaucoup




// Définition des paramètres du code
DEFPARAM CumulateOrders = False // Cumul des positions désactivé
// Annule tous les ordres en attente et ferme toutes les positions à 0:00, puis empêche toute création d'ordre avant l'heure "FLATBEFORE".
DEFPARAM FLATBEFORE = 090000
// Annule tous les ordres en attente et ferme toutes les positions à l'heure "FLATAFTER"
DEFPARAM FLATAFTER = 170000

// Empêche le système de placer des ordres pour entrer sur le marché ou augmenter la taille d'une position avant l'heure spécifiée
noEntryBeforeTime = 100000
timeEnterBefore = time >= noEntryBeforeTime

// Empêche le système de placer des ordres pour entrer sur le marché ou augmenter la taille d'une position après l'heure spécifiée
noEntryAfterTime = 163000
timeEnterAfter = time < noEntryAfterTime

// Empêche le système de placer des ordres pendant midi
macondition = time>1150000 and time<1250000

// Conditions pour ouvrir une position acheteuse
indicator1 = Stochastic[14,3](close)
c1 = (indicator1 >= indicator1)
indicator2 = rsi[14](close)
c2 = (indicator2 >= indicator2)

IF (c1 AND c2) AND timeEnterBefore AND macondition=0 AND timeEnterAfter THEN
BUY 1 SHARES AT MARKET
ENDIF


// Conditions pour fermer une position acheteuse
indicator3 = Stochastic[14,3](close)
c3 = (indicator3 > indicator3)
indicator4 = macd[12,26,9](close)
c4 = (indicator4 >= indicator4)
indicator5 = rsi[14](close)
c5 = (indicator5 >= indicator5)

IF c3 AND c4 AND c5 THEN
SELL AT MARKET
ENDIF

//indice de scalping

inTimeInterval = time>=090000 and time>1150000 and time<1250000 and time<170000

//short term stochastic
sto = stochastic[5,3]
//long term stochastic
stol = stochastic[14,1]

ma100 = average[100,2](close)
ma50 = average[50,2](close)

//atr = averagetruerange[14]
if inTimeInterval and barindex>14 then
if sto<01.1 and close>ma100 then
endif
if sto>60.9 and close<ma100 then
endif
if stol>20.99 and sto<7.1 and close>ma100 then
endif
if stol<40.01 and sto>60.9 and close<ma100 then
endif
if stol>40.01 and sto<6.1 and close>MA100 and close>MA50 then
endif
if stol<40.01 and sto>70.9 and close<MA100 and close<MA50 then
endif
endif


// Stops et objectifs
SET STOP $LOSS 6
SET TARGET $PROFIT 40

//Trailing stop
trailingstop = 0.6

//resetting variables when no trades are on market
if not onmarket then
MAXPRICE = 0
MINPRICE = close
priceexit = 0
endif

//case short order
if shortonmarket then
MINPRICE = MIN(MINPRICE,close) //saving the MFE of the current trade
if tradeprice(1)-MINPRICE>=trailingstop*pointsize then //if the MFE is higher than the trailingstop then
priceexit = MINPRICE+trailingstop*pointsize //set the exit price AT the MFE + trailing stop price level
endif
endif

//case LONG order
if longonmarket then
MAXPRICE = MAX(MAXPRICE,close) //saving the MFE of the current trade
if MAXPRICE-tradeprice(1)>=trailingstop*pointsize then //if the MFE is higher than the trailingstop then
priceexit = MAXPRICE-trailingstop*pointsize //set the exit price AT the MFE - trailing stop price level
endif
endif

//exit on trailing stop price levels
if onmarket and priceexit>0 then
EXITSHORT AT priceexit STOP
SELL AT priceexit STOP
endif

//--parametre d'arret des trades des que l'objectif journalier est atteint
MaxDailyProfit=40 //objectif de profit journalier
MaxDailyLoss=50 //Perte max journaliere


// lancement du trade
once TradeAllowed=1

// remise a zéro du trade
If intradaybarindex=0 then
MyProfit=STRATEGYPROFIT
TradeAllowed=1
endif

// tester si le profit de la stratégie de la journée est actuellement supérieur au bénéfice quotidien autorisé ou inférieur à la perte journalière autorisée
If StrategyProfit>=MyProfit+MaxDailyProfit or Strategyprofit<=MyProfit-MaxDailyLoss then
TradeAllowed=0
endif

// initier un nouvel achat
if TradeAllowed=1 and c1 AND c2 then
buy 1 lot AT market
endif

Re: problème clôture trade auto dès objectif journalier atte

par Benoist Rousseau » 28 mai 2020 20:57

Bonjour , avant de participer au forum, il faut se présenter dans présentation des membres comme l'exige la nétiquette. Cela permet aux membres de mieux répondre à tes questions en connaissant ton niveau, ton expérience et ton compte sera débloqué.

Re: problème clôture trade auto dès objectif journalier atte

par Amarantine » 28 mai 2020 22:02

Présentation faite. :mercichinois:

Sujets similaires
respect de l'objectif journalier ou respects des signaux ?
par ludo88 » 11 juil. 2016 14:02 (6 Réponses)
Cloture de trade en trading auto
par Bertrand44 » 03 nov. 2018 17:02 (7 Réponses)
Trade automatique si le cours atteint telle valeur
Fichier(s) joint(s) par tjee » 19 janv. 2022 20:52 (3 Réponses)
Vous avez atteint les 1000 messages
Fichier(s) joint(s) par Anonyme01 » 08 déc. 2014 14:42 (61 Réponses)
Le Nikkei a atteint son plus haut depuis aout 2015
par Davidof » 04 oct. 2017 01:41 (3 Réponses)
Succession (pour un ami atteint d'un cancer).
par Burzum » 06 oct. 2017 17:41 (18 Réponses)
SL non exécuté si TP atteint dans la même bougie
par BearIsDead » 19 juin 2018 17:48 (8 Réponses)
l'entourage de Vladimir Poutine atteint du Covid-19
Fichier(s) joint(s) par Benoist Rousseau » 16 sept. 2021 18:23 (4 Réponses)
système auto qui fait +de 10 points nets par trade ?
par ticktack » 26 nov. 2016 17:35 (34 Réponses)