Valeur initialisé à 0, mais apparaît à 1

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #83288 quote
    schneiderjschneiderj
    Participant
    Average

    Bonjour,

     

    j’ai un souci avec ce code :

    // Définition des paramètres du code
    DEFPARAM CumulateOrders = False // Cumul des positions désactivé
    a = ExponentialAverage[Periode](close)
    b = ExponentialAverage[Periode2](close)
    
    // Passage d'un ordre long
    // Achat de deux mini contrat soit 20 000 €
    // Couverture = 20 000 * 3.3/100 = 660 €
    // Perte maxi autorisée : 10 € -> à modéliser
    
    Once Contrat = 0 // = 1 achetter,,   = -1 vente à découvert
    //Once CoursMax = 0
    
    If Contrat = 0 Then
    If a Crosses Over b Then
    Buy 2 Contract at Market
    Contrat = 1
    //CoursMax = TradePrice
    ElsIf a Crosses Under b Then
    SellShort 2 Contract at Market
    Contrat = -1
    //CoursMax = TradePrice
    EndIf
    EndIf
     
    Graph a Coloured(255,0, 0)
    Graph(b) Coloured(0,255, 0)as "b"
    Graph Contrat Coloured(255,0, 0)
    

    Dés le début de l’exécution du code Contrat est égale à 1 (voir capture ci-dessous) !

    EDIT : j’ai chargé une seconde capture, la première n’ayant pas les échelles !

    A quoi cela est-il du ?

     

    Merci pour votre aide

    Capture-1.jpg Capture-1.jpg Capture-2.jpg Capture-2.jpg
    #83329 quote
    NicolasNicolas
    Keymaster
    Legend

    Cela est dut au fait que le code est lu avant le début du backtest et donc la variable change d’état. Pour éviter ce phénomène, on utilise couramment cette instruction en tête du code :

     

    defparam preloadbars=0
    #83416 quote
    schneiderjschneiderj
    Participant
    Average

    Merci !

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

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

Valeur initialisé à 0, mais apparaît à 1


ProOrder : Trading Automatique & Backtests

New Reply
Author
author-avatar
schneiderj @schneiderj Participant
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by schneiderjschneiderj
8 years ago.

Topic Details
Forum: ProOrder : Trading Automatique & Backtests
Language: French
Started: 10/21/2018
Status: Active
Attachments: 2 files
ProRealCode ProRealCode
Loading...