Morning Star rules not respected

Viewing 15 posts - 1 through 15 (of 21 total)
  • Author
    Posts
  • #94059 quote
    Bard
    Participant
    Master

    Hi

    I can’t find a good Morning Star candlestick pattern on here that respects Charles Bulkowski’s definition. He is regarded as the master on candlestick studies publishing % return tables for candlestick patterns. See http://thepatternsite.com/MorningStar.html

    Eg: MorningStar,  Bullish Reversal, Accuracy = 78% in a Bull Market/65% Bear Market with a very low occurrence.

    I have amalgamated different code from prorealcode to obtain the closest to Bulkowski’s definition for this pattern. In the first screenshot the last green candle (with a white arrow after the Morning Star) doesn’t respect the rule that it should climb up to over half the opening candles body length (first long white long candle), probably because maybe I haven’t coded it correctly?

    I think adding a bullish pinbar code (on this forum) for extending the Morning Star candle shadow may also help to respect the rules further.

    (First screen Morning Star pattern from XAGUSD Daily 9th Feb 2000)

    if range>0 then
    ratio=body/range
    else
    ratio=0
    endif
    
    longcandle= (ratio>0.7)
    
    body=close-open
    
    abody=abs(body)
    
    
    MorningStar     = 0
    signal          = 0
    
    if MorningStar then
    signal = 5
    endif
    
    //text color
    // white = 255,255,255 ; black = 0,0,0
    r = 255
    g = 51
    b = 51
    
    //Orig
    //e1 = close[2] < open[2]  // red candle
    //e2 = open[1] < close[2] and close[1] < close[2] and low[1] < close[2] // candle entirely below predecessor's body
    //e3 = close[0] > open[0] and open[0] > open[1] and high[0] > low[1]  // green candle with a gap
    //e4 = range[1] > (range[2] / 2 ) and close[0] > (open[2] - close[2]/2)  // morning star's range is small compared to preceding candle
    
    e1 = body[2]<0 and body>0 and longcandle[2] // red candle
    e2 = open[1]<close[2] and low[1]<low[2] and low[1]<low[0] and high[1]<open[2] and high[1]<close [0] and abody[1]<abody[2] and abody[1]<abody[0] // small candle entirely below predecessor's body
    e3 = open[0]>close[1] and ratio[1]<0.3 and close[0] > (open[2] - close[2]/1.5)//green candle with a gap
    
    if e1 and e2 and e3 then
    MorningStar = 1
    endif
    
    if MorningStar = 1 then
    signal = 1
    endif
    
    if e1 and e2 and e3 then
    DRAWTEXT("Morning Star", barindex, high, Dialog, Standard, 20) COLOURED(R,G,B)
    DRAWARROWUP(barindex,low) COLOURED(0,155,10)
    endif
    
    
    Return signal > 0
    #94064 quote
    robertogozzi
    Moderator
    Master

    I suggest that lines 1 through 7  be moved AFTER line 11, since at line 2 BODY has not yet been defined, so it will refer to the body of the previous candlestick.

    #94087 quote
    Bard
    Participant
    Master

    Thanks @Robertogozzi, that makes logical sense, problem is that it now produces zero Morning Stars patterns? There were 4 with Daily Silver so I relaxed the rules for longcandle= (ratio>0.7) changing it to longcandle= (ratio>0.5) and also (open[2] close[2]/1.5) changing it to (open[2] close[2]/2). No patterns. I have tried it on 10,000 units of Daily silver, £/$ $/CHF and £/Yen, yet no patterns? (Please screens of “Morning Star 2” indicator now missing whereas the second image shows it produced a pattern before reversing the body code)

    x.png x.png y.png y.png
    #94096 quote
    robertogozzi
    Moderator
    Master

    I changed it a bit:

    offset1 = 50 * pipsize
    offset2 = offset1 * 4
    body=close-open
    abody=abs(body)
    if range>0 then
    ratio=abody/range
    else
    ratio=0
    endif
    longcandle= (ratio>0.5)   //0.7
    //MorningStar     = 0
    signal          = 0
    //if MorningStar then
    //signal = 5
    //endif
    //text color
    // white = 255,255,255 ; black = 0,0,0
    r = 255
    g = 51
    b = 51
    //Orig
    //e1 = close[2] < open[2]  // red candle
    //e2 = open[1] < close[2] and close[1] < close[2] and low[1] < close[2] // candle entirely below predecessor's body
    //e3 = close[0] > open[0] and open[0] > open[1] and high[0] > low[1]  // green candle with a gap
    //e4 = range[1] > (range[2] / 2 ) and close[0] > (open[2] - close[2]/2)  // morning star's range is small compared to preceding candle
    e1 = body[2]<0 and body>0 and longcandle[2] // red candle
    e2 = open[1]<close[2] and low[1]<low[2] and low[1]<low[0] and high[1]<open[2] and high[1]<close[0] and abody[1]<abody[2] and abody[1]<abody[0] // small candle entirely below predecessor's body
    e3 = open[0]>close[1] and ratio[1]<0.5 and close[0] > open[2]//(open[2] - close[2]/1.5)//green candle with a gap
    if e1 and e2 and e3 then
    //MorningStar = 1
    //endif
    //if MorningStar = 1 then
    signal = 1
    //endif
    //if e1 and e2 and e3 then
    DRAWTEXT("Morning Star", barindex,low-offset2, Dialog, Standard, 14) COLOURED(R,G,B)
    DRAWARROWUP(barindex,low-offset1) COLOURED(0,155,10)
    endif
    if signal then
    endif
    Return// signal

    I used it on the price chart, not below.

    The second and third last lines are intended to use the variable SIGNAL only (dummy lines).

    As you can see I commented out many unnecessary lines and modified line 28 (your line 35).

    I also addet the first two line to set offset values to plot at a distance from the candles.

    I also changed line 6 (your line 2).

    Few patterns were found, but this may depend on settings. The pattern recognition seems to work.

    Bard thanked this post
    silver.jpg silver.jpg Sp500.jpg Sp500.jpg
    #94130 quote
    Bard
    Participant
    Master

    That’s much appreciated @Robertogozzio, thanks for re-writing this code,

    A number of thoughts occur to me:

    Can you think why the first candle of the Morning Star formation is still very short? In your first screenshot both red candles don’t have a long body. I believe this is a crucial part of the pattern where the Bears think they have the upper hand and then the price gaps down to the Star candle only to powerfully reverse direction after it, (i.e. an exhaustion point).

    There appears to be no gap between the opening of the third green candle and the Morning Star candle in the first two examples? (Hence the name “Star”).

    Also I think it’s important for the third green candle to cover / retrace back to at least over half the height of the first long red candles body – which they do – but in these examples is that only because the first red candles are all short in body?

    Nice offset tip too!

    Cheers
    Bard

    #94142 quote
    robertogozzi
    Moderator
    Master

    Line 10 (my version’s)  deals with the size of the body, but not with the size of the range. A big body is only evaluated with reference to its range, if it’s a candle having a small range, then its body will be even smaller!

    You must define a way to translate into code what you would do when sitting in front of your PC; when you watch your charts, when do you say “this candle is big enough”:

    1. when it has a big range, regardless of its body size?
    2. when it has a big body, regardless of its range?

    then code then accordingly. You might use averages to compute the average (body or range) size of the last, say 50, candle and consider a candle as being a big one if it exceeds that average.

    Example 1 (body size average):

    Body     = abs(close - open)     //definition of body
    BodySize = average[50,0](Body)   //average of the body size of the last 50 candles
    MyCond   = Body > BodySize       //MyCond is true id the size exceeds the average one

    Example 2 (body size in relation to the average range size):

    Body      = abs(close - open)        //definition of body
    RangeSize = average[50,0](range)     //average of the range size of the last 50 candles
    MyCond    = Body > (RangeSize * 0.7) //MyCond is true if the size exceeds a percentage of the average RangeSize
    Bard thanked this post
    #94337 quote
    Bard
    Participant
    Master

    Thanks for explaining the issue @Robertogozzi.

    I added the second option:

    Body = abs(close – open) //definition of body
    RangeSize = average[50,0](range) //average of the range size of the last 50 candles
    LongCandle = Body > (RangeSize * 0.9) //LongCandle is true if the size exceeds a percentage of the average RangeSize
    
    e1 = close[2] < open[2] // red candle
    e2 = open[1] < close[2] and close[1] < close[2] and low[1] < close[2] // candle entirely below predecessor’s body
    e3 = close[0] > open[0] and open[0] > open[1] and low[0] < high[1] and LongCandle // green candle with a gap //and ratio[0]>0.3
    e4 = range[1] < (range[2] / 2 ) // morning star’s range is small compared to preceding candle

    ..and yet there is still a small red (white) candle as the first candle of the formation even though I upped the RangeSize to 0.9? Range size has some big candles: Pls see screenshot. I also tried the first option with the pattern still showing despite the opening small down candle.

    Any ideas how to get rid of these dwarf candles!? (on the crosshair in image)

    Cheers

    a.png a.png
    #94339 quote
    robertogozzi
    Moderator
    Master

    You could replace line 5 with:

    e1 = close[2] < open[2] AND LongCandle // red candle

    but if you think LongCandle is too much for the second previous candle, then you can define a smaller LongCandle and use both definitions (with different names):

    Body = abs(close – open) //definition of body
    RangeSize = average[50,0](range) //average of the range size of the last 50 candles
    LongCandle = Body > (RangeSize * 0.9) //LongCandle is true if the size exceeds a percentage of the average RangeSize
    LongCandle2 = Body > (RangeSize * 0.5) //LongCandle is true if the size exceeds a percentage of the average RangeSize
    e1 = close[2] < open[2] AND LongCandle2 // red candle
    e2 = open[1] < close[2] and close[1] < close[2] and low[1] < close[2] // candle entirely below predecessor’s body
    e3 = close[0] > open[0] and open[0] > open[1] and low[0] < high[1] and LongCandle // green candle with a gap //and ratio[0]>0.3
    e4 = range[1] < (range[2] / 2 ) // morning star’s range is small compared to preceding candle
    
    Bard thanked this post
    #94352 quote
    Bard
    Participant
    Master

    Thanks very much again for the modifications, right.. there was a LongCandle in previous versions, not that it worked then.

    Thing is, even with the exact same code as above or even with slight modifications to your code (swapping the LongCandles), to really follow Bulkowski’s definition as close as possible — (i.e. large first red candle and the last green candle’s price, after the Morning Star, must climb at least over half way into the red body of the first red candle) — this code still produces a “red dwarf?”

    Body = abs(close - open) //definition of body
    RangeSize = average[150,0](range) //average of the range size of the last 50 candles
    LongCandle = Body > (RangeSize * 0.9) //LongCandle is true if the size exceeds a percentage of the average RangeSize
    LongCandle2 = Body > (RangeSize * 0.6) //LongCandle is true if the size exceeds a percentage of the average RangeSize
    e1 = close[2] < open[2] AND LongCandle // red candle
    e2 = open[1] < close[2] and close[1] < close[2] and low[1] < close[2] // candle entirely below predecessor’s body
    e3 = close[0] > open[0] and open[0] > open[1] and low[0] < high[1] and LongCandle2 // green candle with a gap //and ratio[0]>0.3
    e4 = range[1] < (range[2] / 2 ) // morning star’s range is small compared to preceding candle

    I also notice my first post didn’t contain the images from Bulkowski’s book, which I tried twice to upload, thinking the second time had been successful. I’m going to try again here with at least one of the screens:

    b.png b.png
    #94357 quote
    robertogozzi
    Moderator
    Master

    There’s no requirement for the long black candle, it just needs to be long.

    It’s up to anyone one defining how long enough is LONG.

    If you think an average does not help, you can replace it with the sum of the previous 2-3 candles’range or maybe the previous one multiplied by some factor.

    Look at your chart and when you see a candle and think “this is not a dwarf”, well… code exactly what your eyes see.

    Bard thanked this post
    #94358 quote
    Bard
    Participant
    Master

    Also realised this code will need to be added…:

    bearishbody = ABS(open-close)
    bearishwick = ABS(high-close)
    //bearishnose = ABS(close-low)
    
    e5 = bearishwick/bearishbody < 30/100

    …so this exhaustion point spike on the green candle (after the Morning Star) is taken account of and avoids a Morning Star signal being given (see Morning Star 4 indicator) :

    b-1.png b-1.png
    #94365 quote
    robertogozzi
    Moderator
    Master

    The more rules you add, the less clear and uncertain your definition will be!

    There are a million candlestick combinations around, you cannot follow any DWARF candle your eyes see and get rid of it…. you’ll need a million rules!

    Have ONE rule, you’ll get rid of, say 67-75 %, of dwarfs; still, you’ll have have some left. It’s like a strategy, no strategy will EVER have a 100% winning rate!

    Few simple rules, few simple lines of code, few indicators, few… everything will prove to be more winning than anything else.

    In the second last pic you attached you can read “ignore the shadows in this candlestick pattern“. DO stick to this rule.

    Bard thanked this post
    #94368 quote
    Vonasi
    Moderator
    Master

    no strategy will EVER have a 100% winning rate!

    Not quite true.

    //SP500
    //Daily
    
    if date = 19700101 then
    buy 1 contract at market
    endif
    
    if date = 20190321 then
    sell at market
    endif
    #94369 quote
    robertogozzi
    Moderator
    Master
    • no strategy will EVER have a 100% winning rate!

      Not quite true.

    • Any overnight fee/rollover?
    • Would you have opened that trade on Jan. 1st, 1970?
    #94381 quote
    Vonasi
    Moderator
    Master

    Any overnight fee/rollover? Would you have opened that trade on Jan. 1st, 1970?

    Even with fees it has a 100% win rate.

    No I wouldn’t have bought as I was only a few months old and so unable to open an account with a broker due to silly age restrictions.

Viewing 15 posts - 1 through 15 (of 21 total)
  • You must be logged in to reply to this topic.

Morning Star rules not respected


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Bard @brad Participant
Summary

This topic contains 20 replies,
has 3 voices, and was last updated by Bard
6 years, 10 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 03/19/2019
Status: Active
Attachments: 7 files
Logo Logo
Loading...