//+------------------------------------------------------------------+ //| Mouteki.mq4 | //| | //+------------------------------------------------------------------+ #property copyright "" #property link "" #property indicator_chart_window #property indicator_buffers 6 #property indicator_color1 White /*Original #property indicator_color1 Red. Color of Upper TD Points*/ #property indicator_color2 White /*Original #property indicator_color2 Blue. Color of Lower TD Points*/ #property indicator_color3 Silver #property indicator_color4 Silver //---- input parameters /* Mod 02: only one step, no back steps, only one target, no fractal trendlines, no large arrow option for TD points, and added user changable colours and styles*/ /* Mod 03: Alerts Added. Horizontal Lines indicating where projections start from and where alerts should be determined from re-enabled with Default of False.*/ /* Mod 03B: Bug where TD Points and TD Lines drawn in wrong place for double, triple and quadruple tops or bottoms is fixed*/ extern bool AlertsOn = true; // Line added. Default is true. extern bool SendMailOn = true; // Line added. Default is true. extern bool Comments=true;/*Optional Comments. Default is false. Orginal variable called "Commen"*/ extern bool TrendLine=True;/*Default is true to draw current TD Lines*/ extern int TrendLineStyle=STYLE_SOLID;/*STYLE>_SOLID=0,DASH=1,_DOT=2,_DASHDOT=3,_DASHDDOTDOT=4. Line of code added from original.*/ extern int TrendLineWidth=1;/*Thinnest or allow dots and dashes = 0 or 1, Thinner=2, Medium=3,Thicker=4,Thickest=5. Line of code added from original.*/ extern color UpperTrendLineColour=LimeGreen;/*Line of code added from original.*/ extern color LowerTrendLineColour=Red;/*Line of code added from original.*/ extern bool ProjectionLines=True;/*Default is True. These are the TD Price Projections. Original variable called "Take Prof"*/ extern int ProjectionLinesStyle=STYLE_DOT;/*STYLE>_SOLID=0,DASH=1,_DOT=2,_DASHDOT=3,_DASHDDOTDOT=4. Line of code added from original.*/ extern int ProjectionLinesWidth=1;/*Thinnest or allow dots and dashes = 0 or 1, Thinner=2, Medium=3,Thicker=4,Thickest=5. Line of code added from original.*/ extern color UpperProjectionLineColour=LimeGreen;/*Line of code added from original.*/ extern color LowerProjectionLineColour=Red;/*Line of code added from original.*/ extern bool HorizontLine=true;/*Default is false. It seems the Horizontal Lines are were the code predicts price may cross TD line.*/ bool TD=False;/*Default is false. True setting draws up and down arrows instead of dots on TD Points creating more clutter.*/ extern int BackSteps=0;/*Used to be extern int now just int. Leave at 0*/ extern int ShowingSteps=1;/*Used to be extern int now just int. Leave at 1*/ extern int FractalOfLevel=8;/*Used to be extern bool now just bool. Leave at false, otherwise Trend Lines based on Fractal Points not TD Points*/ double s1[]; double TrendLineBreakUp=-1;//Line added. bool TrendLineBreakUpFlag=False;//Line added. double TrendLineBreakDown=-1;//Line added. bool TrendLineBreakDownFlag=False;//Line added. static double LTP = 0; static double HTP = 0; //---- buffers double ExtMapBuffer1[]; double ExtMapBuffer2[]; double ExtMapBuffer3[]; double ExtMapBuffer4[]; double ExtMapBuffer5[]; double ExtMapBuffer6[]; //==================================================================== int init() { SetIndexStyle(0,DRAW_ARROW); SetIndexArrow(0,217); SetIndexBuffer(0,ExtMapBuffer1); SetIndexEmptyValue(0,0.0); SetIndexStyle(1,DRAW_ARROW); SetIndexArrow(1,218); SetIndexBuffer(1,ExtMapBuffer2); SetIndexEmptyValue(1,0.0); SetIndexStyle(2,DRAW_LINE); SetIndexBuffer(2,ExtMapBuffer3); SetIndexLabel(2,"UTD"); SetIndexStyle(3,DRAW_LINE); SetIndexBuffer(3,ExtMapBuffer4); SetIndexLabel(3,"LTD"); SetIndexStyle(4,DRAW_LINE); SetIndexBuffer(4,ExtMapBuffer5); SetIndexLabel(4,"UTP"); SetIndexStyle(5,DRAW_LINE); SetIndexBuffer(5,ExtMapBuffer6); SetIndexLabel(5,"LTP"); ObjectsDeleteAll(); // for (int i=1;i<=10;i++) // { // ObjectDelete("HHL_"+i);ObjectDelete("HL_"+i); // ObjectDelete("HLL_"+i);ObjectDelete("LL_"+i); // ObjectDelete("HC1_"+i); // ObjectDelete("HC2_"+i); // ObjectDelete("HC3_"+i); // ObjectDelete("LC1_"+i); // ObjectDelete("LC2_"+i); // ObjectDelete("LC3_"+i); // } // Comment(""); return(0); } int deinit() { ObjectsDeleteAll(); // for (int i=1;i<=10;i++) // { // ObjectDelete("HHL_"+i);ObjectDelete("HL_"+i); // ObjectDelete("HLL_"+i);ObjectDelete("LL_"+i); // ObjectDelete("HC1_"+i); // ObjectDelete("HC2_"+i); // ObjectDelete("HC3_"+i); // ObjectDelete("LC1_"+i); // ObjectDelete("LC2_"+i); // ObjectDelete("LC3_"+i); // } // Comment(""); // return(0); } //-------------------------------------------------------------------- int SetTDPoint(int B) { int shift,i; bool failed; for (shift=B;shift>FractalOfLevel-1;shift--) { failed=false; for(i=FractalOfLevel;i>0;i--) { if(High[shift+i]>=High[shift]) failed=true; if(High[shift-i]>=High[shift]) failed=true; } if (!failed) ExtMapBuffer1[shift]=High[shift]; failed=false; for(i=FractalOfLevel;i>0;i--) { if(Low[shift+i]<=Low[shift]) failed=true; if(Low[shift-i]<=Low[shift]) failed=true; } if (!failed) ExtMapBuffer2[shift]=Low[shift]; } for(i=FractalOfLevel-1;i>=0;i--) { ExtMapBuffer1[i]=0; ExtMapBuffer2[i]=0; } return(0); } //-------------------------------------------------------------------- int GetHighTD(int P) { int i=0,j=0; while (j
Bars-2)return(-1);} j++; } return (i); } //-------------------------------------------------------------------- int GetNextHighTD(int P) { int i=P+1; while(ExtMapBuffer1[i]<=High[P]){i++;if(i>Bars-2)return(-1);} return (i); } //-------------------------------------------------------------------- int GetLowTD(int P) { int i=0,j=0; while (j
Bars-2)return(-1);}
j++;
}
return (i);
}
//--------------------------------------------------------------------
int GetNextLowTD(int P)
{
int i=P+1;
while(ExtMapBuffer2[i]>=Low[P] || ExtMapBuffer2[i]==0){i++;if(i>Bars-2)return(-1);}
return (i);
}
//--------------------------------------------------------------------
int TrendLineHighTD(int H1,int H2,int Step,int Col)/*Draw Upper Trend Line*/
{
ObjectSet("HL_"+Step,OBJPROP_TIME1,Time[H2]);ObjectSet("HL_"+Step,OBJPROP_TIME2,Time[H1]);
ObjectSet("HL_"+Step,OBJPROP_PRICE1,High[H2]);ObjectSet("HL_"+Step,OBJPROP_PRICE2,High[H1]);
ObjectSet("HL_"+Step,OBJPROP_COLOR,UpperTrendLineColour);/*TEMP Original OBJPROP_COLOR,Col*/
if (Step==1)ObjectSet("HL_"+Step,OBJPROP_WIDTH,TrendLineWidth);/*Original OBJPROP_WIDTH,2*/
else ObjectSet("HL_"+Step,OBJPROP_WIDTH,1);
return(0);
}
//--------------------------------------------------------------------
int TrendLineLowTD(int L1,int L2,int Step,int Col)/*Draw Lower Trend Line*/
{
ObjectSet("LL_"+Step,OBJPROP_TIME1,Time[L2]);ObjectSet("LL_"+Step,OBJPROP_TIME2,Time[L1]);
ObjectSet("LL_"+Step,OBJPROP_PRICE1,Low[L2]);ObjectSet("LL_"+Step,OBJPROP_PRICE2,Low[L1]);
ObjectSet("LL_"+Step,OBJPROP_COLOR,LowerTrendLineColour);/*TEMP Original OBJPROP_COLOR,Col*/
if (Step==1)ObjectSet("LL_"+Step,OBJPROP_WIDTH,TrendLineWidth);/*Original OBJPROP_WIDTH,2*/
else ObjectSet("LL_"+Step,OBJPROP_WIDTH,1);
return(0);
}
//--------------------------------------------------------------------
int HorizontLineHighTD(int H1,int H2,int Step,double St,int Col)
{
// Print("HHL_1=", High[H2]-(High[H2]-High[H1])/(H2-H1)*H2, "Point=", Digits);
ExtMapBuffer3[0] = NormalizeDouble(High[H2]-(High[H2]-High[H1])/(H2-H1)*H2,Digits);
ObjectSet("HHL_"+Step,OBJPROP_PRICE1,High[H2]-(High[H2]-High[H1])/(H2-H1)*H2);//HORIZONTAL HIGH LINE HEIGHT CALCULATION
ObjectSet("HHL_"+Step,OBJPROP_STYLE,St);
ObjectSet("HHL_"+Step,OBJPROP_COLOR,Col);
ObjectSet("HHL_"+Step,OBJPROP_BACK,True);//Line added
return(0);
}
//--------------------------------------------------------------------
int HorizontLineLowTD(int L1,int L2,int Step,double St,int Col)
{
ObjectSet("HLL_"+Step,OBJPROP_PRICE1,Low[L2]+(Low[L1]-Low[L2])/(L2-L1)*L2);//HORIZONTAL LOW LINE HEIGHT CALCULATION
ExtMapBuffer4[0] = NormalizeDouble(Low[L2]+(Low[L1]-Low[L2])/(L2-L1)*L2,Digits) ;
ObjectSet("HLL_"+Step,OBJPROP_STYLE,St);
ObjectSet("HLL_"+Step,OBJPROP_COLOR,Col);
ObjectSet("HLL_"+Step,OBJPROP_BACK,True);//Line added
return(0);
}
//--------------------------------------------------------------------
string TakeProfitHighTD(int H1,int H2,int Step,int Col)/*Draw Buy TD Price Projection(s)*/
{
int i,ii,j=0;
string Comm="";
double kH,HC1,HC2,HC3,k,St;
kH=(High[H2]-High[H1])/(H2-H1);
while (NormalizeDouble(Point,j)==0)j++;
k=0;
for(i=H1;i>0;i--)if(Close[i]>High[H2]-kH*(H2-i)){k=High[H2]-kH*(H2-i);break;}
if (k>0)
{
Comm=Comm+"UTD_Line ("+DoubleToStr(High[H2]-kH*H2,j)+") broken at "+DoubleToStr(k,j)+", uptargets:\n";
ii=Lowest(NULL,0,MODE_LOW,H2-i,i);
HC1=High[H2]-kH*(H2-ii)-Low[ii];
HC2=High[H2]-kH*(H2-ii)-Close[ii];
ii=Lowest(NULL,0,MODE_CLOSE,H2-i,i);
HC3=High[H2]-kH*(H2-ii)-Close[ii];
St=TrendLineStyle;/*Original STYLE_SOLID*/
}
else
{
k=High[H2]-kH*H2;
Comm=Comm+"UTD_Line ("+DoubleToStr(k,j)+"), probable break-up targets:\n";
ii=Lowest(NULL,0,MODE_LOW,H2,0);
HC1=High[H2]-kH*(H2-ii)-Low[ii];
HTP = HC1;
HC2=High[H2]-kH*(H2-ii)-Close[ii];
ii=Lowest(NULL,0,MODE_CLOSE,H2,0);
HC3=High[H2]-kH*(H2-ii)-Close[ii];
St=TrendLineStyle;/*Original STYLE_DASHDOT*/
}
ObjectSet("HL_"+Step,OBJPROP_STYLE,St);
Comm=Comm+"T1="+DoubleToStr(HC1+k,j)+" ("+DoubleToStr(HC1/Point,0)+"pts.)\n";//changed "pts.)" to "pts.)\n"
//Comm=Comm+" T2="+DoubleToStr(HC2+k,j)+" ("+DoubleToStr(HC2/Point,0)+"pts.)";
//Comm=Comm+" T3="+DoubleToStr(HC3+k,j)+" ("+DoubleToStr(HC3/Point,0)+"pts.)\n";
ObjectSet("HC1_"+Step,OBJPROP_TIME1,Time[H1]);ObjectSet("HC1_"+Step,OBJPROP_TIME2,Time[0]);
ObjectSet("HC1_"+Step,OBJPROP_PRICE1,HC1+k);ObjectSet("HC1_"+Step,OBJPROP_PRICE2,HC1+k);
ExtMapBuffer5[0] = NormalizeDouble(HC1+k,Digits) ;
ObjectSet("HC1_"+Step,OBJPROP_COLOR,Col);ObjectSet("HC1_"+Step,OBJPROP_STYLE,St);
//ObjectSet("HC2_"+Step,OBJPROP_TIME1,Time[H1]);ObjectSet("HC2_"+Step,OBJPROP_TIME2,Time[0]);
//ObjectSet("HC2_"+Step,OBJPROP_PRICE1,HC2+k);ObjectSet("HC2_"+Step,OBJPROP_PRICE2,HC2+k);
//ObjectSet("HC2_"+Step,OBJPROP_COLOR,Col);ObjectSet("HC2_"+Step,OBJPROP_STYLE,St);
//ObjectSet("HC3_"+Step,OBJPROP_TIME1,Time[H1]);ObjectSet("HC3_"+Step,OBJPROP_TIME2,Time[0]);
//ObjectSet("HC3_"+Step,OBJPROP_PRICE1,HC3+k);ObjectSet("HC3_"+Step,OBJPROP_PRICE2,HC3+k);
//ObjectSet("HC3_"+Step,OBJPROP_COLOR,Col);ObjectSet("HC3_"+Step,OBJPROP_STYLE,St);
if (Step==1)
{
ObjectSet("HC1_"+Step,OBJPROP_WIDTH,ProjectionLinesWidth);/*Original OBJPROP_WIDTH,2*/
ObjectSet("HC1_"+Step,OBJPROP_STYLE,ProjectionLinesStyle);/*This Line of code added from original. TD Upper Projection Line Style*/
// ObjectSet("HC2_"+Step,OBJPROP_WIDTH,2);
// ObjectSet("HC3_"+Step,OBJPROP_WIDTH,2);
}
else
{
ObjectSet("HC1_"+Step,OBJPROP_WIDTH,2);
// ObjectSet("HC2_"+Step,OBJPROP_WIDTH,2);
// ObjectSet("HC3_"+Step,OBJPROP_WIDTH,2);
}
return(Comm);
}
//--------------------------------------------------------------------
string TakeProfitLowTD(int L1,int L2,int Step,int Col)/*Draw Sell TD Price Projection(s)*/
{
int i,ii,j=0;
string Comm="";
double kL,LC1,LC2,LC3,k,St;
kL=(Low[L1]-Low[L2])/(L2-L1);
while (NormalizeDouble(Point,j)==0)j++;
k=0;
for(i=L1;i>0;i--)if(Close[i]