RSI classical and hidden Divergences Indicator

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

    Hi,

    Francesco had done a great job with the strategy indicator. I like it. Thank you Frank.

    However, I wanted to convert this as a strategy but it doesn’t work…

    I’ve removed line 31 to 35 and 51 to 55 replaced by the “buy 1 contract at market”… error.

    Anyone would have a “tuto” or a piece of advice, I’d be happy to learn “how to” tweak it (same for other great indicators from the library…)

    Thank you all.

    //RSI Divergences By Frank (Francesco)
     
    //Description: the indicator draws arrows on chart as entry points when a direct or an hidden RSI divergence is found.
    //When a DIRECT divergence is found, "dd" (direct divergence) text is added to chart over (Sell signal) or under (Buy signal) the arrow
     
    //When an HIDDEN or INVERSE divergence is found, "hd" (hidden divergence) text is added to chart over (Sell signal) or under (Buy signal) the arrow
     
    //Variables:
    //RsiPeriod: number of bars to calculare RSI value
    //RsiOverSold: Oversold Level
    //RsiOverBought: OverBought Level
    //MinBarRange: minimum distance from two consecutive RSI Highs or RSI Lows
     
    Rge = averagetruerange[10](close)
    MyRSI = rsi[RsiPeriod](Close)
     
    ONCE ShiftText = 3
     
    RsiMax = MyRSI < MyRSI[1] and MyRSI[1] > MyRSI[2] and MyRSI[1] > RsiOverBought
    RsiMin = MyRSI > MyRSI[1] and MyRSI[1] < MyRSI[2] and MyRSI[1] < RsiOverSold
     
    if RsiMax then
     RSIMax1 = MyRSI[1]
     High1 = High[1]
     
     for I = MinBarRange to  80
      if RsiMax[I] then
       RSIMax2 = MyRSI[I + 1]
       High2 = High[I + 1]
       If High1 > High2 and RSIMax1 < RSIMax2 then
        DRAWARROWDOWN(barindex, High + Rge / ShiftText)coloured(255,192,203,255)
        DRAWTEXT("dd", barindex, High + Rge / ShiftText / 0.3,SansSerif,Italic,10)coloured(0,0,255,255)
       elsif High1 < High2 and RSIMax1 > RSIMax2 then
        DRAWARROWDOWN(barindex, High + Rge / ShiftText)coloured(255,192,203,255)
        DRAWTEXT("hd", barindex, High + Rge / ShiftText / 0.2,SansSerif,Italic,10)coloured(0,0,255,255)
       endif
       break
      endif
     next
    endif
     
    if RsiMin then
     RSIMin1 = MyRSI[1]
     Low1 = Low[1]
     
     for I = MinBarRange to  80
      if RSIMin[I] then
       RSIMin2 = MyRSI[I + 1]
       Low2 = Low[I + 1]
       If Low1 < Low2 and RSIMin1 > RSIMin2 then
        DRAWARROWUP(barindex, lOW - Rge / ShiftText)coloured(0,0,255,255)
        DRAWTEXT("dd", barindex, lOW - Rge / ShiftText / 0.3,SansSerif,Italic,10)coloured(0,0,255,255)
       elsif Low1 > Low2 and RSIMin1 < RSIMin2 then
        DRAWARROWUP(barindex, lOW - Rge / ShiftText)coloured(0,0,255,255)
        DRAWTEXT("hd", barindex, lOW - Rge / ShiftText / 0.2,SansSerif,Italic,10)coloured(0,0,255,255)
       endif
       break
      endif
     next
    endif
     
    return
    #59710 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Topic moved to Probuilder support.

    Inertia thanked this post
    #59716 quote
    InertiaInertia
    Participant
    Master

    Hereafter is my attemp…but doesn’t work… omg, why ? “Endif” is missing somwhere ?

    //RSI Divergences By Frank (Francesco)
     
    Rge = averagetruerange[10](close)
    MyRSI = rsi[RsiPeriod](Close)
     
    ONCE ShiftText = 3
     
    RsiMax = MyRSI < MyRSI[1] and MyRSI[1] > MyRSI[2] and MyRSI[1] > RsiOverBought
    RsiMin = MyRSI > MyRSI[1] and MyRSI[1] < MyRSI[2] and MyRSI[1] < RsiOverSold
     
    if RsiMax then
    RSIMax1 = MyRSI[1]
    High1 = High[1]
     
    for I = MinBarRange to  80
    if RsiMax[I] then
    RSIMax2 = MyRSI[I + 1]
    High2 = High[I + 1]
    
    //Conditions below, no ?!
    If High1 > High2 and RSIMax1 < RSIMax2 then
    //instead od drawarrowdown or drawtext, buy...
    buy 1 contract at market
    endif
    //Conditions below, no ?!
    elsif High1 < High2 and RSIMax1 > RSIMax2 then
    //instead od drawarrowdown or drawtext, buy...
    buy 1 contract at market
    endif
     
    if RsiMin then
    RSIMin1 = MyRSI[1]
    Low1 = Low[1]
     
    for I = MinBarRange to  80
    if RSIMin[I] then
    RSIMin2 = MyRSI[I + 1]
    Low2 = Low[I + 1]
    
    //Conditions below, no ?!
    If Low1 < Low2 and RSIMin1 > RSIMin2 then
    //instead od drawarrowdown or drawtext, buy...
    buy 1 contract at market
    endif
    //Conditions below, no ?!
    elsif Low1 > Low2 and RSIMin1 < RSIMin2 then
    //instead od drawarrowdown or drawtext, buy...
    buy 1 contract at market
    endif
    
    #59733 quote
    mr bluemr blue
    Participant
    Senior

    OK – I try to assist a bit .. I took above source and added some missing statements so that at least the strategy gives  A RESULT – but I don’t understand yet! how it should work.

    anyway, hope it helps a bit

    //RSI Divergences By Frank (Francesco)
    
    defparam cumulateorders = false
    defparam flatbefore = 090000
    defparam flatafter = 180000
    
     
    
    RsiPeriod = 14
    RsiOverSold = 20
    RsiOverBought= 80
    MinBarRange = 1
    
    MyRSI = rsi[RsiPeriod](Close)
     
     
    RsiMax = MyRSI < MyRSI[1] and MyRSI[1] > MyRSI[2] and MyRSI[1] > RsiOverBought
    RsiMin = MyRSI > MyRSI[1] and MyRSI[1] < MyRSI[2] and MyRSI[1] < RsiOverSold
     
    if RsiMax then
    RSIMax1 = MyRSI[1]
    High1 = High[1]
     
    for I = MinBarRange to  80 do
    if RsiMax[I] then
    RSIMax2 = MyRSI[I + 1]
    High2 = High[I + 1]
    
    //Conditions below, no ?!
    If High1 > High2 and RSIMax1 < RSIMax2 then
    //instead od drawarrowdown or drawtext, buy...
    buy 1 contract at market
    endif
    //Conditions below, no ?!
    elsif High1 < High2 and RSIMax1 > RSIMax2 then
    //instead od drawarrowdown or drawtext, buy...
    buy 1 contract at market
    endif
     
    if RsiMin then
    RSIMin1 = MyRSI[1]
    Low1 = Low[1]
     
    for I = MinBarRange to  80 do
    if RSIMin[I] then
    RSIMin2 = MyRSI[I + 1]
    Low2 = Low[I + 1]
    
    //Conditions below, no ?!
    If Low1 < Low2 and RSIMin1 > RSIMin2 then
    //instead od drawarrowdown or drawtext, buy...
    buy 1 contract at market
    endif
    //Conditions below, no ?!
    elsif Low1 > Low2 and RSIMin1 < RSIMin2 then
    //instead od drawarrowdown or drawtext, buy...
    buy 1 contract at market
    endif
    next
    endif
    
    
    next
    endif
    
    

     

    adapted on the DAX 1E contract …

    #59734 quote
    InertiaInertia
    Participant
    Master

    You are my man Mr Blue ! Big thank.

    I got the modifications you made for the next time.

     

    Good site “Diffchecker” Mr GraHal.

    discrepancies.png discrepancies.png
Viewing 5 posts - 1 through 5 (of 5 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

RSI classical and hidden Divergences Indicator


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Inertia @inertia Participant
Summary

This topic contains 4 replies,
has 3 voices, and was last updated by InertiaInertia
8 years, 8 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 01/17/2018
Status: Active
Attachments: 1 files
ProRealCode ProRealCode
Loading...