123PatternsV6

If you need an Indicator or Signal developed or translated from other language, please post all Indicator development REQUESTS to this section here.

Moderator: admin

123PatternsV6

Postby sinbad » Fri Dec 02, 2011 12:56 pm

If you could please convert this to lua. Thanks.
_________________________________________________________________________________

//+-----------------------------------------------------------+
//| MT4 CUSTOM INDICATOR 123PatternsV6.MQ4 |
//| copy to [experts\\indicators] and recompile or restart MT4 |
//+-----------------------------------------------------------+
//| Free software for personal non-commercial use only. |
//| No guarantees are expressed or implied. |
//| Feedback welcome via Forex Factory private message. |
//+-----------------------------------------------------------+
#property copyright "Copyright © 2010 Robert Dee"
#property link "www.forexfactory.com/robdee"

#define INDICATOR_VERSION 20101105 // VERSION 6
#define INDICATOR_NAME "123PatternsV6"
#define RELEASE_LEVEL "Public"
#define MT4_BUILD 226

#property indicator_chart_window
#property indicator_buffers 8
#property indicator_color1 DodgerBlue // UpperLine
#property indicator_color2 OrangeRed // LowerLine
#property indicator_color3 LimeGreen // Target1
#property indicator_color4 LimeGreen // Target2
#property indicator_color5 DodgerBlue // BuyArrow
#property indicator_color6 OrangeRed // SellArrow
#property indicator_color7 DodgerBlue // BullDot
#property indicator_color8 OrangeRed // BearDot
#property indicator_width1 1
#property indicator_width2 1
#property indicator_width3 1
#property indicator_width4 1
#property indicator_width5 3 // BuyArrow
#property indicator_width6 3 // SellArrow
#property indicator_width7 3 // BullDot
#property indicator_width8 3 // BearDot

extern string Notes = "15pip RangeBars Basic Setup";
extern int ZigZagDepth = 1;
extern double RetraceDepthMin = 0.4;
extern double RetraceDepthMax = 1.0;
extern bool ShowAllLines = True;
extern bool ShowAllBreaks = True;
extern bool ShowTargets = False;
extern double Target1Multiply = 1.5;
extern double Target2Multiply = 3.0;
extern bool HideTransitions = True;

// indicator buffers
double UpperLine[];
double LowerLine[];
double Target1[];
double Target2[];
double BuyArrow[];
double SellArrow[];
double BullDot[];
double BearDot[];

double firsthigh, firstlow, lasthigh, lastlow, prevhigh, prevlow, signalprice, brokenline;
datetime firsthightime, firstlowtime, lasthightime, lastlowtime, prevhightime, prevlowtime, signaltime;
datetime redrawtime; // remember when the indicator was redrawn

int signal;
#define NOSIG 0
#define BUYSIG 1
#define SELLSIG 2

