ProRealTime: GNT@TSA-Long-BarStat

Voici le code de l’indicateur ProRealTime GNT@TSA-Long-Barstat

Des questions? Des idées? Des astuces? Venez échanger et discuter sur le forum !

Pour le paramétrage des variables… c’est ici.

Bons trades.

Grégoire Tardy

// Grégoire Tardy 01.01.2010
// Update : 08.11.2010
// Version 8
// Ajout autonomie des modules

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

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
  
  Once PosLgOpenActiv = 0
  Once PosLgFinActiv = 0
  Once PosLgFinSupActiv = 0
  Once PosLgObjActiv = 0
  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
  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
  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
  LgAle = 0
  LgSig = 0
  StopPrice = 0
  ObjPrice = 0
  LgInvSig = 0
  LgBenSig = 0
  LgOutSig = 0
  LgAle, ignored, LgSig , ignored, StopPrice, ObjPrice, LgInvSig, ignored, LgBenSig, ignored, LgOutSig, ignored = CALL “GNT@SYS
  If PosLgOpenActiv = 0 Then
   If LgAle 0 Then
    PosLgAleIndic = 3
   EndIf
  EndIf
  If LgSig 0 Then
   xHIndic = 3
   If PosLgOpenActiv 0 Then
    xHIndic = xHIndic / 3*2
    If Pymd 0 Then
     If Pymd = 1 Then
      If PosLgFinActiv 0 Then
       PosLgPydIndic = 1
      EndIf
     EndIf
     If Pymd = 2 Then
      PosLgPydIndic = 1
     EndIF
    EndIf
   Endif
  Else
   xHIndic =0
  EndIf
  If PosLgOpenActiv 0 Then
   PosLgInIndic = 1
   If PosLgObjActiv 0 Then
    PosLgInIndic = PosLgInIndic /2
   EndIf
  Else
   PosLgInIndic = 0
  Endif
  If PosLgOpenActiv 0 Then
   GainTrLg = Close – PosLgOpenPrice
  Else
   GainTrLg = 0
  Endif
  If FinObj 0 Then
   If PosLgOpenActiv 0 Then
    If PosLgFinActiv = 0 then
     If FinType = 0 Then
      NextObjPrice = PosLgOpenPrice + FinObj
     Else
      NextObjPrice = PosLgOpenPrice * ( 1 + ( FinObj / 100))
     Endif
     If High => (NextObjPrice) Then
      PosLgFinIndic = 2
      PosLgFinPlusIndic = 0
      PosLgFinActiv = 1
      NbTrLgFin = NbTrLgFin + 1
      FinPosNbBar = FinPosNbBar + (BarIndex – PosBarIn)
     Else
      PosLgFinIndic = 0
      PosLgFinPlusIndic = 0
     Endif
    Else
     PosLgFinIndic = 0
     PosLgFinPlusIndic = 0
    Endif
   Endif
  EndIf
  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
     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
  If PosLgOpenActiv 0 Then
   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
   If LgBenSig = 1 Then
    PosLgBenIndic = 1
   Else
    PosLgBenIndic = 0
   Endif
   If FinBenef 0 AND FinBenef > MAX(FinObj, FinObjSup) Then
    If PosLgFinActiv = 1 Then
     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
  If PosLgOpenActiv 0 Then
   If Low <= PosLgStopPrice OR ( LgInvSig 0 AND PosLgFinActiv = 0 AND PosLgFinSupActiv = 0) Or LgOutSig 0 Then
    If LgInvSig 0 AND PosLgFinActiv = 0 Then
     PosLgInvIndic = 1.5
     NbTrLgInv = NbTrLgInv + 1
     InvPosNbBar = InvPosNbBar + (BarIndex – PosBarIn)
     InvPosNbBar = InvPosNbBar
    EndIf
    If LgOutSig 0 Then
     PosLgOutIndic = 2.5
    EndIf
    PosLgClosePrice = OpenOfNextBar
    If Low <= PosLgStopPrice Then
     PosLgStopIndic = 3
     NbTrLgSto = NbTrLgSto + 1
     StopPosNbBar = StopPosNbBar + (BarIndex – PosBarIn)
     StopPosNbBar = StopPosNbBar
     PosLgClosePrice = PosLgStopPrice
     If PosLgInvIndic = 2 Then
      NbTrLgInv = NbTrLgInv – 1
      InvPosNbBar = InvPosNbBar – (BarIndex – PosBarIn)
     EndIf
    Endif
    PosLgOpenActiv = 0
    PosLgFinActiv = 0
    PosLgFinSupActiv = 0
    PosLgObjActiv = 0
    PosBarOut = BarIndex
    NbTrLg = NbTrLg + 1
    If (PosLgClosePrice – PosLgOpenPrice ) > 0 Then
     NbTrLgWin = NbTrLgWin + 1
     WinPosNbBar = WinPosNbBar + (BarIndex – PosBarIn)
     GainTrLg = (PosLgOpenPrice – PosLgClosePrice)
     TotGainTrLg = TotGainTrLg + GainTrLg
     AvgGainTrLg = TotGainTrLg / NbTrLgWin
     AvgGainTrLg = AvgGainTrLg
    EndIf
    If (PosLgClosePrice – PosLgOpenPrice ) <= 0 Then
     NbTrLgLos = NbTrLgLos + 1
     LosPosNbBar = LosPosNbBar + (BarIndex – PosBarIn)
     LosTrLg = ( PosLgClosePrice – PosLgOpenPrice)
     TotLosTrLg = TotLosTrLg + LosTrLg
     AvgLosTrLg = TotLosTrLg / NbTrLgLos
     AvgLosTrLg = AvgLosTrLg
    EndIf
    PosNbBar = PosBarOut – PosBarIn
    CountPosBar = CountPosBar + PosNbBar
    NbMoyPosBar = CountPosBar / NbTrLg
    NbMoyPosBar = NbMoyPosBar
    If MinPosNbBar = 0 Then
     MinPosNbBar = PosNbBar
    Else
     If PosNbBar < MinPosNbBar Then
      MinPosNbBar = PosNbBar
     EndIf
    EndIf
    If MaxPosNbBar = 0 Then
     MaxPosNbBar = PosNbBar
    Else
     If PosNbBar > MaxPosNbBar Then
      MaxPosNbBar = PosNbBar
     EndIf
    EndIf
    GainTrLg = 0
   Endif
  Endif
  If (PosLgStopIndic = 0 AND PosLgInvIndic = 0 AND PosLgInvIndic = 0) Then
   If LgSig = 1 Then
    If PosLgOpenActiv = 0 Then
     PosLgOpenActiv = 1
     PosLgFinActiv = 0
     PosLgFinSupActiv = 0
     PosLgObjActiv = 0
     PosLgAleIndic = 0
     PosLgInIndic = 0
     PosLgStopIndic = 0
     PosLgInvIndic = 0
     PosLgFinIndic = 0
     PosLgFinPlusIndic = 0
     PosLgPydIndic = 0
     PosLgObjIndic = 0
     PosLgBenIndic = 0
     PosLgBenTrendIndic = 0
     PosLgOutIndic = 0
     If SprType = 0 Then
      PosLgOpenPrice = OpenOfNextBar + Spread
     Else
      PosLgOpenPrice = OpenOfNextBar * (1 + (Spread / 100))
     EndIf
     PosLgBenefPrice = PosLgOpenPrice
     PosLgStopPrice = StopPrice
     PosStopPrice = PosLgStopPrice
     PosStopPrice = PosStopPrice
     PosLgObjPrice = ObjPrice
     GainTrLg = 0
     LosTrLg = 0
     PosNbBar = 0
     PosBarIn = BarIndex
     PosBarOut = 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
  
  PosLgInIndic = PosLgInIndic
  PosLgAleIndic = PosLgAleIndic
  PosLgStopIndic = PosLgStopIndic
  PosLgInvIndic = PosLgInvIndic
  PosLgFinIndic = PosLgFinIndic
  PosLgFinPlusIndic = PosLgFinPlusIndic
  PosLgObjIndic = PosLgObjIndic
  PosLgPydIndic = PosLgPydIndic
  PosLgBenTrendIndic = PosLgBenTrendIndic
  PosLgBenIndic = PosLgBenIndic
  PosLgOutIndic  = PosLgOutIndic
  
 Endif
EndIf

Return MaxPosNbBar COLOURED(0,0,200) as “Durée Maximum Position”, MinPosNbBar COLOURED(255,0,0) as “Durée Minimum Position”, ROUND(NbMoyPosBar) COLOURED(0,0,255) as “Durée Moyenne Position”, Round(WinPosNbBar / NbTrLgWin ) COLOURED(0,150,0) as “Durée Moyenne Gagnant”, Round(ObjPosNbBar / NbTrLgObj) COLOURED(255,0,200) as “Durée Moyenne Objectif”, Round(FinPosNbBar/NbTrLgFin) COLOURED(255, 150,0) as “Durée Moyenne Financement”, Round(LosPosNbBar / NbTrLgLos) COLOURED(255,0,0) as “Durée Moyenne Perdant”, Round(StopPosNbBar / NbTrLgSto) COLOURED(255,255,0) as “Durée Moyenne Stop”, Round(InvPosNbBar / NbTrLgInv) COLOURED(0,0,0) as “Durée Moyenne Invalidation”

Laisser un commentaire

Votre adresse de messagerie ne sera pas publiée. Les champs obligatoires sont indiqués avec *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>