2ème signal boucle le 1er (erreur)

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #81470 quote
    djamel kouachidjamel kouachi
    Participant
    New

    Salut,

    J’ai un petit problème dans mon code, ça doit être tout simple mais je n’y arrive, quelqu’un pourrait m’éclairer 🙂

    Dans le graph posté, j’ai un signal Short repéré et executé (1ère ellipse).

    Il y a un deuxième signal (cette fois ci Long) qui est repéré (2ème ellipse), celui-ci s’exécute et dans le même temps cloture la position Short de la 1ère ellipse.

    Là est mon problème, je ne veux pas que ce 2ème signal soit executé et surtout pas qu’il cloture une position en cours.

    Dans mon code j’ai essayé avec “DEFPARAM Cumulate orders = false”  mais ça ne doit pas être ça puisque cela ne fonctionne pas.

    Voici mon code :

    DEFPARAM CumulateOrders = false
    
    mm3= average[297]
    mm2= average[99]
    mm1= average[50]
    
    if mm1<mm2 and mm2<mm3 AND RSI > 70 then
    buy 5 contract at market
    endif
    
    if mm1>mm2 and mm2>mm3 and RSI < 30 then
    sellshort 5 contract at market
    endif
    
    //Stops et target
    
    SET STOP pLOSS 25
    SET TARGET pPROFIT 15
    ERREUR-CODE.png ERREUR-CODE.png
    #81646 quote
    NicolasNicolas
    Keymaster
    Legend

    Sujet déplacé dans le forum trading automatique. Merci de bien poster dans l’endroit approprié 🙂

    Cumulateorders = false, ne sera utile que pour forcer le système à ne pas prendre de nouvelles positions dans le même sens, soit ne pas cumuler des positions d’achat par exemple, mais ne supprime pas le fait que l’on puisse prendre des positions dans le sens inverse comme c’est le cas de ton code.

    Pour ne pas initier de nouvelles positions contraire, il faut simplement tester si on est déjà au marché ou non, avec NOT ONMARKET :

    DEFPARAM CumulateOrders = false
    
    mm3= average[297]
    mm2= average[99]
    mm1= average[50]
    
    if not onmarket then 
     if mm1<mm2 and mm2<mm3 AND RSI > 70 then
      buy 5 contract at market
     endif
    
     if mm1>mm2 and mm2>mm3 and RSI < 30 then
      sellshort 5 contract at market
     endif
    endif
    
    //Stops et target
    
    SET STOP pLOSS 25
    SET TARGET pPROFIT 15
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI Nuevo

¿Atascado con este código ProBuilder?

Describe en lenguaje natural lo que este tema intenta construir y ProRealAI escribirá por ti el indicador, screener o sistema de ProRealTime™.

Disponible en 7 idiomas
Probar ProRealAI

2ème signal boucle le 1er (erreur)


ProOrder : Trading Automatique & Backtests

New Reply
Author
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by NicolasNicolas
7 years, 11 months ago.

Topic Details
Forum: ProOrder : Trading Automatique & Backtests
Language: French
Started: 09/27/2018
Status: Active
Attachments: 1 files
ProRealCode ProRealCode
Loading...