B-XTrender Système ne prend aucune position

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #219333 quote
    Fgats
    Participant
    New

    Je m’intéresse depuis quelques jours à cet indicateur donné dans la bibliothèque ici et  nommé B-XTrender.  Cet indicateur a été produit par Bharat Jhunjhunwala et publié dans  IFTA journal  (  ifta.org/public/files/journal/d_ifta_journal_19.pdf  ). Une adaptation en a été proposée par Nicolas.  J’ignore si quelqu’un a déjà essayé et proposé un système basé sur cet indicateur mais l’auteur, lui, dans le même article en propose un.   J’ai tenté une traduction en PRT langage et je vous la soumets ci-dessous :

    // B-XTrender System
    DEFPARAM CUMULATEORDERS = false
    //DEFPARAM FLATBEFORE = 090000
    //DEFPARAM FLATAFTER = 213000

    //stpLossPIP = 40
    //TgtprofitPIP = 2 * stpLossPIP
    //SET STOP pLOSS stpLossPIP
    //SET TARGET PPROFIT TgtprofitPIP

    // Forex EUR/USD en 5 minutes
    nbLots = 1 // 100000

    Once nbrePosJourMax = 2

    // reset de variables en début de journée
    IF IntradayBarIndex = 0 THEN
    nbreAppelsPos = 0
    condTradeJour = 1 // booléen
    endif

    // vérification du nbre de positions ouvertes
    if nbreAppelsPos < nbrePosJourMax then
    condTradeJour = 1
    else
    condTradeJour = 0
    endif

    // — settings
    shortl1 = 5 //Short – L1
    shortl2 = 20 //Short – L2
    shortl3 = 15 //Short – L3

    longl1 = 20 //Long – L1
    longl2 = 15 //Long – L2
    // — end of settings
    ///////////////////////////////////////////////////////////////
    // stratégie
    shortTerm = rsi[shortl3](average[shortl1,1]-average[shortl2,1])-50
    longTerm = rsi[longl2](average[longl1,1])-50

    PosChangeInLongTerm = (longTerm[-1] < 0 and longTerm > 0)
    NegChangeInLongTerm = (longTerm[-1] > 0 and longTerm < 0)
    PosChangeInShortTerm = (shortTerm[-1] < 0 and shortTerm > 0)
    NegChangeInShortTerm = (shortTerm[-1] > 0 and shortTerm < 0)

    ChangeInLongTerm = PosChangeInLongTerm OR NegChangeInLongTerm
    ChangeInShortTerm = PosChangeInShortTerm OR NegChangeInShortTerm

    InitialBuy = PosChangeInLongTerm
    InitialSell = NegChangeInLongTerm

    Achat = InitialBuy or ((longTerm > 0) and PosChangeInShortTerm)
    Vente = (longTerm > 0) and NegChangeInShortTerm
    Short = InitialSell or ((longTerm < 0)) and NegChangeInShortTerm
    ExShort = (longTerm < 0) and PosChangeInShortTerm

    //////////////////////////////////////////////////////////////
    // Prises de Positions

    IF Achat and condTradeJour THEN
    nbreAppelsPos = nbreAppelsPos + 1
    BUY nbLots CONTRACTS AT MARKET
    ENDIF

    If LongOnMarket AND Vente THEN
    SELL nbLots CONTRACTS AT MARKET
    ENDIF

    IF Short and condTradeJour THEN
    nbreAppelsPos = nbreAppelsPos + 1
    SELLSHORT nbLots CONTRACTS AT MARKET
    ENDIF

    IF ShortOnMarket AND ExShort THEN
    EXITSHORT nbLots CONTRACTS AT MARKET
    ENDIF

    //////////////////////////////////////////////////////////////

    (désolé mais je n’ai toujours pas compris comment on peut insérer proprement des lignes de programme dans ce forum)

    Je pense avoir traduit correctement ce programme mais, en fait, je n’en suis pas certain pour la bonne raison qu’il refuse de prendre une quelconque position  !

    Si donc, quelqu’un pouvait m’aidait à sortir de mon impasse je lui en serai reconnaissant.

    Bon après-midi à tous,

    Gabriel

    #219334 quote
    JC_Bywan
    Moderator
    Master

    longTerm[-1] ne correspond à rien en syntaxe de ce langage de programmation… est-ce que tu voulais faire référence à la valeur de longTerm à la bougie précédente? Si oui, alors [1] plutôt…

    idem shortTerm[-1]

     

    (pour faire réapparaitre le bouton “insert PRT code”, bien qu’il semble que ça ne fonctionne pas forcément avec tous les navigateurs:

    )

    #219335 quote
    robertogozzi
    Moderator
    Master

    Lorsque vous souhaitez faire référence à une bougie spécifique, vous ne pouvez utiliser que des valeurs> = 0, PAS négatives ([0] n’est pas nécessaire, car il est supposé par défaut lorsque les crochets sont manquants), [1] indique le premier bougie précédente, [2 ] la deuxième etc…
    [-1] Ce n’est PAS autorisé, lorsqu’il a un comportement incorrect, dans ce cas il ne trouve pas cette bougie, donc la condition n’est PAS vérifiée et aucune opération n’est ouverte:

    Voici comment vous écrivez ces quatre lignes :

    PosChangeInLongTerm = (longTerm[1] < 0 and longTerm > 0)
    NegChangeInLongTerm = (longTerm[1] > 0 and longTerm < 0)
    PosChangeInShortTerm = (shortTerm[1] < 0 and shortTerm > 0)
    NegChangeInShortTerm = (shortTerm[1] > 0 and shortTerm < 0)
    #219337 quote
    robertogozzi
    Moderator
    Master

    Deux réponses valent mieux qu'une ! 🙂

    #219345 quote
    Fgats
    Participant
    New

     

    Mais c’est  bien sûr !  ….

    Comment n’ai-je pas vu cela  …..

    Merci à vous,

    Gabriel

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.

B-XTrender Système ne prend aucune position


ProOrder : Trading Automatique & Backtests

New Reply
Author
author-avatar
Fgats @fgats Participant
Summary

This topic contains 4 replies,
has 3 voices, and was last updated by Fgats
2 years, 6 months ago.

Topic Details
Forum: ProOrder : Trading Automatique & Backtests
Language: French
Started: 08/19/2023
Status: Active
Attachments: No files
Logo Logo
Loading...