ProRealCode - Trading & Coding with ProRealTime™
bonjour a tous bon nombre d entre nous utilise un système manuel pour trader qui contient parfois plusieurs indicateur qui prennent de la place sur nos écrans et certain d entre nous n utilise que 2 ou 3 écrans selon leur moyen ou besoin. de plus nous devons parfois attendre et parfois longtemps que nos indicateurs nous donne le signal pour entré en position. en effectuant pas mal de recherche a ce sujet sur internet je suis tombé sur un système semi automatique qui permet d enlevé tout les indicateurs de l écrans et nous donné ce fameux signal par rapport à notre stratégie de plus toute les positions sont comptabilisé et nous permet d avoir un money management a jour. le seul hic est que ce système à été crée il y à 6 ans et les codes de programmation ne sont plus à jour, j ai commencé à partir de la 10.2 et suis maintenant en 10.3 donc je nage complètement d autant plus que ce système contient 7 codes différent le 1er contient les conditions et stratégie que vous programmer ensuite il y 3 long avec le Money management et 3 short et MM. je joint quelques image pour vous donné une idée du résultat. j ai essayer de faire en sorte qu il fonctionne sur la 10.3 mais mon niveau ne me le permet pas si quelqu’un est intéressé pour m aidé à recodé afin de le partagé avec les autres membres de ce forum.
merci
Hello all, many of us use a manual trader system that sometimes contains several indicators that take up space on our screens and some of us use only 2 or 3 screens depending on their means or need. Moreover we sometimes have to wait and sometimes for a long time that our indicators give us the signal to enter into position. By doing a lot of research on this subject on the internet I came across a semi automatic system that allows to remove all the indicators of the screens and gave us this famous signal in relation to our strategy of more all positions are counted and allows us D have a money management a day. The only problem is that this system was created 6 years ago and the programming codes are no longer up to date, I started from 10.2 and am now in 10.3 so I swam all the more so as this system contains 7 different codes the 1st contains the conditions and strategy that you program then there 3 along with Money management and 3 short and MM. I attached a few images to give you an idea of the result. I have tried to make it work on the 10.3 but my level does not allow me if someone is interested to help me recode it in order to share it with the other members of this forum. thank you
/////// A LIRE ATTENTIVEMENT AVANT L'UTILISATION DU TRADING SEMI AUTOMATIQUE ////////
/// LE PROGRAMME CI DESSOUS EST LIBRE DE TOUTE MODIFICATION. EN EFFET, IL VOUS PERMET
/// DE CONSTRUIRE VOTRE STRATEGIE DE TRADING ET DE LA COMMUNIQUER AU TRADING SEMI
/// AUTOMATIQUE. AVANT TOUTE MODIFICATION, PRENEZ SOINS DE COPIER TOUT SON CONTENU
/// DANS UN FICHIER TEXTE QUE VOUS CONSERVEREZ PRECIEUSEMENT.
/// LE TRADING SEMI AUTOMATIQUE N'EST PAS UN SYSTEME DE TRADING. AINSI, POUR L'UTILISER
/// VOUS DEVEZ LUI ADJOINDRE VOTRE SYSTEME DE TRADING PERSONNEL. POUR CE FAIRE, VOUS
/// DEVEZ COPIER ET COLLER VOTRE SYSTEME DE TRADING DANS L'INDICATEUR PROREALTIME
/// 'GNT@SYS' QUE VOUS TROUVEREZ DANS LA LISTE DES INDICATEURS UNE FOIS LE MODULE
/// 'GNT@TSA' INSTALLE SUR VOTRE PLATEFORME. L'INDICATEUR 'GNT@SYS' EST LE SEUL INDICATEUR
/// QUI EST UTILISE PAR LE PROGRAMME 'GNT@TSA'.
/// L'INDICATEUR 'GNT@SYS' EST UNE STRUCTURE PROFORMAT POUR VOUS GUIDER DANS LA
/// COMMUNICATION DES DONNEES NECCESSAIRES AU FONCTIONNEMENT DU 'GNT@TSA'
/// A TITRE D'EXEMPLE, UN SYSTEME DE TRADING FICTIF EST FOURNI PAR DEFAUT DANS L'INDICATEUR
/// 'GNT@SYS'. IL PERMET D'ILLUSTRER L'UTILISATION DU 'GNT@TSA' SUR LE MARCHE DES DEVISES
/// DIT 'FOREX'. ATTENTION, NE PAS UTILISER CE SYSTEME FICTIF !
/// EN VOICI CI DESSOUS UN DESCRIPTIF.
// Signal Alerte : Croissement d'une moyenne mobile exponentielle de 8 périodes avec une
// moyenne mobile exponentielle de 21 périodes
// Signal Entrée en position : Rebond du cours (prix) sur la moyenne mobile
// exponentielle de 21 périodes
// Signal d'invalidation : Croissement, dans le sens inverse au signal d'alerte, des deux
// moyennes mobiles, rapidement après la prise de position sur le marché.
// Signal de prise de bénéfice : Croissement de la moyenne mobile exponentielle de 21
// périodes par le cours de clôture.
// Signal de clôture de position : Croissement, dans le sens inverse au signal d'alerte,
// des deux moyennes mobiles.
// STOP DE PROTECTION A 10 PIPS AU DELA DU PUS HAUT/BAS A L'INSTANT DU SIGNAL
// OBJECTIF DE SORTIE A 40 PIPS AU DELA DU PUS HAUT/BAS A L'INSTANT DU SIGNAL
/////////////////////////////////////////////////////////////////////////////////////////
// Initialisation des variables
/////////////////////////////////////////////////////////////////////////////////////////
/// CI APRES DEUX VARIABLES POUR LA GESTION DE LA TENDANCE DANS LE SYSTEME DE TRADING
/// FICTIF
Trda = 1
Trdv = 0
/// CI APRES, TOUTES LES VARIABLES NECESSAIRES AU TRADING SEMI AUTOMTIQUE POUR VOUS
/// GUIDER DANS LA GESTION DE VOS POSITIONS
LgAle = 1
ShAle = 0
LgSig = 1
ShSig = 0
StopPrice = 0
ObjPrice = 0
LgBenSig = 1
ShBenSig = 0
LgOutSig = 1
ShOutSig = 0
LgInvSig = 1
ShInvSig = 0
/////////////////////////////////////////////////////////////////////////////////////////
// Appel des fonctions externes ou calcul d'indicateurs sous jacents à la stratégie
/////////////////////////////////////////////////////////////////////////////////////////
EMASh = ExponentialAverage[20](close)
EMALg = ExponentialAverage[50](close)
/////////////////////////////////////////////////////////////////////////////////////////
// Gestion des filtres
/////////////////////////////////////////////////////////////////////////////////////////
/// LA TENDANCE EST DEFINIE PAR LA POSITION DE LA MOYENNE MOBILE COURTE, PAR RAPPORT A LA
/// MOYENNE MOBILE LONGUE
If EMASh >= EMALg Then
TRDA = 1
TRDV = 0
Else
TRDA = 0
Endif
If EMASh < EMALg Then
TRDV = 1
TRDA = 0
Else
TRDV = 0
Endif
/////////////////////////////////////////////////////////////////////////////////////////
// Gestion des signaux
/////////////////////////////////////////////////////////////////////////////////////////
// Signal d'alerte //
//------------------//
// LE SIGNAL D'ALERTE ET ISSUE DU CROISSEMENT DES DEUX MOYENNES MOBILES EXPONENTIELLES
LgAle = EMASh crosses over EMALg /// Signal d'alerte à la hausse
ShAle = EMASh crosses under EMALg /// Signal d'alerte à la baisse
// Signal d'entrée en position //
//-----------------------------//
// LE SIGNAL D'ENTREE EN POSITION EST ISSU DU REBOND DES PRIX SUR LA MOYENNE MOBILE EXPONENTIELLE DE 21 PERIODES
LgSig = TRDA AND ((Close crosses over EMALg) OR (Close > EMALg AND OPEN > CLOSE))
ShSig = TRDV AND ((Close crosses under EMALg) OR (Close < EMALg) OR (High >= EMALg AND CLOSE < EMALg)) AND (OPEN < CLOSE)
// Signal d'invalidation de la position //
//-------------------------------------//
// IL Y A INVALIDATION DU SIGNAL SI NOUVEAU CROISSEMENT, DANS LE SENS INVERSE DES DEUX MOYENNES MOBILES.
LgInvSig = EMASh crosses under EMALg
ShInvSig = EMASh crosses over EMALg
// Si vous ne souhaitez pas utiliser un signal d'invalidation, alors il suffit
// d'attribuer la valeur 0 à la variable. Comme ci dessous !
// LgInvSig = 0
// ShInvSig = 0
// Signal de prise de bénéfice //
//----------------------------//
// IL Y A UN SIGNAL DE PRISE DE BENENFICES SI LE COURS EN CLOTURE CROISE LA MOYENNE MOBILE EXPONENTIELLE DE 21 PERIODES
LgBenSig = CLOSE crosses under EMALg
ShBenSig = CLOSE crosses over EMALg
// Si vous ne souhaitez pas utiliser un signal de prise de bénéfice, alors il suffit
// d'attribuer la valeur 0 à la variable. Comme ci dessous !
// LgBenSig = 0
// ShBenSig = 0
// Signal de sortie de position //
//------------------------------//
// IL Y A SIGNAL DE SORTIE SI NOUVEAU CROISSEMENT, DANS LE SENS INVERSE DES DEUX MOYENNES MOBILES.
LgOutSig = EMASh crosses under EMALg
ShOutSig = EMASh crosses over EMALg
/////////////////////////////////////////////////////////////////////////////////////////////
// Stop & Objectif
/////////////////////////////////////////////////////////////////////////////////////////
/// IL EST IMPORTANT DE COMMUNIQUER AU TRADING SEMI AUTOMATIQUE VOTRE NIVEAU DE SORTIE ET
/// VOTRE OBJECTIF AU MOMENT OU VOUS AVEC VOTRE SIGNAL D'ENTREE EN POSITION.
/// ATTENTION, VOUS AVEZ LA POSSIBILITE DE TRANSMETTRE UNE VALEUR ISSUE D'UN CALCUL FIXE,
/// SOIT PRIX/COURS PLUS OU MOINS X% OU X POINTS OU PIPS. MAIS EGALEMENT D'UN INDICATEUR, /// SOIT LA VALEUR D'UNE MOYENNE MOBILE PLUS OU MOINS X% OU X POINTS OU PIPS.
/// TOUTEFOIS, CES DONNES NE SONT TRANSMISES QU'A L'INSTANT DU SIGNAL D'ENTREE EN
/// POSITION
/// SI ENTREE EN POSITION LONGUE ////
If LgSig = 1 Then
StopPrice = LOW - 0.001
ObjPrice = HIGH + 15
Endif
/// SI ENTREE EN POSITION COURTE ////
If ShSig = 1 Then
StopPrice = HIGH + 0.001
ObjPrice = Low - 15
Endif
/////////////////////////////////////////////////////////////////////////////////////////
// Gestion des retours
/////////////////////////////////////////////////////////////////////////////////////////
// CI APRES LA LIGNE LA PLUS IMPORTANTE DU PROGRAMME GNT@SYS, CELLE QUI VA PERMETTRE
// LA TRANSMISSION DES VALEURS DE VOTRE SYSTEME DE TRADING AU TRADING SEMI AUTOMATIQUE
// GNT@TSA
// VOUS TROUVEREZ CI APRES 12 VALEURS A RETOURNER. NE PAS MODIFIER CETTE LIGNE AU RISQUE // DE CREER UN DYSFONCTIONNEMENT DU TRADING SEMI AUTOMATIQUE. SI VOUS N'UTILISEZ PAS CERTAINS SIGNAUX, ALORS AFFECTEZ LEUR UNE VALEUR DE 0 DANS LE PROGRAMME CI DESSUS.
Return LgAle as "LgAle", ShAle as "ShAle", LgSig as "LgSig" , ShSig as "ShSig" , StopPrice as "StopPrice" , ObjPrice as "ObjectifPrice", LgInvSig as "LgInvSig", ShInvSig as "ShInvSig", LgBenSig as "LgBenSig" , ShBenSig as "ShBenSig", LgOutSig as "LgOutSig", ShOutSig as "ShOutSig"
GNT@TSA-Long
//////////////////////////////////////////////////////////////////////////////////////////
// Variable de paramétrage //
//////////////////////////////////////////////////////////////////////////////////////////
Once FinObj = FinObj
Once FinObjSup = FinObjSup
Once FinBenef = FinBenef
Once FinType = FinType
Once Spread = Spread
Once SprType = SprType
Once Pymd = Pymd
Once Annee = Annee
Once Mois = Mois
Once Jour = Jour
//////////////////////////////////////////////////////////////////////////////////////////
// Filtre de Temps //
//////////////////////////////////////////////////////////////////////////////////////////
If (Annee > 1950 AND Annee < 2050) AND Mois < 13 AND Jour <32 Then
If (Year > Annee) OR (Year = Annee AND Month => Mois and Day => Jour) Then
//////////////////////////////////////////////////////////////////////////////////////////
// Initialisation des variables //
//////////////////////////////////////////////////////////////////////////////////////////
// Active - Conditions actives ou non sur plusieurs bougies
Once PosLgOpenActiv = 0
Once PosLgFinActiv = 0
Once PosLgFinSupActiv = 0
Once PosLgObjActiv = 0
// Indic - Indications visuelles sur la bougie en cours
Once PosLgInIndic = 0
PosLgAleIndic = 0
PosLgStopIndic = 0
PosLgInvIndic = 0
PosLgFinIndic = 0
PosLgFinPlusIndic = 0
PosLgObjIndic = 0
PosLgPydIndic = 0
PosLgBenTrendIndic = 0
PosLgBenIndic = 0
PosLgOutIndic = 0
xHIndic = 0
// Price - Divers prix de l'actif pour gestion de la position
// Price - Divers prix de l'actif pour gestion des statistiques
Once PosLgOpenPrice = 0
Once PosLgClosePrice = 0
Once PosLgBenefPrice = 0
Once PosLgStopPrice = 0
Once PosStopPrice = 0
Once PosLgObjPrice = 0
Once NextObjPrice = 0
Once NextObjSupPrice = 0
Once BenefObjPrice = 0
// Stat
Once NbTrLg = 0
Once NbTrLgSto = 0
Once NbTrLgInv = 0
Once NbTrLgFin = 0
Once NbTrLgObj = 0
Once NbTrLgWin = 0
Once NbTrLgLos = 0
Once GainTrLg= 0
Once TotGainTrLg = 0
Once AvgGainTrLg = 0
Once LosTrLg = 0
Once TotLosTrLg = 0
Once AvgLosTrLg = 0
PosNbBar = 0
Once PosBarIn = 0
Once PosBarOut = 0
Once CountPosBar = 0
Once NbMoyPosBar = 0
Once MinPosNbBar = 0
Once MaxPosNbBar = 0
Once StopPosNbBar = 0
Once InvPosNbBar = 0
Once FinPosNbBar = 0
Once ObjPosNbBar = 0
Once WinPosNbBar = 0
Once LosPosNbBar = 0
// Input - Variables provenant du système de trading
LgAle = 0 // Signal d'alerte
LgSig = 0 // Signal d'entrée long
StopPrice = 0 // Prix du STOP
ObjPrice = 0 // Prix de l'objectif
LgInvSig = 0 // Signal d'invalidation du signal d'entrée
LgBenSig = 0 // Signal de prise de bénéfice
LgOutSig = 0 // Signal de sortie de position
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Appel fonctions externes
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
LgAle, ignored, LgSig , ignored, StopPrice, ObjPrice, LgInvSig, ignored, LgBenSig, ignored, LgOutSig, ignored = CALL "GNT@SYS"
////////////////////////////////////////////////////////////////////////////////////
// Gestion d'un signal d'alerte //
///////////////////////////////////////////////////////////////////////////////////
If PosLgOpenActiv = 0 Then // Si nous sommes en position
If LgAle <> 0 Then
PosLgAleIndic = 3
EndIf
EndIf
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Gestion d'un signal de prise de position
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Signal position long
If LgSig <> 0 Then // Si provenance d'un signal du système de trading sous jacent ...
xHIndic = 3 // Signal d'entrée en position
If PosLgOpenActiv <> 0 Then // Si déjà en position longue
xHIndic = xHIndic / 3*2 // Signal de pyramidage.... possible !!
If Pymd <> 0 Then // Si option de pyramidage
If Pymd = 1 Then // Si option de pyramidage après financement
If PosLgFinActiv <> 0 Then // Fiancement ok ?
PosLgPydIndic = 1
EndIf
EndIf
If Pymd = 2 Then // Si option de Pyramidage à tout prix
PosLgPydIndic = 1
EndIF
EndIf
Endif
Else
xHIndic =0 // Absence de signal
EndIf
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// GESTION INDICATEUR POSITION
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
If PosLgOpenActiv <> 0 Then // Si nous sommes en position
// Indic
PosLgInIndic = 1 // Indicateur de position ON
If PosLgObjActiv <> 0 Then // Si l'objectif a été atteint
PosLgInIndic = PosLgInIndic /2 // Indicateur de position "ON - Allegée"
EndIf
Else // Si non
PosLgInIndic = 0 // Indicateur de position OFF
Endif
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// GESTION DU GAIN EN POSITION
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
If PosLgOpenActiv <> 0 Then
GainTrLg = Close - PosLgOpenPrice // Calcul du gain en cours de position
Else
GainTrLg = 0
Endif
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// GESTION DU FINANCEMENT
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// FINANCEMENT PRUDENT
If FinObj <> 0 Then
If PosLgOpenActiv <> 0 Then // Si nous sommes en position
If PosLgFinActiv = 0 then // Non financée
// Financement absolu !! ou Relatif !!
If FinType = 0 Then
NextObjPrice = PosLgOpenPrice + FinObj
Else
NextObjPrice = PosLgOpenPrice * ( 1 + ( FinObj / 100))
Endif
If High => (NextObjPrice) Then // Que le prix franchit l'objectif
// de financement prudent
PosLgFinIndic = 2 // Indicateur de financement prudent
PosLgFinPlusIndic = 0 // Indicateur de financement audacieux
PosLgFinActiv = 1 // Financement activé
NbTrLgFin = NbTrLgFin + 1 // Compteur de positions financées
FinPosNbBar = FinPosNbBar + (BarIndex - PosBarIn) // Compteur du nombre de jours pour financement
Else
PosLgFinIndic = 0
PosLgFinPlusIndic = 0
Endif
Else
PosLgFinIndic = 0
PosLgFinPlusIndic = 0
Endif
Endif
EndIf
// FINANCEMENT AUDACIEUX //
If (FinObjSup <> 0 AND FinObjSup > FinObj) OR (FinObj = 0 AND FinObjSup <> 0) Then
If PosLgOpenActiv <> 0 Then
If (PosLgFinActiv <> 0 OR FinObj = 0) and PosLgFinSupActiv = 0 Then
// Financement absolu !! ou Relatif !!
If FinType = 0 Then
NextObjSupPrice = PosLgOpenPrice + FinObjSup
Else
NextObjSupPrice = PosLgOpenPrice * ( 1 + (FinObjSup / 100))
Endif
If High => (NextObjSupPrice) Then
PosLgFinIndic = PosLgFinIndic
PosLgFinPlusIndic = 2
PosLgFinSupActiv = 1
Else
PosLgFinIndic = PosLgFinIndic
PosLgFinPlusIndic = 0
PosLgFinSupActiv = 0
Endif
Endif
Endif
EndIf
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// POSITION GAGANTE SORTIE SUR OBJECTIF
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
If PosLgOpenActiv <> 0 Then
// ********************** Prise de Bénéfices sur objectif **********************
If PosLgObjActiv = 0 Then
If High => PosLgObjPrice Then
PosLgObjIndic = 1.5
PosLgObjActiv = 1
NbTrLgObj = NbTrLgObj + 1
ObjPosNbBar = ObjPosNbBar + (BarIndex - PosBarIn)
Else
PosLgObjIndic = 0
EndIf
EndIf
// ********************** Prise de Bénéfices sur signal **********************
If LgBenSig = 1 Then
PosLgBenIndic = 1
Else
PosLgBenIndic = 0
Endif
// ********************** Prise de Bénéfices en tendance ********************** //
If FinBenef <> 0 AND FinBenef > MAX(FinObj, FinObjSup) Then
If PosLgFinActiv = 1 Then
// Financement absolu !! ou Relatif !!
If FinType = 0 Then
BenefObjPrice = PosLgBenefPrice + FinBenef
Else
BenefObjPrice = PosLgBenefPrice * ( 1 + (FinBenef / 100))
Endif
If High >= BenefObjPrice Then
PosLgBenTrendIndic = 1.5
If FinType = 0 Then
PosLgBenefPrice = PosLgBenefPrice + FinBenef
Else
PosLgBenefPrice = PosLgBenefPrice * ( 1 + (FinBenef / 100))
Endif
Else
PosLgBenTrendIndic = 0
Endif
Endif
EndIf
// ********************** ********************** //
EndIf
///////////////////////////////////////////////////////////////////////////////////////////////////
// GESTION SORTIE DE POSITION
//////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// POSITION PERDANTE SORTIE SUR STOP OU INVALIDATION DU SIGNAL //
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
If PosLgOpenActiv <> 0 Then // Si nous sommes en position
If Low <= PosLgStopPrice OR ( LgInvSig <> 0 AND PosLgFinActiv = 0 AND PosLgFinSupActiv = 0) Or LgOutSig <> 0 Then
// soit un signal d'invalidation soit un prix de cloture inférieur au STOP
// soit un signal de sortie....
// Cas de l'invalidation du signal
If LgInvSig <> 0 AND PosLgFinActiv = 0 Then
PosLgInvIndic = 1.5
//Stat
NbTrLgInv = NbTrLgInv + 1
InvPosNbBar = InvPosNbBar + (BarIndex - PosBarIn)
InvPosNbBar = InvPosNbBar
EndIf
// Cas du signal de sortie
If LgOutSig <> 0 Then
PosLgOutIndic = 2.5
EndIf
// Price
PosLgClosePrice = OpenOfNextBar
// Cas du stop
If Low <= PosLgStopPrice Then
PosLgStopIndic = 3
//Stat
NbTrLgSto = NbTrLgSto + 1
StopPosNbBar = StopPosNbBar + (BarIndex - PosBarIn)
StopPosNbBar = StopPosNbBar
PosLgClosePrice = PosLgStopPrice
// Non cumulation du signal d'invalidation et de stop
If PosLgInvIndic = 2 Then
NbTrLgInv = NbTrLgInv - 1
InvPosNbBar = InvPosNbBar - (BarIndex - PosBarIn)
EndIf
Endif
// Flag
PosLgOpenActiv = 0
PosLgFinActiv = 0
PosLgFinSupActiv = 0
PosLgObjActiv = 0
//Statistiques génériques
PosBarOut = BarIndex
NbTrLg = NbTrLg + 1 // Compteur de position +1
//Statistiques génériques - Trade gagnant
If (PosLgClosePrice - PosLgOpenPrice ) > 0 Then
NbTrLgWin = NbTrLgWin + 1
WinPosNbBar = WinPosNbBar + (BarIndex - PosBarIn)
GainTrLg = (PosLgOpenPrice - PosLgClosePrice)
TotGainTrLg = TotGainTrLg + GainTrLg
AvgGainTrLg = TotGainTrLg / NbTrLgWin
AvgGainTrLg = AvgGainTrLg
EndIf
//Statistiques génériques - Trade perdant
If (PosLgClosePrice - PosLgOpenPrice ) <= 0 Then
NbTrLgLos = NbTrLgLos + 1
LosPosNbBar = LosPosNbBar + (BarIndex - PosBarIn)
LosTrLg = ( PosLgClosePrice - PosLgOpenPrice)
TotLosTrLg = TotLosTrLg + LosTrLg
AvgLosTrLg = TotLosTrLg / NbTrLgLos
AvgLosTrLg = AvgLosTrLg
EndIf
// Calcul du nombre de périodes (bougies) en relation à la statégie.
// Position actuelle
PosNbBar = PosBarOut - PosBarIn
// Moyenne
CountPosBar = CountPosBar + PosNbBar
NbMoyPosBar = CountPosBar / NbTrLg
NbMoyPosBar = NbMoyPosBar
// Minimum
If MinPosNbBar = 0 Then
MinPosNbBar = PosNbBar
Else
If PosNbBar < MinPosNbBar Then
MinPosNbBar = PosNbBar
EndIf
EndIf
// Maximum
If MaxPosNbBar = 0 Then
MaxPosNbBar = PosNbBar
Else
If PosNbBar > MaxPosNbBar Then
MaxPosNbBar = PosNbBar
EndIf
EndIf
// Reset fin de position
GainTrLg = 0
Endif
Endif
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// GESTION DES PRISES DE POSITIONS //
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
If (PosLgStopIndic = 0 AND PosLgInvIndic = 0 AND PosLgInvIndic = 0) Then
If LgSig = 1 Then // Si exitence d'un signal d'achat
If PosLgOpenActiv = 0 Then // et d'une absence de position
// Flag
PosLgOpenActiv = 1 // Ouverture d'une position
PosLgFinActiv = 0 // Initialisation flag financement
PosLgFinSupActiv = 0 // Initialisation flag financement audacieux
PosLgObjActiv = 0 // Initialisation flag atteinte objectif
// Indic
PosLgAleIndic = 0 //Aucun indicateur de position
PosLgInIndic = 0 //Aucun indicateur de position
PosLgStopIndic = 0 //Aucun indicateur de position
PosLgInvIndic = 0 //Aucun indicateur de position
PosLgFinIndic = 0 //Aucun indicateur de position
PosLgFinPlusIndic = 0 //Aucun indicateur de position
PosLgPydIndic = 0 //Aucun indicateur de position
PosLgObjIndic = 0 //Aucun indicateur de position
PosLgBenIndic = 0 //Aucun indicateur de position
PosLgBenTrendIndic = 0 //Aucun indicateur de position
PosLgOutIndic = 0 //Aucun indicateur de position
// Price
If SprType = 0 Then
PosLgOpenPrice = OpenOfNextBar + Spread // Ouverture au prix de la bougie suivante + spread absolu
Else
PosLgOpenPrice = OpenOfNextBar * (1 + (Spread / 100)) // Ouverture au prix de la bougie suivante + spread absolu
EndIf
PosLgBenefPrice = PosLgOpenPrice // Définition du prix de référence pour prise de bénéfice absolue
PosLgStopPrice = StopPrice // Définition du prix du STOP
PosStopPrice = PosLgStopPrice // Définition du prix du STOP
PosStopPrice = PosStopPrice
PosLgObjPrice = ObjPrice // Définition du prix de l'objectif
// Stat
GainTrLg = 0 // Gain sur position initialisé à 0
LosTrLg = 0 // Perte sur position initialisé à 0
PosNbBar = 0 // Nombre de Bar position = 0
PosBarIn = BarIndex // BarIndex d'ouverture à 1
PosBarOut = 0 // BarIndex de cloture à 0
EndIf
EndIf
EndIf
Else
xHIndic = 0
PosLgInIndic = 0
PosLgInvIndic = 0
PosLgStopIndic = 0
PosLgFinIndic = 0
PosLgFinPlusIndic = 0
PosLgObjIndic = 0
PosLgBenTrendIndic = 0
PosLgBenIndic = 0
PosLgOutIndic = 0
NbTrLg = 0
NbTrLgSto = 0
NbTrLgInv = 0
NbTrLgFin = 0
NbTrLgWin = 0
NbTrLgLos = 0
NbTrLgObj = 0
TotGainTrLg = 0
TotLosTrLg = 0
AvgGainTrLg = 0
AvgLosTrLg = 0
GainTrLg = 0
LosTrLg = 0
PosStopPrice = 0
FinObj = FinObj
FinObjSup = FinObjSup
FinBenef = FinBenef
FinType = FinType
Spread = Spread
SprType = SprType
Pymd = Pymd
Annee = Annee
Mois = Mois
Jour = Jour
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// GESTION DES VARIABLES MULTI MODULES //
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// n/a
Endif
EndIf
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Retour des variables //
////////////////////////////////////////////////////////////////////////////////////////////////////////////
Return PosLgAleIndic as "Alerte", xHIndic as "Signal Prise Position", PosLgInIndic as "En Position Longue", PosLgInvIndic as "Signal Invalidation", PosLgStopIndic as "Signal Stop", PosLgFinIndic as "Financement Prudent", PosLgFinPlusIndic as "Financement Audacieux", PosLgObjIndic as "Signal Position Objectif" , PosLgBenTrendIndic as "Position Objectif Absolu" , PosLgBenIndic as "Signal Prise Bénéfice", PosLgOutIndic as "Signal Sortie", PosLgPydIndic as "Signal Pyramidage"
// GNT@TSA-Short
//////////////////////////////////////////////////////////////////////////////////////////
// Variable de paramétrage //
//////////////////////////////////////////////////////////////////////////////////////////
Once FinObj = FinObj
Once FinObjSup = FinObjSup
Once FinBenef = FinBenef
Once FinType = FinType
Once SpreGNT@TSA-Long
//////////////////////////////////////////////////////////////////////////////////////////
// Variable de paramétrage //
//////////////////////////////////////////////////////////////////////////////////////////
Once FinObj = FinObj
Once FinObjSup = FinObjSup
Once FinBenef = FinBenef
Once FinType = FinType
Once Spread = Spread
Once SprType = SprType
Once Pymd = Pymd
Once Annee = Annee
Once Mois = Mois
Once Jour = Jour
//////////////////////////////////////////////////////////////////////////////////////////
// Filtre de Temps //
//////////////////////////////////////////////////////////////////////////////////////////
If (Annee > 1950 AND Annee < 2050) AND Mois < 13 AND Jour <32 Then
If (Year > Annee) OR (Year = Annee AND Month => Mois and Day => Jour) Then
//////////////////////////////////////////////////////////////////////////////////////////
// Initialisation des variables //
//////////////////////////////////////////////////////////////////////////////////////////
// Active - Conditions actives ou non sur plusieurs bougies
Once PosLgOpenActiv = 0
Once PosLgFinActiv = 0
Once PosLgFinSupActiv = 0
Once PosLgObjActiv = 0
// Indic - Indications visuelles sur la bougie en cours
Once PosLgInIndic = 0
PosLgAleIndic = 0
PosLgStopIndic = 0
PosLgInvIndic = 0
PosLgFinIndic = 0
PosLgFinPlusIndic = 0
PosLgObjIndic = 0
PosLgPydIndic = 0
PosLgBenTrendIndic = 0
PosLgBenIndic = 0
PosLgOutIndic = 0
xHIndic = 0
// Price - Divers prix de l'actif pour gestion de la position
// Price - Divers prix de l'actif pour gestion des statistiques
Once PosLgOpenPrice = 0
Once PosLgClosePrice = 0
Once PosLgBenefPrice = 0
Once PosLgStopPrice = 0
Once PosStopPrice = 0
Once PosLgObjPrice = 0
Once NextObjPrice = 0
Once NextObjSupPrice = 0
Once BenefObjPrice = 0
// Stat
Once NbTrLg = 0
Once NbTrLgSto = 0
Once NbTrLgInv = 0
Once NbTrLgFin = 0
Once NbTrLgObj = 0
Once NbTrLgWin = 0
Once NbTrLgLos = 0
Once GainTrLg= 0
Once TotGainTrLg = 0
Once AvgGainTrLg = 0
Once LosTrLg = 0
Once TotLosTrLg = 0
Once AvgLosTrLg = 0
PosNbBar = 0
Once PosBarIn = 0
Once PosBarOut = 0
Once CountPosBar = 0
Once NbMoyPosBar = 0
Once MinPosNbBar = 0
Once MaxPosNbBar = 0
Once StopPosNbBar = 0
Once InvPosNbBar = 0
Once FinPosNbBar = 0
Once ObjPosNbBar = 0
Once WinPosNbBar = 0
Once LosPosNbBar = 0
// Input - Variables provenant du système de trading
LgAle = 0 // Signal d'alerte
LgSig = 0 // Signal d'entrée long
StopPrice = 0 // Prix du STOP
ObjPrice = 0 // Prix de l'objectif
LgInvSig = 0 // Signal d'invalidation du signal d'entrée
LgBenSig = 0 // Signal de prise de bénéfice
LgOutSig = 0 // Signal de sortie de position
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Appel fonctions externes
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
LgAle, ignored, LgSig , ignored, StopPrice, ObjPrice, LgInvSig, ignored, LgBenSig, ignored, LgOutSig, ignored = CALL "GNT@SYS"
////////////////////////////////////////////////////////////////////////////////////
// Gestion d'un signal d'alerte //
///////////////////////////////////////////////////////////////////////////////////
If PosLgOpenActiv = 0 Then // Si nous sommes en position
If LgAle <> 0 Then
PosLgAleIndic = 3
EndIf
EndIf
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Gestion d'un signal de prise de position
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Signal position long
If LgSig <> 0 Then // Si provenance d'un signal du système de trading sous jacent ...
xHIndic = 3 // Signal d'entrée en position
If PosLgOpenActiv <> 0 Then // Si déjà en position longue
xHIndic = xHIndic / 3*2 // Signal de pyramidage.... possible !!
If Pymd <> 0 Then // Si option de pyramidage
If Pymd = 1 Then // Si option de pyramidage après financement
If PosLgFinActiv <> 0 Then // Fiancement ok ?
PosLgPydIndic = 1
EndIf
EndIf
If Pymd = 2 Then // Si option de Pyramidage à tout prix
PosLgPydIndic = 1
EndIF
EndIf
Endif
Else
xHIndic =0 // Absence de signal
EndIf
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// GESTION INDICATEUR POSITION
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
If PosLgOpenActiv <> 0 Then // Si nous sommes en position
// Indic
PosLgInIndic = 1 // Indicateur de position ON
If PosLgObjActiv <> 0 Then // Si l'objectif a été atteint
PosLgInIndic = PosLgInIndic /2 // Indicateur de position "ON - Allegée"
EndIf
Else // Si non
PosLgInIndic = 0 // Indicateur de position OFF
Endif
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// GESTION DU GAIN EN POSITION
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
If PosLgOpenActiv <> 0 Then
GainTrLg = Close - PosLgOpenPrice // Calcul du gain en cours de position
Else
GainTrLg = 0
Endif
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// GESTION DU FINANCEMENT
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// FINANCEMENT PRUDENT
If FinObj <> 0 Then
If PosLgOpenActiv <> 0 Then // Si nous sommes en position
If PosLgFinActiv = 0 then // Non financée
// Financement absolu !! ou Relatif !!
If FinType = 0 Then
NextObjPrice = PosLgOpenPrice + FinObj
Else
NextObjPrice = PosLgOpenPrice * ( 1 + ( FinObj / 100))
Endif
If High => (NextObjPrice) Then // Que le prix franchit l'objectif
// de financement prudent
PosLgFinIndic = 2 // Indicateur de financement prudent
PosLgFinPlusIndic = 0 // Indicateur de financement audacieux
PosLgFinActiv = 1 // Financement activé
NbTrLgFin = NbTrLgFin + 1 // Compteur de positions financées
FinPosNbBar = FinPosNbBar + (BarIndex - PosBarIn) // Compteur du nombre de jours pour financement
Else
PosLgFinIndic = 0
PosLgFinPlusIndic = 0
Endif
Else
PosLgFinIndic = 0
PosLgFinPlusIndic = 0
Endif
Endif
EndIf
// FINANCEMENT AUDACIEUX //
If (FinObjSup <> 0 AND FinObjSup > FinObj) OR (FinObj = 0 AND FinObjSup <> 0) Then
If PosLgOpenActiv <> 0 Then
If (PosLgFinActiv <> 0 OR FinObj = 0) and PosLgFinSupActiv = 0 Then
// Financement absolu !! ou Relatif !!
If FinType = 0 Then
NextObjSupPrice = PosLgOpenPrice + FinObjSup
Else
NextObjSupPrice = PosLgOpenPrice * ( 1 + (FinObjSup / 100))
Endif
If High => (NextObjSupPrice) Then
PosLgFinIndic = PosLgFinIndic
PosLgFinPlusIndic = 2
PosLgFinSupActiv = 1
Else
PosLgFinIndic = PosLgFinIndic
PosLgFinPlusIndic = 0
PosLgFinSupActiv = 0
Endif
Endif
Endif
EndIf
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// POSITION GAGANTE SORTIE SUR OBJECTIF
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
If PosLgOpenActiv <> 0 Then
// ********************** Prise de Bénéfices sur objectif **********************
If PosLgObjActiv = 0 Then
If High => PosLgObjPrice Then
PosLgObjIndic = 1.5
PosLgObjActiv = 1
NbTrLgObj = NbTrLgObj + 1
ObjPosNbBar = ObjPosNbBar + (BarIndex - PosBarIn)
Else
PosLgObjIndic = 0
EndIf
EndIf
// ********************** Prise de Bénéfices sur signal **********************
If LgBenSig = 1 Then
PosLgBenIndic = 1
Else
PosLgBenIndic = 0
Endif
// ********************** Prise de Bénéfices en tendance ********************** //
If FinBenef <> 0 AND FinBenef > MAX(FinObj, FinObjSup) Then
If PosLgFinActiv = 1 Then
// Financement absolu !! ou Relatif !!
If FinType = 0 Then
BenefObjPrice = PosLgBenefPrice + FinBenef
Else
BenefObjPrice = PosLgBenefPrice * ( 1 + (FinBenef / 100))
Endif
If High >= BenefObjPrice Then
PosLgBenTrendIndic = 1.5
If FinType = 0 Then
PosLgBenefPrice = PosLgBenefPrice + FinBenef
Else
PosLgBenefPrice = PosLgBenefPrice * ( 1 + (FinBenef / 100))
Endif
Else
PosLgBenTrendIndic = 0
Endif
Endif
EndIf
// ********************** ********************** //
EndIf
///////////////////////////////////////////////////////////////////////////////////////////////////
// GESTION SORTIE DE POSITION
//////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// POSITION PERDANTE SORTIE SUR STOP OU INVALIDATION DU SIGNAL //
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
If PosLgOpenActiv <> 0 Then // Si nous sommes en position
If Low <= PosLgStopPrice OR ( LgInvSig <> 0 AND PosLgFinActiv = 0 AND PosLgFinSupActiv = 0) Or LgOutSig <> 0 Then
// soit un signal d'invalidation soit un prix de cloture inférieur au STOP
// soit un signal de sortie....
// Cas de l'invalidation du signal
If LgInvSig <> 0 AND PosLgFinActiv = 0 Then
PosLgInvIndic = 1.5
//Stat
NbTrLgInv = NbTrLgInv + 1
InvPosNbBar = InvPosNbBar + (BarIndex - PosBarIn)
InvPosNbBar = InvPosNbBar
EndIf
// Cas du signal de sortie
If LgOutSig <> 0 Then
PosLgOutIndic = 2.5
EndIf
// Price
PosLgClosePrice = OpenOfNextBar
// Cas du stop
If Low <= PosLgStopPrice Then
PosLgStopIndic = 3
//Stat
NbTrLgSto = NbTrLgSto + 1
StopPosNbBar = StopPosNbBar + (BarIndex - PosBarIn)
StopPosNbBar = StopPosNbBar
PosLgClosePrice = PosLgStopPrice
// Non cumulation du signal d'invalidation et de stop
If PosLgInvIndic = 2 Then
NbTrLgInv = NbTrLgInv - 1
InvPosNbBar = InvPosNbBar - (BarIndex - PosBarIn)
EndIf
Endif
// Flag
PosLgOpenActiv = 0
PosLgFinActiv = 0
PosLgFinSupActiv = 0
PosLgObjActiv = 0
//Statistiques génériques
PosBarOut = BarIndex
NbTrLg = NbTrLg + 1 // Compteur de position +1
//Statistiques génériques - Trade gagnant
If (PosLgClosePrice - PosLgOpenPrice ) > 0 Then
NbTrLgWin = NbTrLgWin + 1
WinPosNbBar = WinPosNbBar + (BarIndex - PosBarIn)
GainTrLg = (PosLgOpenPrice - PosLgClosePrice)
TotGainTrLg = TotGainTrLg + GainTrLg
AvgGainTrLg = TotGainTrLg / NbTrLgWin
AvgGainTrLg = AvgGainTrLg
EndIf
//Statistiques génériques - Trade perdant
If (PosLgClosePrice - PosLgOpenPrice ) <= 0 Then
NbTrLgLos = NbTrLgLos + 1
LosPosNbBar = LosPosNbBar + (BarIndex - PosBarIn)
LosTrLg = ( PosLgClosePrice - PosLgOpenPrice)
TotLosTrLg = TotLosTrLg + LosTrLg
AvgLosTrLg = TotLosTrLg / NbTrLgLos
AvgLosTrLg = AvgLosTrLg
EndIf
// Calcul du nombre de périodes (bougies) en relation à la statégie.
// Position actuelle
PosNbBar = PosBarOut - PosBarIn
// Moyenne
CountPosBar = CountPosBar + PosNbBar
NbMoyPosBar = CountPosBar / NbTrLg
NbMoyPosBar = NbMoyPosBar
// Minimum
If MinPosNbBar = 0 Then
MinPosNbBar = PosNbBar
Else
If PosNbBar < MinPosNbBar Then
MinPosNbBar = PosNbBar
EndIf
EndIf
// Maximum
If MaxPosNbBar = 0 Then
MaxPosNbBar = PosNbBar
Else
If PosNbBar > MaxPosNbBar Then
MaxPosNbBar = PosNbBar
EndIf
EndIf
// Reset fin de position
GainTrLg = 0
Endif
Endif
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// GESTION DES PRISES DE POSITIONS //
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
If (PosLgStopIndic = 0 AND PosLgInvIndic = 0 AND PosLgInvIndic = 0) Then
If LgSig = 1 Then // Si exitence d'un signal d'achat
If PosLgOpenActiv = 0 Then // et d'une absence de position
// Flag
PosLgOpenActiv = 1 // Ouverture d'une position
PosLgFinActiv = 0 // Initialisation flag financement
PosLgFinSupActiv = 0 // Initialisation flag financement audacieux
PosLgObjActiv = 0 // Initialisation flag atteinte objectif
// Indic
PosLgAleIndic = 0 //Aucun indicateur de position
PosLgInIndic = 0 //Aucun indicateur de position
PosLgStopIndic = 0 //Aucun indicateur de position
PosLgInvIndic = 0 //Aucun indicateur de position
PosLgFinIndic = 0 //Aucun indicateur de position
PosLgFinPlusIndic = 0 //Aucun indicateur de position
PosLgPydIndic = 0 //Aucun indicateur de position
PosLgObjIndic = 0 //Aucun indicateur de position
PosLgBenIndic = 0 //Aucun indicateur de position
PosLgBenTrendIndic = 0 //Aucun indicateur de position
PosLgOutIndic = 0 //Aucun indicateur de position
// Price
If SprType = 0 Then
PosLgOpenPrice = OpenOfNextBar + Spread // Ouverture au prix de la bougie suivante + spread absolu
Else
PosLgOpenPrice = OpenOfNextBar * (1 + (Spread / 100)) // Ouverture au prix de la bougie suivante + spread absolu
EndIf
PosLgBenefPrice = PosLgOpenPrice // Définition du prix de référence pour prise de bénéfice absolue
PosLgStopPrice = StopPrice // Définition du prix du STOP
PosStopPrice = PosLgStopPrice // Définition du prix du STOP
PosStopPrice = PosStopPrice
PosLgObjPrice = ObjPrice // Définition du prix de l'objectif
// Stat
GainTrLg = 0 // Gain sur position initialisé à 0
LosTrLg = 0 // Perte sur position initialisé à 0
PosNbBar = 0 // Nombre de Bar position = 0
PosBarIn = BarIndex // BarIndex d'ouverture à 1
PosBarOut = 0 // BarIndex de cloture à 0
EndIf
EndIf
EndIf
Else
xHIndic = 0
PosLgInIndic = 0
PosLgInvIndic = 0
PosLgStopIndic = 0
PosLgFinIndic = 0
PosLgFinPlusIndic = 0
PosLgObjIndic = 0
PosLgBenTrendIndic = 0
PosLgBenIndic = 0
PosLgOutIndic = 0
NbTrLg = 0
NbTrLgSto = 0
NbTrLgInv = 0
NbTrLgFin = 0
NbTrLgWin = 0
NbTrLgLos = 0
NbTrLgObj = 0
TotGainTrLg = 0
TotLosTrLg = 0
AvgGainTrLg = 0
AvgLosTrLg = 0
GainTrLg = 0
LosTrLg = 0
PosStopPrice = 0
FinObj = FinObj
FinObjSup = FinObjSup
FinBenef = FinBenef
FinType = FinType
Spread = Spread
SprType = SprType
Pymd = Pymd
Annee = Annee
Mois = Mois
Jour = Jour
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// GESTION DES VARIABLES MULTI MODULES //
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// n/a
Endif
EndIf
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Retour des variables //
////////////////////////////////////////////////////////////////////////////////////////////////////////////
Return PosLgAleIndic as "Alerte", xHIndic as "Signal Prise Position", PosLgInIndic as "En Position Longue", PosLgInvIndic as "Signal Invalidation", PosLgStopIndic as "Signal Stop", PosLgFinIndic as "Financement Prudent", PosLgFinPlusIndic as "Financement Audacieux", PosLgObjIndic as "Signal Position Objectif" , PosLgBenTrendIndic as "Position Objectif Absolu" , PosLgBenIndic as "Signal Prise Bénéfice", PosLgOutIndic as "Signal Sortie", PosLgPydIndic as "Signal Pyramidage"ad = Spread
Once SprType = SprType
Once Pymd = Pymd
Once Annee = Annee
Once Mois = Mois
Once Jour = Jour
//////////////////////////////////////////////////////////////////////////////////////////
// Filtre de Temps //
//////////////////////////////////////////////////////////////////////////////////////////
If (Annee > 1950 AND Annee < 2050) AND Mois < 13 AND Jour <32 Then
If (Year > Annee) OR (Year = Annee AND Month >= Mois and Day >= Jour) Then
//////////////////////////////////////////////////////////////////////////////////////////
// Initialisation des variables //
//////////////////////////////////////////////////////////////////////////////////////////
// Active - Conditions actives ou non sur plusieurs bougies
Once PosShOpenActiv = 0
Once PosShFinActiv = 0
Once PosShFinSupActiv = 0
Once PosShObjActiv = 0
// Indic - Indications visuelles sur la bougie en cours
Once PosShInIndic = 0
PosShAleIndic = 0
PosShStopIndic = 0
PosShInvIndic = 0
PosShFinIndic = 0
PosShFinPlusIndic = 0
PosShObjIndic = 0
PosShPydIndic = 0
PosShBenTrendIndic = 0
PosShBenIndic = 0
PosShOutIndic = 0
xHIndic = 0
// Price - Divers prix de l'actif pour gestion de la position
// Price - Divers prix de l'actif pour gestion des statistiques
Once PosShOpenPrice = 0
Once PosShClosePrice = 1
Once PosShBenefPrice = 0
Once PosShStopPrice = 0
Once PosStopPrice = 0
Once PosShObjPrice = 0
Once NextObjPrice = 0
Once NextObjSupPrice = 0
Once BenefObjPrice = 0
// Stat
Once NbTrSh = 0
Once NbTrShSto = 0
Once NbTrShInv = 0
Once NbTrShFin = 0
Once NbTrShObj = 0
Once NbTrShWin = 0
Once NbTrShLos = 0
Once GainTrSh= 0
Once TotGainTrSh = 0
Once AvgGainTrSh = 0
Once LosTrSh = 0
Once TotLosTrSh = 0
Once AvgLosTrSh = 0
PosNbBar = 0
Once PosBarIn = 0
Once PosBarOut = 0
Once CountPosBar = 0
Once NbMoyPosBar = 0
Once MinPosNbBar = 0
Once MaxPosNbBar = 0
Once StopPosNbBar = 0
Once InvPosNbBar = 0
Once FinPosNbBar = 0
Once ObjPosNbBar = 0
Once WinPosNbBar = 0
Once LosPosNbBar = 0
// Input - Variables provenant du système de trading
ShAle = 0 // Signal d'alerte
ShSig = 0 // Signal d'entrée long
StopPrice = 0 // Prix du STOP
ObjPrice = 0 // Prix de l'objectif
ShInvSig = 0 // Signal d'invalidation du signal d'entrée
ShBenSig = 0 // Signal de prise de bénéfice
ShOutSig = 0 // Signal de sortie de position
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Appel fonctions externes
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ignored, ShAle, ignored, ShSig, StopPrice, ObjPrice, ignored, ShInvSig, ignored, ShBenSig, ignored, ShOutSig = CALL "GNT@SYS"
////////////////////////////////////////////////////////////////////////////////////
// Gestion d'un signal d'alerte //
///////////////////////////////////////////////////////////////////////////////////
If PosShOpenActiv = 0 Then // Si nous sommes en position
If ShAle <> 0 Then
PosShAleIndic = -3
EndIf
EndIf
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Gestion d'un signal de prise de position
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Signal position long
If ShSig <> 0 Then // Si provenance d'un signal du système de trading sous jacent ...
xHIndic = -3 // Signal d'entrée en position
If PosShOpenActiv <> 0 Then // Si déjà en position longue
xHIndic = xHIndic / 3*2 // Signal de pyramidage.... possible !!
If Pymd <> 0 Then // Si option de pyramidage
If Pymd = 1 Then // Si option de pyramidage après financement
If PosShFinActiv <> 0 Then // Fiancement ok ?
PosShPydIndic = -1
EndIf
EndIf
If Pymd = 2 Then // Si option de Pyramidage à tout prix
PosShPydIndic = -1
EndIF
EndIf
Endif
Else
xHIndic =0 // Absence de signal
EndIf
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// GESTION INDICATEUR POSITION
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
If PosShOpenActiv <> 0 Then // Si nous sommes en position
// Indic
PosShInIndic = -1 // Indicateur de position ON
If PosShObjActiv <> 0 Then // Si l'objectif a été atteint
PosShInIndic = PosShInIndic /2 // Indicateur de position "ON - Allegée"
EndIf
Else // Si non
PosShInIndic = 0 // Indicateur de position OFF
Endif
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// GESTION DU GAIN EN POSITION
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
If PosShOpenActiv <> 0 Then
GainTrSh = PosShOpenPrice - Close // Calcul du gain en cours de position
Else
GainTrSh = 0
Endif
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// GESTION DU FINANCEMENT
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// FINANCEMENT PRUDENT
If FinObj <> 0 Then
If PosShOpenActiv <> 0 Then // Si nous sommes en position
If PosShFinActiv = 0 then // Non financée
// Financement absolu !! ou Relatif !!
If FinType = 0 Then
NextObjPrice = PosShOpenPrice - FinObj
Else
NextObjPrice = PosShOpenPrice * ( 1 - ( FinObj / 100))
Endif
If Low <= (NextObjPrice) Then // Que le prix franchit l'objectif
// de financement prudent
PosShFinIndic = -2 // Indicateur de financement prudent
PosShFinPlusIndic = 0 // Indicateur de financement audacieux
PosShFinActiv = 1 // Financement activé
NbTrShFin = NbTrShFin + 1 // Compteur de positions financées
FinPosNbBar = FinPosNbBar + (BarIndex - PosBarIn) // Compteur du nombre de jours pour financement
Else
PosShFinIndic = 0
PosShFinPlusIndic = 0
Endif
Else
PosShFinIndic = 0
PosShFinPlusIndic = 0
Endif
Endif
EndIf
// FINANCEMENT AUDACIEUX //
If (FinObjSup <> 0 AND FinObjSup > FinObj) OR (FinObj = 0 AND FinObjSup <> 0) Then
If PosShOpenActiv <> 0 Then
If (PosShFinActiv <> 0 OR FinObj = 0) and PosShFinSupActiv = 0 Then
// Financement absolu !! ou Relatif !!
If FinType = 0 Then
NextObjSupPrice = PosShOpenPrice - FinObjSup
Else
NextObjSupPrice = PosShOpenPrice * ( 1 - (FinObjSup / 100))
Endif
If Low <= (NextObjSupPrice) Then
PosShFinIndic = PosShFinIndic
PosShFinPlusIndic = -2
PosShFinSupActiv = 1
Else
PosShFinIndic = PosShFinIndic
PosShFinPlusIndic = 0
PosShFinSupActiv = 0
Endif
Endif
Endif
EndIf
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// POSITION GAGANTE SORTIE SUR OBJECTIF
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
If PosShOpenActiv <> 0 Then
// ********************** Prise de Bénéfices sur objectif **********************
If PosShObjActiv = 0 Then
If Low <= PosShObjPrice Then
PosShObjIndic = -1.5
PosShObjActiv = 1
NbTrShObj = NbTrShObj + 1
ObjPosNbBar = ObjPosNbBar + (BarIndex - PosBarIn)
Else
PosShObjIndic = 0
EndIf
EndIf
// ********************** Prise de Bénéfices sur signal **********************
If ShBenSig = 1 Then
PosShBenIndic = -1
Else
PosShBenIndic = 0
Endif
// ********************** Prise de Bénéfices en tendance ********************** //
If FinBenef <> 0 AND FinBenef > MAX(FinObj, FinObjSup) Then
If PosShFinActiv = 1 Then
// Financement absolu !! ou Relatif !!
If FinType = 0 Then
BenefObjPrice = PosShBenefPrice - FinBenef
Else
BenefObjPrice = PosShBenefPrice * ( 1 - (FinBenef / 100))
Endif
If Low <= BenefObjPrice Then
PosShBenTrendIndic = -1.5
If FinType = 0 Then
PosShBenefPrice = PosShBenefPrice - FinBenef
Else
PosShBenefPrice = PosShBenefPrice * ( 1 - (FinBenef / 100))
Endif
Else
PosShBenTrendIndic = 0
Endif
Endif
EndIf
// ********************** ********************** //
EndIf
///////////////////////////////////////////////////////////////////////////////////////////////////
// GESTION SORTIE DE POSITION
//////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// POSITION PERDANTE SORTIE SUR STOP OU INVALIDATION DU SIGNAL //
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
If PosShOpenActiv <> 0 Then // Si nous sommes en position
If High >= PosShStopPrice OR ( ShInvSig <> 0 AND PosShFinActiv = 0 AND PosShFinSupActiv = 0) Or ShOutSig <> 0 Then
// soit un signal d'invalidation soit un prix de cloture inférieur au STOP
// soit un signal de sortie....
// Cas de l'invalidation du signal
If ShInvSig <> 0 AND PosShFinActiv = 0 Then
PosShInvIndic = -1.5
//Stat
NbTrShInv = NbTrShInv + 1
InvPosNbBar = InvPosNbBar + (BarIndex - PosBarIn)
InvPosNbBar = InvPosNbBar
EndIf
// Cas du signal de sortie
If ShOutSig <> 0 Then
PosShOutIndic = -2.5
EndIf
// Price
PosShClosePrice = OpenOfNextBar
// Cas du stop
If High >= PosShStopPrice Then
PosShStopIndic = -3
//Stat
NbTrShSto = NbTrShSto + 1
StopPosNbBar = StopPosNbBar + (BarIndex - PosBarIn)
StopPosNbBar = StopPosNbBar
PosShClosePrice = PosShStopPrice
// Non cumulation du signal d'invalidation et de stop
If PosShInvIndic = -2 Then
NbTrShInv = NbTrShInv - 1
InvPosNbBar = InvPosNbBar - (BarIndex - PosBarIn)
EndIf
Endif
// Flag
PosShOpenActiv = 0
PosShFinActiv = 0
PosShFinSupActiv = 0
PosShObjActiv = 0
//Statistiques génériques
PosBarOut = BarIndex
NbTrSh = NbTrSh + 1 // Compteur de position +1
//Statistiques génériques - Trade gagnant
If (PosShOpenPrice - PosShClosePrice) > 0 Then
NbTrShWin = NbTrShWin + 1
WinPosNbBar = WinPosNbBar + (BarIndex - PosBarIn)
GainTrSh = (PosShOpenPrice - PosShClosePrice)
TotGainTrSh = TotGainTrSh + GainTrSh
AvgGainTrSh = TotGainTrSh / NbTrShWin
AvgGainTrSh = AvgGainTrSh
EndIf
//Statistiques génériques - Trade perdant
If (PosShOpenPrice - PosShClosePrice) <= 0 Then
NbTrShLos = NbTrShLos + 1
LosPosNbBar = LosPosNbBar + (BarIndex - PosBarIn)
LosTrSh = (PosShOpenPrice - PosShClosePrice)
TotLosTrSh = TotLosTrSh + LosTrSh
AvgLosTrSh = TotLosTrSh / NbTrShLos
AvgLosTrSh = AvgLosTrSh
EndIf
// Calcul du nombre de périodes (bougies) en relation à la statégie.
// Position actuelle
PosNbBar = PosBarOut - PosBarIn
// Moyenne
CountPosBar = CountPosBar + PosNbBar
NbMoyPosBar = CountPosBar / NbTrSh
NbMoyPosBar = NbMoyPosBar
// Minimum
If MinPosNbBar = 0 Then
MinPosNbBar = PosNbBar
Else
If PosNbBar < MinPosNbBar Then
MinPosNbBar = PosNbBar
EndIf
EndIf
// Maximum
If MaxPosNbBar = 0 Then
MaxPosNbBar = PosNbBar
Else
If PosNbBar > MaxPosNbBar Then
MaxPosNbBar = PosNbBar
EndIf
EndIf
// Reset fin de position
GainTrSh = 0
Endif
Endif
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// GESTION DES PRISES DE POSITIONS //
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
If (PosShStopIndic = 0 AND PosShInvIndic = 0 AND PosShInvIndic = 0) Then
If ShSig = 1 Then // Si exitence d'un signal d'achat
If PosShOpenActiv = 0 Then // et d'une absence de position
// Flag
PosShOpenActiv = 1 // Ouverture d'une position
PosShFinActiv = 0 // Initialisation flag financement
PosShFinSupActiv = 0 // Initialisation flag financement audacieux
PosShObjActiv = 0 // Initialisation flag atteinte objectif
// Indic
PosShAleIndic = 0 //Aucun indicateur de position
PosShInIndic = 0 //Aucun indicateur de position
PosShStopIndic = 0 //Aucun indicateur de position
PosShInvIndic = 0 //Aucun indicateur de position
PosShFinIndic = 0 //Aucun indicateur de position
PosShFinPlusIndic = 0 //Aucun indicateur de position
PosShPydIndic = 0 //Aucun indicateur de position
PosShObjIndic = 0 //Aucun indicateur de position
PosShBenIndic = 0 //Aucun indicateur de position
PosShBenTrendIndic = 0 //Aucun indicateur de position
PosShOutIndic = 0 //Aucun indicateur de position
// Price
If SprType = 0 Then
PosShOpenPrice = OpenOfNextBar + Spread // Ouverture au prix de la bougie suivante + spread absolu
Else
PosShOpenPrice = OpenOfNextBar * (1 + (Spread / 100)) // Ouverture au prix de la bougie suivante + spread absolu
EndIf
PosShBenefPrice = PosShOpenPrice // Définition du prix de référence pour prise de bénéfice absolue
PosShStopPrice = StopPrice // Définition du prix du STOP
PosStopPrice = PosShStopPrice // Définition du prix du STOP
PosStopPrice = PosStopPrice
PosShObjPrice = ObjPrice // Définition du prix de l'objectif
// Stat
GainTrSh = 0 // Gain sur position initialisé à 0
LosTrSh = 0 // Perte sur position initialisé à 0
PosNbBar = 0 // Nombre de Bar position = 0
PosBarIn = BarIndex // BarIndex d'ouverture à 1
PosBarOut = 0 // BarIndex de cloture à 0
EndIf
EndIf
EndIf
Else
xHIndic = 0
PosShInIndic = 0
PosShInvIndic = 0
PosShStopIndic = 0
PosShFinIndic = 0
PosShFinPlusIndic = 0
PosShObjIndic = 0
PosShBenTrendIndic = 0
PosShBenIndic = 0
PosShOutIndic = 0
NbTrSh = 0
NbTrShSto = 0
NbTrShInv = 0
NbTrShFin = 0
NbTrShWin = 0
NbTrShLos = 0
NbTrShObj = 0
TotGainTrSh = 0
TotLosTrSh = 0
AvgGainTrSh = 0
AvgLosTrSh = 0
GainTrSh = 0
LosTrSh = 0
PosStopPrice = 0
FinObj = FinObj
FinObjSup = FinObjSup
FinBenef = FinBenef
FinType = FinType
Spread = Spread
SprType = SprType
Pymd = Pymd
Annee = Annee
Mois = Mois
Jour = Jour
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// GESTION DES VARIABLES MULTI MODULES //
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// n/a
Endif
EndIf
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Retour des variables //
////////////////////////////////////////////////////////////////////////////////////////////////////////////
Return PosShAleIndic as "Alerte", xHIndic as "Signal Prise Position", PosShInIndic as "En Position Longue", PosShInvIndic as "Signal Invalidation", PosShStopIndic as "Signal Stop", PosShFinIndic as "Financement Prudent", PosShFinPlusIndic as "Financement Audacieux", PosShObjIndic as "Signal Position Objectif" , PosShBenTrendIndic as "Position Objectif Absolu" , PosShBenIndic as "Signal Prise Bénéfice",PosShOutIndic as "Signal Sortie", PosShPydIndic as "Signal Pyramidage"
voila pour le moment je ne met que les 3 codes principaux le gnt@sys est celui ou vous installé votre système de trading ou stratégie, les 2 suivant font un call du premier suivant vos paramètre et si vous êtes à l achat ou la vente, il y à tous les commentaire pour faire vos réglages et je pense que l on peut encore l’amélioré.
actuellement mon problème ce situe dans GNT@TSA-Long et GNT@TSA-Short dans la partie position perdante sortie sur stop ou invalidation du signal au niveau du commentaire //price j ai cet ligne de code PosLgClosePrice = OpenOfNextBar et quand je veux validé le programme il me demande de definir la variable OpenOfNextBar et je ne vois pas pourquoi ? si quelqu un pouvait m’éclairer parce que si j arrive à résoudre cet partie je pourrais m attaqué au 4 autres pour complété le programme de money management.
merci
Here is for the moment I only put the 3 main codes the gnt @ sys is the one where you installed your trading system or strategy, the next 2 make a call of the first following your parameter and if you are buying or selling, There are all the comments to make your settings and I think we can still improve it.
Currently my problem is located in GNT @ TSA-Long and GNT @ TSA-Short in the part losing position output on stop or invalidation of the signal at the comment level // price j have this line of code PosLgClosePrice = OpenOfNextBar and when I want validated The program it asks me to define the variable OpenOfNextBar and I do not see why? If anyone could enlighten me because if I can solve this part I could m attacked the 4 others to complete the program of money management.
thank you
J’ai écrit ce code… il y a bien longtemps ! et je suis content de voir que quelqu’un s’intéresse à celui-ci…
Ca a été beaucoup de travail 🙂
il faudrait que je ne re-plonge dedans pour être certains, mais ajoute seulement
Once openofnextbar = 1
juste après
Once Jour = Jour
Ceci donne…
Once FinObj = FinObj
Once FinObjSup = FinObjSup
Once FinBenef = FinBenef
Once FinType = FinType
Once Spread = Spread
Once SprType = SprType
Once Pymd = Pymd
Once Annee = Annee
Once Mois = Mois
Once Jour = Jour
Once openofnextbar = 1
Hallo, würde mich interessieren ob ihr diesen code wieder zum laufen bekommen habt.
Ich habe noch so etwas komplexes hier im forum gesehen ! respekt
Oui te voilà enfin gfx mon rêve ce réalisé enfin C est bizarre je n est pas été averti de tes message enfin bref ce qui compte C est maintenant effectivement ton code date de 2011 et je le trouve genialissime😉 comparativement à tout ce que j ai pu voir ailleurs mais comme je débute en prog je suis resté coincé et prt C est amélioré depuis…
Dit moi avec les nouvelles fonctionnalités prt est il possible de simplifier tout sa, je sais j en demande beaucoup parce que si C est oui tu va révolutionner ma façon de travailler et mon temps si précieux pour ma famille, bon du coup je me remet en selle et revient vers toi si j ai des questions.
Et encore toute ma gratitude pour ton travail
Mille merci
Bonjour Grégoire,
Merci pour ce partage !!!
As-tu pu faire fonctionner le code finalement ?
Marche-t-il sur les actions ou est-il destiné à d’autres actifs ?
Je ne comprends pas pourquoi on ne trouve pas qlq part un ranking en temps réel des performances de stratégies de trading automatique par actifs ; tu aurais une explication ?
Bonjour GFX,
Merci pour ce code !!!
As-tu pu faire fonctionner le code finalement ?
Marche-t-il sur les actions ou est-il destiné à d’autres actifs ?
Je ne comprends pas pourquoi on ne trouve pas qlq part un ranking en temps réel des performances de stratégies de trading automatique par actifs ; tu aurais une explication ?
bonjour kris
oui en faisant la modif Once openofnextbar = 1 dans le code principal mais depuis prt à beaucoup évolué et c est pour cela que j ai demandé au créateur du code si on pouvait simplifier depuis mais je suis sans réponse il doit être occupé ailleurs , pour ta questions je n’ ai pas la réponse je peu seulement te dire qu un ranking sur plus de 8000 actions qui s échange chaque jours prenne beaucoup de temps et place donc j ‘en déduis que cela doit être la raison , et le but du trader est de détecter les meilleurs opportunité sinon si tout est livré sur un plateau à quoi bon…
bien à toi et bon trade ou bonne prog…
@gregoire Thanks 😉 bon dommage pour l’aide à la prog …
en fait je pensais à un ranking non pas par action mais plutôt par actif = les actions / Forex … ; oui je pense que chacun bosse dans son coin ce qui n’est pas un reproche of course ; j’en fais l’expérience tout cela est du travail et du talent !
tu utilises quoi du coup comme système automatique sur les actions ?
Bien à toi,
Chris
en fait je n ai pas automatisé je screen tous les soir et fini de filtre visuellement par moi même parce qu une machine ne peu reproduire certaine chose mais vu que cela ne me prend qu entre 30mn et 1h cela ne pose aucun problème et me laisse du temps pour autre choses…
@grégoire ; ok et donc tu utilises quels screener ?
Salut, pourriez-vous télécharger les fichiers joints à la poste? Les codes ne semblent pas fonctionner comme ça.
bonjour à tous,
je suis parti sur MT4… pendant quelques années… et je reviens sur PRT de temps à autre 🙂
le code devrait toujours fonctionner. En tous cas sur mon poste c’est le cas.
Probablement un problème de copier/coller.
A+
Hello GFX,
Peux-tu nous donner exactement ta configuration et le support que tu trades, que l’on puisse mieux utiliser ce superbe travail ?
Merci
Kris
Semi automatic trading
This topic contains 20 replies,
has 3 voices, and was last updated by gfx
3 years, 2 months ago.
| Forum: | ProBuilder : Indicateurs & Outils Personnalisés |
| Language: | French |
| Started: | 04/11/2017 |
| Status: | Active |
| Attachments: | 4 files |
The information collected on this form is stored in a computer file by ProRealCode to create and access your ProRealCode profile. This data is kept in a secure database for the duration of the member's membership. They will be kept as long as you use our services and will be automatically deleted after 3 years of inactivity. Your personal data is used to create your private profile on ProRealCode. This data is maintained by SAS ProRealCode, 407 rue Freycinet, 59151 Arleux, France. If you subscribe to our newsletters, your email address is provided to our service provider "MailChimp" located in the United States, with whom we have signed a confidentiality agreement. This company is also compliant with the EU/Swiss Privacy Shield, and the GDPR. For any request for correction or deletion concerning your data, you can directly contact the ProRealCode team by email at privacy@prorealcode.com If you would like to lodge a complaint regarding the use of your personal data, you can contact your data protection supervisory authority.