Steve Nison method indicator

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #177841 quote
    Suzu YukSuzu Yuk
    Participant
    Average

    I would like to exchange ideas on how to program Steve Nison’s candlestick pattern.

    // YS-CandlesPatternV1.0
    //(choose 0=No Trend check, 1=MACD, 2=SAR, 3=Directional Movement, 4=Moving Averages crossing [default], 5=Stochastic)
    TDS=4
    //text color
    // white = 255,255,255 ; black = 0,0,0
    r = 0
    g = 0
    b = 0
    atr = averagetruerange[10](close)*0.5
    body=close-open
    abody=abs(body)
    
    if range>0 then
    ratio=abody/range
    else
    ratio=0
    endif
    
    middle=(open+close)/2
    
    if body>0 then
    bodytop=close
    bodybottom=open
    else
    bodytop=open
    bodybottom=close
    endif
    
    shadowtop=high-bodytop
    
    shadowbottom=bodybottom-low
    
    longcandle= (ratio>0.6)
    
    DojiSize = 0.05
    data=(abs(open - close) <= (high - low) * DojiSize)
    if data then
    DRAWTEXT("Dji", barindex, high+atr*dis1, Dialog, Standard, 12) COLOURED(R,G,B, fade1)
    endif
    if close[1]<close and close<open[1] and close[1]<open and open<open[1] then
    Hara=3
    else
    Nohara=4
    endif
    
    //Trend Detection
    if TDS=0 then
    TrendUp=1
    TrendDown=1
    else
    if TDS=1 then
    TrendUp=(MACDline[12,26,9](close)>0 AND MACD[12,26,9](close)>0)
    TrendDown=(MACDline[12,26,9](close)<0 AND MACD[12,26,9](close)<0)
    else
    if TDS=2 then
    TrendUp=(SAR[0.02,0.02,0.2]<low)
    TrendDown=(SAR[0.02,0.02,0.2]>high)
    else
    if TDS=3 then
    TrendUp=(ADX[14]>23 AND DI[14](close)>0)
    TrendDown=(ADX[14]>23 AND DI[14](close)<0)
    else
    if TDS=4 then
    TrendUp=(ExponentialAverage[2](close)>ExponentialAverage[4](close))
    TrendDown=(ExponentialAverage[2](close)<ExponentialAverage[4](close))
    else
    if TDS=5 then
    TrendUp=(Stochastic[14,3](close)>Average[5](Stochastic[14,3](close)))
    TrendDown=(Stochastic[14,3](close)<Average[5](Stochastic[14,3](close)))
    endif
    endif
    endif
    endif
    endif
    endif
    size1=10
    y=20
    size3=30
    fade1=10
    fade2=100
    fade3=200
    dis1=1
    dis15=1.5
    dis2=2
    dis3=5
    dis4=10
    
    ////Bearish Signal Falling3Method2  p142
    if (open[5]>close[5] AND close[5]<open[4] and open[4]<open[3] and open[3]<open[2] and open[2]<open[1] and close[1]<open AND open>close) or (open[4]>close[4] AND close[4]<open[3] and open[3]>open[2] and open[2]>open[1] and close[1]<open AND open>close) or (open[3]>close[3] AND close[3]<open[2] and open[2]>open[1] and close[1]<open AND open>close)then
    DRAWTEXT("Falling3Method1",barindex,high[1]+atr*dis1, Dialog, Standard, 10) COLOURED(255,0,0,fade2)
    DRAWARROWdown(barindex,high[1]) COLOURED(255,0,0,fade3)
    endif
    
    Return
    
    

    The those three middle white candles (open[3]<close[3] AND close[3]>open[2] and open[2]<open[1] and close[1]>open AND open<close) can possibly continue not only 3 but also 7, 8, 9… middle candles. Then, the code will be too long to express it.

    Alternatively, I have re-coded it using the while loop as the below.

    //Bearish Signal Falling3Method2 p126//////////////////////////////////////////////////////////////////////
    i=1
    while (open[i+4]>close[i+3] AND close[i+3]<open[i+2] and open[i+2]>open[i+1] and close[i+1]<open AND open>close) and i < 30 DO
    i=i+1
    DRAWTEXT("Falling3Method2", barindex,low[1]-atr*dis2, Dialog, Standard, 10) COLOURED(0,155,10,fade2)
    DRAWARROWUP(barindex,low[1]-atr*dis1) COLOURED(0,155,10,fade2)
    Wend

    But it has been unsuccessful. I would appreciate it very much if there is any advice to make it shorter code. Thank you.

    fal.png fal.png
    #177851 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    This is the “Rising Three”. I added a minimum BODY size for the first and last candles. If you don’t want to apply it then uncomment line 5:

    Bullish = close > open
    Bearish = close < open
    Body    = abs(close - open)
    MinSize = average[100](Body)
    //MinSize = 0
    BarID   = 0
    //detect the BULLISH candle prior to the current one
    FOR i = 1 TO BarIndex
       //if found, then all other canndles in between the two bullish ones can be checked
       IF Bullish[i] THEN
          BarID = i                     //ID of the leftmost bullish candle and...
          hh    = high[i]               //... its data
          ll    = low[i]
          Size  = range[i]
          IF Size < MinSize THEN        //check if its size is large enough...
             BarID = 0                     //... or exit
             Break
          ENDIF
          IF BarID >= 3 THEN           //now check the 2+ candles in betweeen...
             FOR j = (BarID - 1) DOWNTO 1 //... which must ALL be within the range of the leftmost Bullish candle...
                IF not ((high[j] <= hh) AND (low[j] >= ll)) THEN
                   BarID = 0              //... or exit
                   break
                ENDIF
             NEXT
          ELSE
             BarID = 0                    //no pattern found if there are lesss than 2 Bearish candles in between
          ENDIF
          Break
       ENDIF
    NEXT
    IF BarID >= 3 THEN
       L1   = (close > close[BarID])
       L2   = (open > close[1])
       IF Body < MinSize THEN        //no pattern found if also the current (rightmost) Bullish bar is < to the minimum Size
          L1 = 0
       ENDIF
       Cond = L1 AND L2
    ELSE
       Cond = 0
    ENDIF
    RETURN Cond AS "Three Rising"
    #177884 quote
    Suzu YukSuzu Yuk
    Participant
    Average

    Thank you very much for your advice. It looks great idea. I will have a look into it.

    However, for others, here is a more clear picture of what I am trying to do. The challenge is that how can we express the possibly large number of white candle bars (not only 3 bars) as code, using while or for a loop.

    3.jpg 3.jpg
    #177887 quote
    Suzu YukSuzu Yuk
    Participant
    Average

    Reference: Steve-Nison-Japanese-Candlestick-Charting-Techniques-Prentice-Hall-Press-2001_1

    #177907 quote
    Suzu YukSuzu Yuk
    Participant
    Average

    Here is a more calibrated version of the original code with Ticker DAX 10ticks chart for Bearish Signal Falling 2 Method up to Falling 7 Method. Still looking for a shorter code of this…

    Bearish-Signal-Falling7Method.itf
    #177915 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    My code can find any number of inside candles, from 2 on…

    You code seems not to be correct, as the rule says that ALL inside candles must be within the RANGE of the leftmost candle in the pattern.

    #178094 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    I have coded a version detecting both the FALLING and the RISING method, any candle in between from 2 to… N.

    I have attached 3 pics of the indicator as it shows on charts and the two ITF files (screener + indicator).

    Suzu Yuk thanked this post
    Rising-Falling-Three-screener.itf Rising-Falling-Three-method.itf Pic1-1.jpg Pic1-1.jpg Pic2-1.jpg Pic2-1.jpg Pic3-1.jpg Pic3-1.jpg
Viewing 7 posts - 1 through 7 (of 7 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

Steve Nison method indicator


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Suzu Yuk @suzu_yuk Participant
Summary

This topic contains 6 replies,
has 2 voices, and was last updated by robertogozzirobertogozzi
5 years ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 09/18/2021
Status: Active
Attachments: 8 files
ProRealCode ProRealCode
Loading...