//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
int i;
for(i=0; i<=7; i++) SetIndexEmptyValue(i,EMPTY_VALUE);
if(ShowAllLines == True) SetIndexStyle(0,DRAW_LINE); else SetIndexStyle(0,DRAW_NONE);
if(ShowAllLines == True) SetIndexStyle(1,DRAW_LINE); else SetIndexStyle(1,DRAW_NONE);
if(ShowTargets == True) SetIndexStyle(2,DRAW_LINE); else SetIndexStyle(2,DRAW_NONE);
if(ShowTargets == True) SetIndexStyle(3,DRAW_LINE); else SetIndexStyle(3,DRAW_NONE);
SetIndexStyle(4,DRAW_ARROW); SetIndexArrow(4,SYMBOL_ARROWUP);
SetIndexStyle(5,DRAW_ARROW); SetIndexArrow(5,SYMBOL_ARROWDOWN);
SetIndexStyle(6,DRAW_ARROW); SetIndexArrow(6,159); // BullDot (WingDings character)
SetIndexStyle(7,DRAW_ARROW); SetIndexArrow(7,159); // BearDot (WingDings character)
SetIndexBuffer(0,UpperLine);
SetIndexBuffer(1,LowerLine);
SetIndexBuffer(2,Target1);
SetIndexBuffer(3,Target2);
SetIndexBuffer(4,BuyArrow);
SetIndexBuffer(5,SellArrow);
SetIndexBuffer(6,BullDot);
SetIndexBuffer(7,BearDot);
IndicatorShortName(INDICATOR_NAME);
IndicatorDigits(Digits);
if(ShowAllLines == True) SetIndexLabel(0,"UpperLine"); else SetIndexLabel(0,"");
if(ShowAllLines == True) SetIndexLabel(1,"LowerLine"); else SetIndexLabel(1,"");
if(ShowTargets == True) SetIndexLabel(2,"Target1"); else SetIndexLabel(2,"");
if(ShowTargets == True) SetIndexLabel(3,"Target2"); else SetIndexLabel(3,"");
SetIndexLabel(4,"BuyArrow");
SetIndexLabel(5,"SellArrow");
SetIndexLabel(6,"");
SetIndexLabel(7,"");
// cleanup display buffers
for(i=0; i<Bars; i++)
{
UpperLine[i] = EMPTY_VALUE;
LowerLine[i] = EMPTY_VALUE;
Target1[i] = EMPTY_VALUE;
Target2[i] = EMPTY_VALUE;
BuyArrow[i] = EMPTY_VALUE;
SellArrow[i] = EMPTY_VALUE;
BullDot[i] = EMPTY_VALUE;
BearDot[i] = EMPTY_VALUE;
}
// message to the experts log (shows in reverse order)
if(IsTesting() == False)
{
Print("Copyright © 2010 Robert Dee, All Rights Reserved");
Print("Free software for personal non-commercial use only. No guarantees are expressed or implied.");
Print(INDICATOR_NAME+" indicator version "+INDICATOR_VERSION+" for "+RELEASE_LEVEL+" release, compiled with MetaTrader4 Build "+MT4_BUILD);
}
} // end of init()

//+------------------------------------------------------------------+
//| Status Message prints below OHLC upper left of chart window
//+------------------------------------------------------------------+
void StatusMessage()
{
if(IsTesting() == True) return; // do no more
double multi = MathPow(10,Digits);
string msg = INDICATOR_NAME+" "+TimeToStr(TimeCurrent(),TIME_MINUTES)+" ";
if(signal == NOSIG) msg = msg + "NOSIG ";
if(signal == BUYSIG) msg = msg + "BUYSIG "+ TimeToStr(signaltime,TIME_MINUTES)+" "+DoubleToStr(signalprice,Digits)+" ";
if(signal == SELLSIG) msg = msg + "SELLSIG "+ TimeToStr(signaltime,TIME_MINUTES)+" "+DoubleToStr(signalprice,Digits)+" ";
msg = msg + "ZigZagDepth="+ZigZagDepth+" ";
//msg = msg + "RetraceDepth="+DoubleToStr(RetraceDepthMin,2)+" "+DoubleToStr(RetraceDepthMax,2)+" ";
//msg = msg + "Target1="+DoubleToStr(Target1Multiply,2)+" ";
//msg = msg + "Target2="+DoubleToStr(Target2Multiply,2)+" ";
msg = msg + "Spread="+DoubleToStr((Ask-Bid)*multi,0)+" ";
msg = msg + "Range="+DoubleToStr((High[0]-Low[0])*multi,0)+" ";
Comment(msg);
}

//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
// REDRAW ONLY ONE TIME PER CANDLE
if(redrawtime == Time[0]) {StatusMessage(); return(0);} // if already redrawn on this candle then do no more
else redrawtime = Time[0]; // remember when the indicator was redrawn

