stevehopwoodforex.com
https://www.stevehopwoodforex.com/phpBB3/
Print view

Custom Candle Stick Pattern
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=4111
Page 1 of 2
Author:  montyy [ Sun Feb 15, 2015 11:51 am ]
Post subject:  Custom Candle Stick Pattern

Hi experienced traders,
i'm looking for bull bull pattern.. in this previous candle and current candle both are bullish, but current candle engulf previous candle.

I've tried to make it work

Code: Select all

if ((C1>O1)&&(C>O)&&(C>=C1)&&(O>=O1)&& ((C-O)>=(C1-O1))) {
if (Display_BULL_BULL == true) {
ObjectCreate(PatternText[shift], OBJ_TEXT, 0, Time[shift1], Low[shift1] - Range*1.5);
ObjectSetText(PatternText[shift], "BULL BULL", 9, "Times New Roman", Yellow);
upArrow[shift1] = Low[shift1] - Range*0.5;
}
if (shift == 0 && Show_Alert == true) {
pattern="BULL BULL pattern";
setalert = 1;
}
but it's not showing me what i want ?

and in addition i want bullish engulfing engulf previous two candle body.

I hope someone will help..
Author:  montyy [ Sun Feb 15, 2015 1:12 pm ]
Post subject:  Custom Candle Stick Pattern

Hi peoples,
I've used below file for code. i missed it on my first post.
Author:  milanese [ Sun Feb 15, 2015 1:22 pm ]
Post subject:  Custom Candle Stick Pattern

Try the attached one I coded with your rules..
simplePattern.mq4
Cheers :)

Tommaso
Author:  montyy [ Sun Feb 15, 2015 1:49 pm ]
Post subject:  Custom Candle Stick Pattern

milanese » Sun Feb 15, 2015 1:22 pm wrote:Try the attached one I coded with your rules..

Cheers :)

Tommaso

Sir, it showing me wrong signals.
Here's a pic


is it possible that, instead of arrow it shows me like this bottom pic? As sir, you can see bullish engulfing in red with just specific candle.
Author:  milanese [ Sun Feb 15, 2015 2:05 pm ]
Post subject:  Custom Candle Stick Pattern

montyy » Sun Feb 15, 2015 1:49 pm wrote:
Sir, it showing me wrong signals.
Here's a pic

is it possible that, instead of arrow it shows me like this bottom pic? As sir, you can see bullish engulfing in red with just with specific candle.
it does what your rule was in your code snippet...

If you want an other rule define it better, you have now a simple base to play with ..

Cheers :)

Tommaso
Author:  milanese [ Sun Feb 15, 2015 2:57 pm ]
Post subject:  Custom Candle Stick Pattern

maybe the attached mod matches more your first rule..., for second one just try yourself...
the arrow code you could modify like you want look there --> http://docs.mql4.com/constants/objectco ... /wingdings
you have a list of codes for arrows..
simplePatternA.mq4
Cheers :)

Tommaso
Author:  montyy [ Sun Feb 22, 2015 2:13 pm ]
Post subject:  Custom Candle Stick Pattern

Hi,
I tried to modfied it.
first candle from right must engulf previous bullish candle body in case of bull bull pattern , as you can see after applying this code, no candle fulfulling condition.

1. both should be bullish
C > O && C[i+1] > O[i+1]

2. first candle from right must engulf previous bullish candle(bull bull)
Close>Close[i+1] && Open>Open[i+1]
(Close-Open)>(Close[i+1]-Open[i+1])

but after applying this code, still it's not showing me correct pattern, i don't know why?
for just checking,
i tried to put this code for bull bull pattern

Code: Select all

 if(
       Close[i] > Open[i] && Close[i+1] > Open[i+1] &&
         Close[i]>Close[i+1] && Open[i]>Open[i+1] &&
         (Close[i]-Open[i])>(Close[i+1]-Open[i+1]))
        {
         LongBuffer[i]=Low[i]-Range;
         if(alertTag!=Time[0] && i==0 && useAlert==true)
           {
            Alert("BULL_BULL-Alert");
            alertTag=Time[0];
           }
        }
i replaced that with this current code, but still it's not showing me right pattern ..
one can think it's like same color harami .( in this first candle from right engulf previous bullish candle)
i even draw the pic of pattern. after applying pic , you can see it, it's not engulfing same color candle, because i talked about bull bull.so bullish candle not engulfing previous candle body.those are up or down from the current candle.
Author:  SteveHopwood [ Sun Feb 22, 2015 10:23 pm ]
Post subject:  Custom Candle Stick Pattern

