Swinglines

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #97140 quote
    Lighthouse
    Participant
    Master

    I am trying to build an indicator as shown in this screenshot from youtube.

    This gentleman is Ira Epstein and posts his end of day financial videos on YouTube.

    The indicator I am referring is a swingline (the one in gold color that connects highs and lows in the screenshot).

    I would like to see what is the low and the high let’s say 50 bars ago, and check each following bar at a time looking for:

    • higher highs
    • lower lows
    • inside days
    • outside days up
    • outside days down

    (which he mentions here https://www.youtube.com/watch?v=CVrfDOVKLlE ) and connect the points to be connected.

    The original indicator is copyrighed but I am only trying to replicate it looking at his videos and listening what he said.

    Could some good soul please post a simple code to connect all the lows in a chart from, let’s say, 50 bars ago?

    I need this simple kick-off because I can’t understand how “drawsegment” works in practice.

    capture_003_24042019_103621.jpg capture_003_24042019_103621.jpg
    #97144 quote
    robertogozzi
    Moderator
    Master
    N = 50
    For i = N DownTo 1
       DRAWSEGMENT(barindex[i],low[i],barindex[i-1],low[i-1])coloured(0,128,0,255)
    Next
    Return

    Not tested.

    Lighthouse thanked this post
    #97160 quote
    Lighthouse
    Participant
    Master

    Thanks

    This is the indicator I thought.

    The original one is proprietary to Ira Epstein, and I tried only to replicate it looking at his charts posted on youtube videos and trying to understand the logic in which he combined the data.

    Surely it has some flaws but it seems to work the way I wanted.

    Let’s call it a Beta version

    PS


    @Roberto
    /Nicolas

    Could you please modify the title of this thread to “Swinglines”? In case one tries to search it.

    //Swing Lines (from an idea by Ira Epstein)
    
    HH=high[0]>high[1] AND low[0]>low[1]
    LL=high[0]<high[1] AND low[0]<low[1]
    ID=high[0]<=high[1] AND low[0]>=low[1]
    ODU=high[0]>high[1] AND low[0]<low[1] AND close[0]>open[0]
    ODD=high[0]>=high[1] AND low[0]<=low[1] AND close[0]<open[0]
    
    //higher highs higher lows
    if HH then
    DRAWSEGMENT(x1,y1,barindex[0],high[0])coloured(0,0,0)
    x1=barindex[0]
    y1=high[0]
    flag=1
    
    //lower highs lower lows
    elsif LL then
    DRAWSEGMENT(x1,y1,barindex[0],low[0])coloured(0,0,0)
    x1=barindex[0]
    y1=low[0]
    flag=0
    
    //inside day
    elsif ID then
    //if after uptrend
    if flag=1 OR flag=3 or flag=4 then
    DRAWSEGMENT(x1,y1,barindex[0],low[0])coloured(0,0,0)
    x1=barindex[0]
    y1=low[0]
    flag=4
    //if after downtrend
    elsif flag=0 OR flag=2 or flag=5 then
    DRAWSEGMENT(x1,y1,barindex[0],high[0])coloured(0,0,0)
    x1=barindex[0]
    y1=high[0]
    flag=5
    endif
    
    //outside day up
    elsif ODU then
    DRAWSEGMENT(x1,y1,barindex[0],low[0])coloured(0,0,0)
    x1=barindex[0]
    y1=low[0]
    flag=2
    
    //outside day down
    elsif ODD then
    DRAWSEGMENT(x1,y1,barindex[0],high[0])coloured(0,0,0)
    x1=barindex[0]
    y1=high[0]
    flag=3
    else
    
    endif
    
    Return
    
    
    robertogozzi thanked this post
    SP500-Daily.png SP500-Daily.png
    #97167 quote
    GraHal
    Participant
    Master

    Above code added to here

    Snippet Link Library

    Lighthouse thanked this post
    #97307 quote
    Lighthouse
    Participant
    Master

    Some changes (for sake of completeness).

    There are some things that still don’t convince me looking at Ira’s videos

    Inside days seem always  to revert the swinglines

    Outside days seem always to bring the swing line to the side of the bar where the opening is.

    That’s the pattern that seems to appear.

    If some guy (joining his courses) can be more clear and post here what’s the real “thing”, he will be appreciated (without disclosing proprietary informations).

    By now it seems the indicator I built replicates 99% of the times Ira’s one.

    All credits to Ira of course 🙂

     

    //Swing Lines (from an idea by Ira Epstein)
    
    HH=high[0]>high[1] AND low[0]>=low[1]
    LL=high[0]<=high[1] AND low[0]<low[1]
    ID=high[0]<=high[1] AND low[0]>=low[1]
    ODU=high[0]>high[1] AND low[0]<low[1] AND close[0]>open[0]
    ODD=high[0]>high[1] AND low[0]<low[1] AND close[0]<open[0]
    DOJI=high[0]>high[1] AND low[0]<low[1] AND close[0]=open[0]
    
    //higher highs higher lows
    if HH then
    DRAWSEGMENT(x1,y1,barindex[0],high[0])coloured(0,0,0)
    x1=barindex[0]
    y1=high[0]
    flag=1
    
    //lower highs lower lows
    elsif LL then
    DRAWSEGMENT(x1,y1,barindex[0],low[0])coloured(0,0,0)
    x1=barindex[0]
    y1=low[0]
    flag=0
    
    //inside day
    elsif ID then
    //if after uptrend
    if flag=1 OR flag=3 OR flag=5 OR flag=7 then
    DRAWSEGMENT(x1,y1,barindex[0],low[0])coloured(0,0,0)
    x1=barindex[0]
    y1=low[0]
    flag=4
    //if after downtrend
    elsif flag=0 OR flag=2 OR flag=4 OR flag=6 then
    DRAWSEGMENT(x1,y1,barindex[0],high[0])coloured(0,0,0)
    x1=barindex[0]
    y1=high[0]
    flag=5
    endif
    
    //outside day up
    elsif ODU then
    DRAWSEGMENT(x1,y1,barindex[0],low[0])coloured(0,0,0)
    x1=barindex[0]
    y1=low[0]
    flag=2
    
    //outside day down
    elsif ODD then
    DRAWSEGMENT(x1,y1,barindex[0],high[0])coloured(0,0,0)
    x1=barindex[0]
    y1=high[0]
    flag=3
    
    //outside day doji
    elsif DOJI then
    //if after uptrend
    if flag=1 OR flag=3 OR flag=5 OR flag=7 then
    DRAWSEGMENT(x1,y1,barindex[0],low[0])coloured(0,0,0)
    x1=barindex[0]
    y1=low[0]
    flag=6
    //if after downtrend
    elsif flag=0 OR flag=2 or flag=4 OR flag=6 then
    DRAWSEGMENT(x1,y1,barindex[0],high[0])coloured(0,0,0)
    x1=barindex[0]
    y1=high[0]
    flag=7
    endif
    
    endif
    
    Return
    
    GraHal thanked this post
    #99264 quote
    Lighthouse
    Participant
    Master

    Version 2.0

    I changed the way Outside Days are treated because Swinglines didn’t replicate 100% what I see in Ira’s Youtube videos

    It “seems” to me that in those cases the close of the day before is compared with the close of the current day

    //Swing Lines 2.0 (from an idea by Ira Epstein)
    
    HH=high[0]>high[1] AND low[0]>=low[1]
    LL=high[0]<=high[1] AND low[0]<low[1]
    ID=high[0]<=high[1] AND low[0]>=low[1]
    ODU=high[0]>high[1] AND low[0]<low[1] AND close[0]>open[0]
    ODD=high[0]>high[1] AND low[0]<low[1] AND close[0]<open[0]
    DOJI=high[0]>high[1] AND low[0]<low[1] AND close[0]=open[0]
    
    //higher highs higher lows
    if HH then
    DRAWSEGMENT(x1,y1,barindex[0],high[0])coloured(0,0,0)
    x1=barindex[0]
    y1=high[0]
    flag=1
    
    //lower highs lower lows
    elsif LL then
    DRAWSEGMENT(x1,y1,barindex[0],low[0])coloured(0,0,0)
    x1=barindex[0]
    y1=low[0]
    flag=0
    
    //inside day
    elsif ID then
    //if after uptrend
    if flag=1 OR flag=3 OR flag=5 OR flag=7 then
    DRAWSEGMENT(x1,y1,barindex[0],low[0])coloured(0,0,0)
    x1=barindex[0]
    y1=low[0]
    flag=4
    //if after downtrend
    elsif flag=0 OR flag=2 OR flag=4 OR flag=6 then
    DRAWSEGMENT(x1,y1,barindex[0],high[0])coloured(0,0,0)
    x1=barindex[0]
    y1=high[0]
    flag=5
    endif
    
    //outside day up down or doji and close1<close0
    elsif (ODU or ODD or DOJI) AND  close[1]<close[0] then
    DRAWSEGMENT(x1,y1,barindex[0],low[0])coloured(0,0,0)
    x1=barindex[0]
    y1=low[0]
    flag=2
    
    //outside day up down or doji and close1>close0
    elsif (ODU or ODD or DOJI) AND  close[1]>close[0] then
    DRAWSEGMENT(x1,y1,barindex[0],high[0])coloured(0,0,0)
    x1=barindex[0]
    y1=high[0]
    flag=3
    
    //outside day up down or doji and close1=close0
    elsif (ODU or ODD or DOJI) AND  close[1]=close[0] then
    //if after uptrend
    if flag=1 OR flag=3 OR flag=5 OR flag=7 then
    DRAWSEGMENT(x1,y1,barindex[0],low[0])coloured(0,0,0)
    x1=barindex[0]
    y1=low[0]
    flag=6
    //if after downtrend
    elsif flag=0 OR flag=2 or flag=4 OR flag=6 then
    DRAWSEGMENT(x1,y1,barindex[0],high[0])coloured(0,0,0)
    x1=barindex[0]
    y1=high[0]
    flag=7
    endif
    
    endif
    
    Return
    
    GraHal thanked this post
    #164757 quote
    airgb58
    Participant
    New

    Hello Ciccio, been following your posts for a few months now because I found you while I was looking for a swing line indicator for my Thinkorswim platform.  I am not familiar with the ProRealTime platform you use but it looks similar to mine.  I have been looking for a person to make me an indicator (like you have done here) that would work on TOS, however I have been unable to find anyone that’s interested in making me one.  My question to you would you consider making me an indicator just like the one you have here that will work on Thinkorswim?  Thanks for looking.

    airgb58

    #164759 quote
    Lighthouse
    Participant
    Master

    Unfortunately I don’t know Thinkorswim, so I cannot help you.
    Let’s hope someone else can help you in this matter 🙂

    #164760 quote
    robertogozzi
    Moderator
    Master

    @airgb58

    Sorry, but this forum is devoted to ProRealTime only, so we can freely convert any code TO ProRealTime, not the other way round.

    You can apply for paid services at https://www.prorealcode.com/trading-programming-services/, but I don’t know if they can do it.

    Lighthouse thanked this post
Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.

Swinglines


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Lighthouse @ciccio Participant
Summary

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

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 04/25/2019
Status: Active
Attachments: 2 files
Logo Logo
Loading...