Hartelijk gefeliciteerd met Uw verjaardag
Doc
ps love monster and will get around to purchasing it this year
Thank you milanese, stevehopwood, baluda, till now problem is not solved, i'll check the code and Happy birthday Baluda sir.Baluda » Wed Feb 25, 2015 2:44 pm wrote:As we say in the Netherlands,
Meaning problems can be solved in several ways.There are different ways to get to Rome.
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.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 ); }
Ask away if the code is not clear enough.
Enjoy, it is my birthday today.
Paul
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];
}
}Hi sir, it's not working for me, i'm using version 4 765 built, does this code working on your terminal?Baluda » Wed Feb 25, 2015 2:44 pm wrote:As we say in the Netherlands,
Meaning problems can be solved in several ways.There are different ways to get to Rome.
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.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 ); }
Ask away if the code is not clear enough.
Enjoy, it is my birthday today.
Paul