double zigzag, range, retracedepth, one, two, three;
datetime onetime, twotime, threetime;
int shift = Bars-1;
while(shift >= 0)
{
// UPPERLINES and LOWERLINES based on ZIGZAG
UpperLine[shift] = UpperLine[shift+1];
LowerLine[shift] = LowerLine[shift+1];
Target1[shift] = Target1[shift+1];
Target2[shift] = Target2[shift+1];
//BuyArrow[shift] = EMPTY_VALUE;
//SellArrow[shift] = EMPTY_VALUE;
BullDot[shift] = EMPTY_VALUE;
BearDot[shift] = EMPTY_VALUE;
zigzag = iCustom(NULL,0,"ZigZag",ZigZagDepth,5,3,0,shift);
if(zigzag == High[shift])
{
UpperLine[shift] = High[shift];
firsthigh = prevhigh; firsthightime = prevhightime;
prevhigh = lasthigh; prevhightime = lasthightime;
lasthigh = zigzag; lasthightime = Time[shift];
}
if(zigzag == Low[shift])
{
LowerLine[shift] = Low[shift];
firstlow = prevlow; firstlowtime = prevlowtime;
prevlow = lastlow; prevlowtime = lastlowtime;
lastlow = zigzag; lastlowtime = Time[shift];
}

///////////////////////////
// BULLISH BREAK ABOVE #2
one = prevlow; onetime = prevlowtime;
two = lasthigh; twotime = lasthightime; if(twotime == Time[shift]){two = prevhigh; twotime = prevhightime;}
three = lastlow; threetime = lastlowtime;
if(one - two != 0) retracedepth = (three - two) / (one - two); // retrace depth
// signal rules
if(shift > 0)
if(retracedepth > RetraceDepthMin) // minimum retrace depth for 123 pattern
if(retracedepth < RetraceDepthMax) // maximum retrace depth for 123 pattern
if(brokenline != UpperLine[shift]) // if this line has not already been broken
if(Low[shift] < UpperLine[shift]) // low of rangebar is below the line
if(Close[shift] > UpperLine[shift]) // close of rangebar body is above the line (break)
{
range = MathAbs(two - three); // range is the distance between two and three
Target1[shift] = two+(range*Target1Multiply);
Target2[shift] = two+(range*Target2Multiply);
BuyArrow[shift] = Low[shift]-(High[shift]-Low[shift])/3;
BullDot[iBarShift(NULL,0,onetime)] = one; // ONE
BullDot[iBarShift(NULL,0,twotime)] = two; // TWO
BullDot[iBarShift(NULL,0,threetime)] = three; // THREE
signal = BUYSIG;
signaltime = Time[shift];
signalprice = BuyArrow[shift];
brokenline = UpperLine[shift];
}

/////////////////////////////////////////////
// BULLISH BREAK OF UPPERLINE (NOT 123 SETUP)
// signal rules
if(shift > 0)
if(ShowAllBreaks == True)
if(brokenline != UpperLine[shift]) // if this line has not already been broken
if(Low[shift] < UpperLine[shift]) // low of rangebar is below the line
if(Close[shift] > UpperLine[shift]) // close of rangebar body is above the line (break)
{
range = UpperLine[shift]-LowerLine[shift];
Target1[shift] = UpperLine[shift]+(range*Target1Multiply);
Target2[shift] = UpperLine[shift]+(range*Target2Multiply);
BuyArrow[shift] = Low[shift]-(High[shift]-Low[shift])/3;
signal = BUYSIG;
signaltime = Time[shift];
signalprice = BuyArrow[shift];
brokenline = UpperLine[shift];
}

///////////////////////////
// BEARISH BREAK BELOW #2
one = prevhigh; onetime = prevhightime;
two = lastlow; twotime = lastlowtime; if(twotime == Time[shift]){two = prevlow; twotime = prevlowtime;}
three = lasthigh; threetime = lasthightime;
if(one - two != 0) retracedepth = (three - two) / (one - two); // retrace depth
// signal rules
if(shift > 0)
if(retracedepth > RetraceDepthMin) // minimum retrace depth for 123 pattern
if(retracedepth < RetraceDepthMax) // maximum retrace depth for 123 pattern
if(brokenline != LowerLine[shift]) // if this line has not already been broken
if(High[shift] > LowerLine[shift]) // high of rangebar is above the line
if(Close[shift] < LowerLine[shift]) // close of rangebar is below the line (break)
{
range = MathAbs(two - three); // range is the distance between two and three
Target1[shift] = two-(range*Target1Multiply);
Target2[shift] = two-(range*Target2Multiply);
SellArrow[shift] = High[shift]+(High[shift]-Low[shift])/3;
BearDot[iBarShift(NULL,0,onetime)] = one; // ONE
BearDot[iBarShift(NULL,0,twotime)] = two; // TWO
BearDot[iBarShift(NULL,0,threetime)] = three; // THREE
signal = SELLSIG;
signaltime = Time[shift];
signalprice = SellArrow[shift];
brokenline = LowerLine[shift];
}

/////////////////////////////////////////////
// BEARISH BREAK OF LOWERLINE (NOT 123 SETUP)
// signal rules
if(shift > 0)
if(ShowAllBreaks == True)
if(brokenline != LowerLine[shift]) // if this line has not already been broken
if(High[shift] > LowerLine[shift]) // high of rangebar is above the line
if(Close[shift] < LowerLine[shift]) // close of rangebar is below the line (break)
{
range = UpperLine[shift]-LowerLine[shift];
Target1[shift] = LowerLine[shift]-(range*Target1Multiply);
Target2[shift] = LowerLine[shift]-(range*Target2Multiply);
SellArrow[shift] = High[shift]+(High[shift]-Low[shift])/3;
signal = SELLSIG;
signaltime = Time[shift];
signalprice = SellArrow[shift];
brokenline = LowerLine[shift];
}

// TARGET LINE RULES
if(signal == BUYSIG)
{
if(Low[shift] > Target1[shift]) Target1[shift] = EMPTY_VALUE;
if(Low[shift] > Target2[shift]) Target2[shift] = EMPTY_VALUE;
}
if(signal == SELLSIG)
{
if(High[shift] < Target1[shift]) Target1[shift] = EMPTY_VALUE;
if(High[shift] < Target2[shift]) Target2[shift] = EMPTY_VALUE;
}

// HIDE LINE TRANSITIONS
if(HideTransitions == True)
{
if(UpperLine[shift] != UpperLine[shift+1]) UpperLine[shift+1] = EMPTY_VALUE;
if(LowerLine[shift] != LowerLine[shift+1]) LowerLine[shift+1] = EMPTY_VALUE;
if(Target1[shift] != Target1[shift+1]) Target1[shift+1] = EMPTY_VALUE;
if(Target2[shift] != Target2[shift+1]) Target2[shift+1] = EMPTY_VALUE;
}

shift--; // move ahead one candle
}

