You are on page 1of 2

//+------------------------------------------------------------------+

//|
Pinbar Alert .mq4 |
//|
Ephraim Elston |
//|
http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Ephraim Elston"
#property link
"http://www.metaquotes.net"
//+------------------------------------------------------------------+
//| expert initialization function
|
//+------------------------------------------------------------------+
extern double sleeptime=900000;
// 15 minutes (in miliseconds)
extern double Lots=0.1
// mini lot
extern double Slippage=20
// 20*.1 pips=2 pips
int start()
{
//---double Delta1= Open[1] - Close[1];
// candle body (bearish if positive)
double Range= High[1] - Low[1];
// price range of bar
double bullnose= High[1]- Close[1];
// nose of bull pinbar
double bearnose= Close[1]- Low[1];
// nose of bear pinbar
double bullwick= MathAbs(Close[1]-Low[1]);
// wick of bull pinbar
double bearwick= MathAbs(Close[1]- High[1]);
// wick of bear pinbar
double D2= Close[2]-Open[2];
// candle body prior to pin
double D3= Close[3]-Open[3];
// candle body two bars before pin
double ATR1= iATR(NULL,0,14,1);
// ATR of previous candle
double ATRnow= iATR(NULL,0,14,0);
// Current ATR
//----------------------------------------------------------------// Trading Criteria: Pinbar setup
//This code still needs Stoploss and TP variables to be defined. Also, hours of the day to
trade and
//when not to trade are still needed. Expiration time shouldn't be necessary.
// longwick pinbar might not be necessary cuz we can always change range:ATR ratio for bear
and bull pin
if(MathAbs(Delta1/Range)<=0.35 && Range>=(1.5*ATR1) &&(bullnose/Range)<0.16 ||
(bearnose/Range)<0.16)
// if bar(1) is either a bull or bear pinbar with an extra long wick
{
Alert("Long Wick Pinbar detected on",Symbol(),Period());
// send this
alert message
Sleep(60000);
// then wait 1
minute
}
if(MathAbs(Delta1/Range)<=0.35 && Delta1 <0 && Range>=(0.85*ATR1)&& (bullnose/Range)<0.16)
// if bar(1)is bull pinbar
{
OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,bullPin_stop,bullPin_tp,"bought",17,0,Green)

Alert("Bullish Pin bar detected on",Symbol(),Period());


alert message
Sleep(sleeptime);
wait
}

// send this
// then

if(MathAbs(Delta1/Range)<=0.35 && Delta1 >0 && Range>=(0.85*ATR1)&&(bearnose/Range)<0.16)


// if bar(1)is bear pinbar
{
OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,bearPin_stop,bearPin_tp,"sold",17,0,Red);
Alert("Bearish Pin bar detected on",Symbol(),Period());
// send this
alert message
Sleep(sleeptime);
// then
wait
}
return(0);
}

// exit start

You might also like