Divergences trading

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #25758 quote
    InertiaInertia
    Participant
    Master

    Dear all,

    Greetings !

    That is a great forum…Well done and thank you!

    I have a favor…

    I am trying to code a strategy that might look up for divergences (RSI today but could be another indicators…).

    I am using PRT Probacktest cause I do not know the coding language…Sorry 🙁

    Q: How can I have the code below *looking back from RSI bar close < 30 up to BAR 6 AND/OR 7 AND/OR 8  etc.. up to X bars ???

    *The curent RSI bar must be over 40…with a 6 bars gap in between (could be less…)

    I would be happy to receive any help from any one at any time 😉

    Hereafter is what I have so far…

    // Définition des paramètres du code
    DEFPARAM CumulateOrders = False // Cumul des positions désactivé
    // Annule tous les ordres en attente et ferme toutes les positions à 0:00, puis empêche toute création d'ordre avant l'heure "FLATBEFORE".
    DEFPARAM FLATBEFORE = 090000
    // Annule tous les ordres en attente et ferme toutes les positions à l'heure "FLATAFTER"
    DEFPARAM FLATAFTER = 173000
    
    // Empêche le système de placer des ordres pour entrer sur le marché ou augmenter la taille d'une position avant l'heure spécifiée
    timeEnterBefore = time >= 090000
    
    // Empêche le système de placer des ordres pour entrer sur le marché ou augmenter la taille d'une position après l'heure spécifiée
    timeEnterAfter = time < 173000
    
    // Empêche le système de placer de nouveaux ordres sur les jours de la semaine spécifiés
    daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
    
    // Conditions pour ouvrir une position acheteuse
    c1 = (close < close[7])
    indicator1 = RSI[14](close)
    c2 = (indicator1 >= 0[7])
    indicator2 = RSI[14](close)
    c3 = (indicator2 <= 30)
    indicator3 = RSI[14](close)
    c4 = (indicator3 >= 40)
    
    IF (c1 AND c2 AND c3 AND c4) AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF
    
    // Conditions pour fermer une position acheteuse
    indicator4 = SAR[0.02,0.02,0.2]
    c5 = (close CROSSES UNDER indicator4)
    indicator5 = ExponentialAverage[10](close)
    c6 = (close CROSSES UNDER indicator5)
    
    IF c5 AND c6 THEN
    SELL AT MARKET
    ENDIF
    
    // Stops et objectifs
    SET STOP pLOSS 15
    SET TARGET pPROFIT 45

    Thank you.

    DJ

    #25870 quote
    NicolasNicolas
    Keymaster
    Legend

    Q: How can I have the code below *looking back from RSI bar close < 30 up to BAR 6 AND/OR 7 AND/OR 8 etc.. up to X bars ??? *The curent RSI bar must be over 40…with a 6 bars gap in between (could be less…)

    Sorry, I’d like to help, but I don’t understand clearly your question. Could you please, upload a screenshot or an example of this condition you are trying to catch? Many thanks in advance.

    #25917 quote
    InertiaInertia
    Participant
    Master

    Hi Nicolas.

    Merci pour votre reacivite.

    The strategy current barclose should enter LONG if :

    Price onbarclosed is currently doing a lower low from let’s say *6 bars ago. *variable.

    RSI made a lower low *x bar ago too and must have been lower than 30 (same as price *6 bars ago) BUT current bar close must be higher than 40 =>divergence.

    Then enter LONG.

    1. However, between curent price bar and previous lower low, *4 bars mini should be in between (6 mentionned above just for example..).
    2. *4 bars mini: here is the trick… The strategy should look back for lower lows that occured on RSI until the trader’s choice ( mini 4 up to 30 or 40 bars back I suppose…)

    Truly hope that my explanation make more sense now for you Nicolas 😉

    However I do remain at your entire disposal should you need more information.

    Happy Trading.

    DJ

    Divergences-prtsc.png Divergences-prtsc.png
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

Divergences trading


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Inertia @inertia Participant
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by InertiaInertia
9 years, 7 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 02/20/2017
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...