// update the status display
StatusMessage();
}// end of start()

//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
// cleanup display buffers
for(int i=0; i<Bars; i++)
{
UpperLine[i] = EMPTY_VALUE;
LowerLine[i] = EMPTY_VALUE;
Target1[i] = EMPTY_VALUE;
Target2[i] = EMPTY_VALUE;
BuyArrow[i] = EMPTY_VALUE;
SellArrow[i] = EMPTY_VALUE;
BullDot[i] = EMPTY_VALUE;
BearDot[i] = EMPTY_VALUE;
}
Comment("");
}// end of deinit()
Attachments
123PatternsV6.mq4
(13.56 KiB) Downloaded 720 times
123PatternsV6.ex4
(12.1 KiB) Downloaded 561 times
sinbad
 
Posts: 7
Joined: Tue Aug 10, 2010 2:08 pm

Re: 123PatternsV6

Postby Apprentice » Fri Dec 02, 2011 6:27 pm

Your request is added to the developmental cue.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 19198
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: 123PatternsV6

Postby biggiesmalls » Wed Dec 07, 2011 10:04 am

I've been using this indicator on MT4 and it's phenomenal. With the right filter and trading with the trend, I average about 45-70 pips a day. Please, focus on this indicator, I hate having to run Marketscope and Metatrader side-by-side.
biggiesmalls
 
