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

Custom Candle Stick Pattern
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=4111
Page 2 of 2
Author:  DocT [ Wed Feb 25, 2015 3:46 pm ]
Post subject:  Custom Candle Stick Pattern

Paul

Hartelijk gefeliciteerd met Uw verjaardag :!!:

Doc

ps love monster and will get around to purchasing it this year ;-)
Author:  montyy [ Wed Feb 25, 2015 7:43 pm ]
Post subject:  Custom Candle Stick Pattern

Baluda » Wed Feb 25, 2015 2:44 pm wrote: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
Thank you milanese, stevehopwood, baluda, till now problem is not solved, i'll check the code and Happy birthday Baluda sir.
Author:  dietcoke [ Wed Feb 25, 2015 8:16 pm ]
Post subject:  Custom Candle Stick Pattern

try this Montyy

Code: Select all

 if(
       Close[i] > Open[i] //This bar is bullish
    && Close[i+1] > Open[i+1] //last bar is bullish
    && Close[i]>Close[i+1] //This close above last  close
    && Open[i]<=Open[i+1]//This open is below or level with the last open
        {
         LongBuffer[i]=Low[i]-Range;
         if(alertTag!=Time[0] && i==0 && useAlert==true)
           {
            Alert("BULL_BULL-Alert");
            alertTag=Time[0];
           }
        }
Author:  montyy [ Wed Feb 25, 2015 11:47 pm ]
Post subject:  Custom Candle Stick Pattern

Baluda » Wed Feb 25, 2015 2:44 pm wrote: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
Hi sir, it's not working for me, i'm using version 4 765 built, does this code working on your terminal?
Author:  milanese [ Thu Feb 26, 2015 12:00 am ]
Post subject:  Custom Candle Stick Pattern

I locked this thread, as the user is only creating confusion and nothing else, montyy you will in the next weeks only be able to read in this board and to learn..

Cheers :)

Tommaso
All times are UTC Page 2 of 2