Stop suiveur dans position longue

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #174681 quote
    trading2trading2
    Participant
    Junior

    Bonjour,

    Débutant dans la programmation je souhaiterai programmer un stop suiveur en position longue pour des actions dans une strategie automatique ( UT = 5mn ) afin de cloturer la position

    1/  Stop initial mise en place à la bougie de l’ouverture de la position :  200 $ de pertes ( par exemple )

    2/ puis  apres : Si  Close (n)  > High (n+1)  alors Stop devient Low ( n+1 )

    ce que je veux dire :  Si la cloture de la bougie est > au plus haut de la bougie d’avant le Stop passe au plus bas de la bougie d’avant .

    Si tel n’est pas le cas le Stop ne bouge pas , il reste identique .

    Vous remerciant à l’avance

    #174714 quote
    NicolasNicolas
    Keymaster
    Legend

    1/ ajouter un SET STOP $LOSS 200

    2/ identifier la condition, créer un flag pour continuellement permettre l’ajout d’un ordre conditionnel STOP permettant de sortir à ce niveau :

    //reset le stop loss
    if not onmarket then 
     mystop = 0
    endif 
    
    n = 1 //à modifier à convenance 
    if longonmarket then 
     if close[n] > high[n+1] then 
      mystop = max(mystop,low[n+1]) //nouveau seuil de stoploss
     //Close (n)  > High (n+1)  alors Stop devient Low ( n+1 )
     endif 
    endif 
    
    //place le stoploss
    if onmarket and mystop>0 then 
     sell at mystop stop
    endif

    non testé.

    trading2 thanked this post
    #174761 quote
    trading2trading2
    Participant
    Junior

    Merci beaucoup Nicolas,

    Je vais voir pour incrémenter le n de 1 jusqu’à la barre à laquelle l’ordre a ete executée.

    Merci encore

    #174769 quote
    NicolasNicolas
    Keymaster
    Legend

    En faisant une soustraction à chaque nouveau chandelier:

    n = max(1,barindex-tradeindex)
Viewing 4 posts - 1 through 4 (of 4 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

Stop suiveur dans position longue


ProOrder : Trading Automatique & Backtests

New Reply
Author
author-avatar
trading2 @trading2 Participant
Summary

This topic contains 3 replies,
has 2 voices, and was last updated by NicolasNicolas
5 years, 1 month ago.

Topic Details
Forum: ProOrder : Trading Automatique & Backtests
Language: French
Started: 08/04/2021
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...