Posts: 39
Joined: Mon Aug 22, 2011 7:08 am

Re: 123PatternsV6

Postby biggiesmalls » Mon Dec 12, 2011 11:41 am

Hey guys, wondering what the status of this indicator is at now. Thanks for the hard work guys.
biggiesmalls
 
Posts: 39
Joined: Mon Aug 22, 2011 7:08 am

Re: 123PatternsV6

Postby Blackcat2 » Mon Dec 12, 2011 11:20 pm

When the indicator is completed, would you be so kind to explain how to use it properly? The rules, Entry/Exit signal, etc...

Thanks..
BC
Blackcat2
FXCodeBase: Initiate
 
Posts: 118
Joined: Wed May 19, 2010 12:42 am

Re: 123PatternsV6

Postby Alexander.Gettinger » Mon Dec 26, 2011 6:20 am

This indicator you may find here: viewtopic.php?f=17&t=10444
Alexander.Gettinger
FXCodeBase: Confirmed User
 
Posts: 3306
Joined: Wed Mar 31, 2010 9:40 pm
Location: Russia, Omsk

Re: 123PatternsV6

Postby t1982t » Tue Dec 27, 2011 8:25 pm

How does it work?
t1982t
 
Posts: 44
Joined: Sat Jun 25, 2011 10:36 am

Re: 123PatternsV6

Postby ntseles » Tue Jan 03, 2012 12:10 am

t1982t wrote:How does it work?


+1

Anyone???
ntseles
 
Posts: 1
Joined: Tue Jan 03, 2012 12:08 am

Re: 123PatternsV6

Postby porschefan » Tue Jan 03, 2012 8:56 am

?
porschefan
 
Posts: 5
Joined: Tue Aug 02, 2011 2:12 pm

Re: 123PatternsV6

Postby Barnestormer » Tue Jan 03, 2012 7:40 pm

I found this in another forum by searching 123PatternsV6. With all the inner links embedded here, this is a rather in-depth question it appears.

At this early stage of the thread I am describing the basic ideas that went into the indicator when we were developing it a year ago. These concepts should appear in most any discussion of 123 patterns. Different authors will use different terms to describe what is essentially the same price behaviour and the same analysis. This can be confusing.

What I have been trying to do is use clear and consistent terms that then provide a foundation for our further discussion. If you use the same terms that I do then confusion (in this thread) will be avoided.

Summary of Terms
Terms used in the first four main posts are underlined below.

Using Zigzag only post #5
123 patterns are an important feature of price action
Looking back in time you will always see three previous price points
Zigzag draws our attention to the most important price points
Charts with Zigzag alone provide a lot of information
Two categories of patterns, ideal and distorted
Basic Setup post #7
basic setup highlights ideal patterns only, not distorted patterns
add 123PatternsV6 on top of Zigzag with matching depths
turn off ShowAllLines ShowAllBreaks and ShowTargets
red dots and arrows for bearish patterns
blue dots and arrows for bullish patterns
When are 123 patterns useful? post #14
123 patterns are not always useful
123 patterns are useful in some situations
an important goal of this thread is to understand what makes the difference between successful and failed 123-break patterns
Basic Setup Sell Zones post #17
Following a bearish 123-break pattern a decision is required about a time and a price for selling
An aggressive decision sells immediately after a break (no wait)
A conservative decision waits for price to retrace up into a sell zone
Consistent sell zone pricing is provided by the red arrow
Sell zones are interesting because they are remembered by both bears and bulls as old battle lines
Sell zones are useful because they offer buying volume to fill limit orders
Sell zones are not an exact price line, they are a small range of prices roughly 10 pips high
OK, that is all I can think of this morning. Have I missed anything?

Now is a good time for feedback and questions on these terms and concepts before we carry on.

Robdee
Barnestormer
 
Posts: 1
Joined: Mon Jan 02, 2012 8:13 am

Next

Return to Indicator and Signal Requests

Who is online

Users browsing this forum: Bing [Bot] and 6 guests