Stop going into such complicated equations. Go for simplicity instead.

In English, to save me thinking about the coding details that are up to you:

Does candle shift 1 engulf candle shift2? Nope? Abandon the function.
It did, so does candle shift 2 engulf candle shift3? Nope? Abandon the function.

etc until you have interrogated as many candles as you want.

Then, your code has got this far, so write code that deals with whatever happens next.

Tip for you. I frequently fail to understand the code of the likes of Baluda here because it is so simple and clever that I simply cannot grasp it. I never fail to understand it because it has complicated equations within complicated equations within complicated equations; guys like Balude do not go in for them.

When it comes to coding at our level, KISS reigns supreme.

:xm:
Author:  Baluda [ Wed Feb 25, 2015 2:44 pm ]
Post subject:  Custom Candle Stick Pattern

As we say in the Netherlands,
There are different ways to get to Rome.
Meaning problems can be solved in several ways.

This is why I came up with this to identify engulfing candles:

Code: Select all

//+------------------------------------------------------------------+
//|                                              WhatsThisCandle.mq4 |
//|                                        Copyright 2015, Deltabron |
//|                                          http://www.deltabron.nl |
//+------------------------------------------------------------------+
#property copyright "Copyright 2014, Deltabron, Paul Geirnaerdt"
#property link      "http://www.deltabron.nl"
#property version   "1.00"
#property strict
#property indicator_chart_window

enum ENUM_CANDLE_TYPES
{
   BULL,
   BEAR,
   DOJI
};
string candleType[] = { "BULLISH", "BEARISH", "DOJI" };


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
{
   return(INIT_SUCCEEDED);
}

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
{
   return(rates_total);
}

//+------------------------------------------------------------------+
//| ChartEvent function                                              |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
{
   if ( id == CHARTEVENT_CLICK )
   {
      int x = (int)lparam;
      int y = (int)dparam;
      datetime dt = 0;
      double price = 0;
      int window = 0;
      
      if ( ChartXYToTimePrice( 0, x, y, window, dt, price ) )
      {
         int shift = iBarShift( NULL, 0, dt );
         
         if ( High[shift] > price && price > Low[shift] )
         {
            // Candle hit!
            ENUM_CANDLE_TYPES candle;
            Print (candleType[candle], " candle is ", IsEngulfing( shift, candle, 2 ) ? "engulfing" : "NOT engulfing");
         
         }
      }
   }
}

ENUM_CANDLE_TYPES GetCandleType( int shift )
{
   ENUM_CANDLE_TYPES result = DOJI;
   
   if ( Close[shift] > Open[shift] ) result = BULL;
   
   else if ( Close[shift] < Open[shift] ) result = BEAR;
   
   return ( result );
}

bool IsEngulfing( int shift, ENUM_CANDLE_TYPES &candle, int count = 1 )
{
   bool result = true;
   
   candle = GetCandleType( shift );
   
   for ( int i = shift + 1; i <= shift + count; i++ )
   {
      switch ( candle )
      {
         case BULL:

            if ( GetCandleType( i ) == BULL ) result = false;

            if ( Open[i] < Open[shift] ) result = false;
            else if ( Close[i] > Close[shift] ) result = false;
            
            break;
         
         case BEAR:

            if ( GetCandleType( i ) == BEAR ) result = false;

            if ( Open[i] > Open[shift] ) result = false;
            else if ( Close[i] < Close[shift] ) result = false;
            
            break;
         
         case DOJI:
         default:
            
            result = false;
            break;
      }   
   }
   
   return ( result );
}
This indicator identifies candles that are clicked on, check the 'Experts' tab. File added to this post.

Ask away if the code is not clear enough.

Enjoy, it is my birthday today.

Paul
Author:  dudest [ Wed Feb 25, 2015 3:21 pm ]
Post subject:  Custom Candle Stick Pattern

Baluda » Wed Feb 25, 2015 5:44 pm wrote:As we say in the Netherlands,

Meaning problems can be solved in several ways.

This is why I came up with this to identify engulfing candles:
...

This indicator identifies candles that are clicked on, check the 'Experts' tab. File added to this post.

Ask away if the code is not clear enough.

Enjoy, it is my birthday today.

Paul
Happy birthday Sir Paul! Hope you enjoy it to the maxx!!

Cheers
:!!:
All times are UTC Page 1 of 2