_TRO_GAUGE_LINREG

Author: Copyright � 2007, Avery T. Horton, Jr. aka TheRumpledOne
_TRO_GAUGE_LINREG
Orders Execution
Checks for the total of open orders
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
_TRO_GAUGE_LINREG
//+------------------------------------------------------------------+
//|                       _TRO_GAUGE_LINREG                          |
//|                                                                  | 
//|   Copyright © 2007, Avery T. Horton, Jr. aka TheRumpledOne       |
//|                                                                  |
//|   PO BOX 43575, TUCSON, AZ 85733                                 |
//|                                                                  |
//|   GIFT AND DONATIONS ACCEPTED                                    | 
//|                                                                  |  
//|    http://docs.mql4.com/constants/wingdings                      |                                         |
//+------------------------------------------------------------------+

#property copyright "Copyright © 2007, Avery T. Horton, Jr. aka TheRumpledOne"
#property link      "therumpledone@gmail.com"

#property indicator_chart_window 
#property indicator_buffers 7

#property indicator_color1 White 
#property indicator_color2 Lime
#property indicator_color3 MediumTurquoise 
#property indicator_color4 Red
#property indicator_color5 Yellow
#property indicator_color6 Orange
#property indicator_color7 OrangeRed

//---- For the small screens
//extern string    Display_infos         = "=== If true, displayed on the chart ===";
//extern bool      display_on_chart      =  true ;  // If true, the open trade analysis, daily pivots and daily range will be displayed on the chart window

// indicators parameters

extern bool iPlotChart = true ;
extern bool iPlotGauge = true ;

extern string myInd1    = "Moving Averages" ;
extern int    myParm1_1 = 13 ;
extern int    myParm1_2 = 0 ;
extern int    myParm1_3 = 0 ;

extern int myPeriod  = 1440 ;
extern int myOffset  = 1 ; 
extern int myChartY = 1 ;

extern int myStyle1  = 2 ;
extern int myStyle2  = 2 ;
extern int myStyle3  = 2 ;
extern int myStyle4  = 2 ;
extern int myStyle5  = 2 ;
extern int myStyle6  = 2 ;
extern int myStyle7  = 2 ;

extern int myWingDing1  = 115 ;
extern int myWingDing2  = 115 ;
extern int myWingDing3  = 115 ;
extern int myWingDing4  = 115 ;
extern int myWingDing5  = 115 ;
extern int myWingDing6  = 115 ;
extern int myWingDing7  = 115 ;

extern color myColor1 =White ;
extern color myColor2 =Lime;
extern color myColor3 =MediumTurquoise ;
extern color myColor4 =Red;
extern color myColor5 =Yellow;
extern color myColor6 =Orange;
extern color myColor7 =OrangeRed;

//---- buffers

double P1Buffer[];
double P2Buffer[];
double P3Buffer[];
double P4Buffer[];
double P5Buffer[];
double P6Buffer[];
double P7Buffer[];


//int myPeriod = PERIOD_D1;

int TimeZone=0;
bool pivots = true;
bool alert = true;

double yesterday_high=0;
double yesterday_open=0;
double yesterday_low=0;
double yesterday_close=0;
double today_open=0;
double today_high=0;
double today_low=0;


double rates_h1[2][6];
double rates_d1[2][6];

double Q,H,L,F;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- name for indicator window

   string short_name=" ";
   IndicatorShortName(short_name);
   SetIndexBuffer(0, P1Buffer);
   SetIndexBuffer(1, P2Buffer);
   SetIndexBuffer(2, P3Buffer);
   SetIndexBuffer(3, P4Buffer);
   SetIndexBuffer(4, P5Buffer);
   SetIndexBuffer(5, P6Buffer);
   SetIndexBuffer(6, P7Buffer);
//----

SetIndexArrow(0, myWingDing1); 
SetIndexArrow(1, myWingDing2); 
SetIndexArrow(2, myWingDing3); 
SetIndexArrow(3, myWingDing4); 
SetIndexArrow(4, myWingDing5); 
SetIndexArrow(5, myWingDing6); 
SetIndexArrow(6, myWingDing7); 
 


   SetIndexStyle(0, DRAW_ARROW, myStyle1, 1);
   SetIndexStyle(1, DRAW_ARROW, myStyle2, 1);   
   SetIndexStyle(2, DRAW_ARROW, myStyle3, 1);
   SetIndexStyle(3, DRAW_ARROW, myStyle4, 1);
   SetIndexStyle(4, DRAW_ARROW, myStyle5, 1);
   SetIndexStyle(5, DRAW_ARROW, myStyle6, 1);
   SetIndexStyle(6, DRAW_ARROW, myStyle7, 1);   
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
   
   ObjectDelete("LR");
   ObjectDelete("line5LR");
   ObjectDelete("X01_LabelLR");
   ObjectDelete("X01_ValueLR");
   ObjectDelete("X02_LabelLR");
   ObjectDelete("X02_ValueLR");
   ObjectDelete("X03_LabelLR");
   ObjectDelete("X03_ValueLR");
   ObjectDelete("X04_LabelLR");
   ObjectDelete("X04_ValueLR");
   ObjectDelete("X05_LabelLR");
   ObjectDelete("X05_ValueLR");
   ObjectDelete("X06_LabelLR");
   ObjectDelete("X06_ValueLR");
   ObjectDelete("X07_LabelLR");
   ObjectDelete("X07_ValueLR");

   
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {

  int j,total=OrdersTotal();
   for(j=0;j<total;j++)
   {
    OrderSelect(j, SELECT_BY_POS, MODE_TRADES);
   }
   
   color color_common_line = White;
   color color_common_text = White;
   color color_ind = PowderBlue;
   color color_indic;
   color color_pivots_1=Orchid;
   double x;
  
   int i, dayi, counted_bars = IndicatorCounted();
//---- check for possible errors
   if(counted_bars < 0) 
       return(-1);
//---- last counted bar will be recounted
   if(counted_bars > 0) 
       counted_bars--;  
   int limit = Bars - counted_bars;
//----   
   for(i = limit - 1; i >= 0; i--)
     {
     
     int sPeriod = Period();

     if (myPeriod != NULL){ sPeriod= myPeriod ;}

     string CustomTrend = "_LinReg" ;
			
	
	double X01 = iCustom(NULL,1,CustomTrend, 60 ,0,0 );
   double X02 = iCustom(NULL,1,CustomTrend, 60 ,0,59 );
   double X03 = iCustom(NULL,1,CustomTrend, 60 ,0,2 );
   double X04 = iCustom(NULL,60,CustomTrend, 60 ,0,0 );	
   double X05 = iCustom(NULL,240,CustomTrend, 60 ,0,0 );	
   double X06 = iCustom(NULL,1440,CustomTrend, 60 ,0,0 );
	double X07 = iCustom(NULL,PERIOD_W1,CustomTrend, 60 ,0,0 );
 

if ( iPlotChart ) { 
	
	P1Buffer[i] = X01 ;
	P2Buffer[i] = X02 ;
   P3Buffer[i] = X03 ;
	P4Buffer[i] = X04 ;
	P5Buffer[i] = X05 ;
   P6Buffer[i] = X06 ;
   P7Buffer[i] = X07 ;
   
} // iPlotChart

    } // FOR 

if ( iPlotGauge ) {  
    
string StrX01 = "LR M1    " ; 
string StrX02 = "-XO2" ; 
string StrX03 = "-XO3" ; 
string StrX04 = "-XO4" ; 
string StrX05 = "-XO5" ; 
string StrX06 = "-XO6" ; 
string StrX07 = "-XO7" ; 
             
   color color_X01=Red;
   color color_X02=Red;
   color color_X03=Red;
   color color_X04=Red;
   color color_X05=Red;
   color color_X06=Red;
   color color_X07=Red;  
   	
	if( Close[0] < X01) { color_X01=Lime; } 
	if( Close[0] < X02) { color_X02=Lime; } 	
	if( Close[0] < X03) { color_X03=Lime; } 
	if( Close[0] < X04) { color_X04=Lime; } 
	if( Close[0] < X05) { color_X05=Lime; } 
	if( Close[0] < X06) { color_X06=Lime; }		
	if( Close[0] < X07) { color_X07=Lime; }	
		
	int Precision, dig;	

   if( StringFind( Symbol(), "JPY", 0) != -1 ) { Precision = 100; dig = 2;}
   else                                        { Precision = 10000; dig = 4; }


       	
//---- Set labels

   int WindowToUse;
   int Corner_line, Xdist_line;
   int Corner_text, Corner_ValueLR, Xdist_text, Xdist_ValueLR;
   int Ydist_line5;
   int Corner_pivots, Xdist_pivots, Ydist_pivots;
   int Ydist_X01, Ydist_X02, Ydist_X03, Ydist_X04, Ydist_X05, Ydist_X06, Ydist_X07;
   int YdistInc ;
   
    WindowToUse =  0;
    Corner_line = 1;
    Corner_text = 1; 
    Corner_ValueLR = 1;
    Xdist_line = 21; 
    Xdist_text = 93; 
    Xdist_ValueLR = 23;
    Corner_pivots = 1; 
    Xdist_pivots = 21; 
    
    Ydist_pivots = myChartY;  
    Ydist_line5 = 
    Ydist_pivots + 11; 
    YdistInc = 15 ;
    Ydist_X01 = Ydist_pivots + 25; 
    Ydist_X02 = Ydist_X01 + YdistInc; 
    Ydist_X03 = Ydist_X01 + YdistInc*2; 
    Ydist_X04 = Ydist_X01 + YdistInc*3; 
    Ydist_X05 = Ydist_X01 + YdistInc*4; 
    Ydist_X06 = Ydist_X01 + YdistInc*5; 
    Ydist_X07 = Ydist_X01 + YdistInc*6;

   ObjectCreate("LR", OBJ_LABEL, WindowToUse, 0, 0);
   ObjectSetText("LR",sPeriod + " LR ",9, "Verdana", color_pivots_1);
   ObjectSet("LR", OBJPROP_CORNER, Corner_pivots);
   ObjectSet("LR", OBJPROP_XDISTANCE, Xdist_pivots);
   ObjectSet("LR", OBJPROP_YDISTANCE, Ydist_pivots);
   
   ObjectCreate("line5LR", OBJ_LABEL, WindowToUse, 0, 0);
   ObjectSetText("line5LR","---------------------",7, "Verdana", color_pivots_1);
   ObjectSet("line5LR", OBJPROP_CORNER, Corner_line);
   ObjectSet("line5LR", OBJPROP_XDISTANCE, Xdist_line);
   ObjectSet("line5LR", OBJPROP_YDISTANCE, Ydist_line5);
   
   ObjectCreate("X01_LabelLR", OBJ_LABEL, WindowToUse, 0, 0);
   ObjectSetText("X01_LabelLR",StrX01,9, "Verdana", myColor1);
   ObjectSet("X01_LabelLR", OBJPROP_CORNER, Corner_text);
   ObjectSet("X01_LabelLR", OBJPROP_XDISTANCE, Xdist_text);
   ObjectSet("X01_LabelLR", OBJPROP_YDISTANCE, Ydist_X01);
   
   ObjectCreate("X01_ValueLR", OBJ_LABEL, WindowToUse, 0, 0);
   ObjectSetText("X01_ValueLR"," "+DoubleToStr(X01,dig),9, "Verdana", color_X01);
   ObjectSet("X01_ValueLR", OBJPROP_CORNER, Corner_ValueLR);
   ObjectSet("X01_ValueLR", OBJPROP_XDISTANCE, Xdist_ValueLR);
   ObjectSet("X01_ValueLR", OBJPROP_YDISTANCE, Ydist_X01);
   
   ObjectCreate("X02_LabelLR", OBJ_LABEL, WindowToUse, 0, 0);
   ObjectSetText("X02_LabelLR",StrX02,9, "Verdana", myColor2);
   ObjectSet("X02_LabelLR", OBJPROP_CORNER, Corner_text);
   ObjectSet("X02_LabelLR", OBJPROP_XDISTANCE, Xdist_text);
   ObjectSet("X02_LabelLR", OBJPROP_YDISTANCE, Ydist_X02);
   
   ObjectCreate("X02_ValueLR", OBJ_LABEL, WindowToUse, 0, 0);
   ObjectSetText("X02_ValueLR"," "+DoubleToStr(X02,dig),9, "Verdana", color_X03);
   ObjectSet("X02_ValueLR", OBJPROP_CORNER, Corner_ValueLR);
   ObjectSet("X02_ValueLR", OBJPROP_XDISTANCE, Xdist_ValueLR);
   ObjectSet("X02_ValueLR", OBJPROP_YDISTANCE, Ydist_X02);
 
   ObjectCreate("X03_LabelLR", OBJ_LABEL, WindowToUse, 0, 0);
   ObjectSetText("X03_LabelLR",StrX03,9, "Verdana", myColor3 );
   ObjectSet("X03_LabelLR", OBJPROP_CORNER, Corner_text);
   ObjectSet("X03_LabelLR", OBJPROP_XDISTANCE, Xdist_text);
   ObjectSet("X03_LabelLR", OBJPROP_YDISTANCE, Ydist_X03);
   
   ObjectCreate("X03_ValueLR", OBJ_LABEL, WindowToUse, 0, 0);
   ObjectSetText("X03_ValueLR"," "+DoubleToStr(X03,dig),9, "Verdana", color_X03);
   ObjectSet("X03_ValueLR", OBJPROP_CORNER, Corner_ValueLR);
   ObjectSet("X03_ValueLR", OBJPROP_XDISTANCE, Xdist_ValueLR);
   ObjectSet("X03_ValueLR", OBJPROP_YDISTANCE, Ydist_X03);

   ObjectCreate("X04_LabelLR", OBJ_LABEL, WindowToUse, 0, 0);
   ObjectSetText("X04_LabelLR",StrX04,9, "Verdana", myColor4 );
   ObjectSet("X04_LabelLR", OBJPROP_CORNER, Corner_text);
   ObjectSet("X04_LabelLR", OBJPROP_XDISTANCE, Xdist_text);
   ObjectSet("X04_LabelLR", OBJPROP_YDISTANCE, Ydist_X04);
   
   ObjectCreate("X04_ValueLR", OBJ_LABEL, WindowToUse, 0, 0);
   ObjectSetText("X04_ValueLR"," "+DoubleToStr(X04,dig),9, "Verdana", color_X04);
   ObjectSet("X04_ValueLR", OBJPROP_CORNER, Corner_ValueLR);
   ObjectSet("X04_ValueLR", OBJPROP_XDISTANCE, Xdist_ValueLR);
   ObjectSet("X04_ValueLR", OBJPROP_YDISTANCE, Ydist_X04);

   ObjectCreate("X05_LabelLR", OBJ_LABEL, WindowToUse, 0, 0);
   ObjectSetText("X05_LabelLR",StrX05,9, "Verdana", myColor5 );
   ObjectSet("X05_LabelLR", OBJPROP_CORNER, Corner_text);
   ObjectSet("X05_LabelLR", OBJPROP_XDISTANCE, Xdist_text);
   ObjectSet("X05_LabelLR", OBJPROP_YDISTANCE, Ydist_X05);
   
   ObjectCreate("X05_ValueLR", OBJ_LABEL, WindowToUse, 0, 0);
   ObjectSetText("X05_ValueLR"," "+DoubleToStr(X05,dig),9, "Verdana", color_X05);
   ObjectSet("X05_ValueLR", OBJPROP_CORNER, Corner_ValueLR);
   ObjectSet("X05_ValueLR", OBJPROP_XDISTANCE, Xdist_ValueLR);
   ObjectSet("X05_ValueLR", OBJPROP_YDISTANCE, Ydist_X05);
    
   ObjectCreate("X06_LabelLR", OBJ_LABEL, WindowToUse, 0, 0);
   ObjectSetText("X06_LabelLR",StrX06,9, "Verdana", myColor6 );
   ObjectSet("X06_LabelLR", OBJPROP_CORNER, Corner_text);
   ObjectSet("X06_LabelLR", OBJPROP_XDISTANCE, Xdist_text);
   ObjectSet("X06_LabelLR", OBJPROP_YDISTANCE, Ydist_X06);
   
   ObjectCreate("X06_ValueLR", OBJ_LABEL, WindowToUse, 0, 0);
   ObjectSetText("X06_ValueLR"," "+DoubleToStr(X06,dig),9, "Verdana", color_X06);
   ObjectSet("X06_ValueLR", OBJPROP_CORNER, Corner_ValueLR);
   ObjectSet("X06_ValueLR", OBJPROP_XDISTANCE, Xdist_ValueLR);
   ObjectSet("X06_ValueLR", OBJPROP_YDISTANCE, Ydist_X06);
   
   ObjectCreate("X07_LabelLR", OBJ_LABEL, WindowToUse, 0, 0);
   ObjectSetText("X07_LabelLR",StrX07,9, "Verdana", myColor7 );
   ObjectSet("X07_LabelLR", OBJPROP_CORNER, Corner_text);
   ObjectSet("X07_LabelLR", OBJPROP_XDISTANCE, Xdist_text);
   ObjectSet("X07_LabelLR", OBJPROP_YDISTANCE, Ydist_X07);
   
   ObjectCreate("X07_ValueLR", OBJ_LABEL, WindowToUse, 0, 0);
   ObjectSetText("X07_ValueLR"," "+DoubleToStr(X07,dig),9, "Verdana", color_X07);
   ObjectSet("X07_ValueLR", OBJPROP_CORNER, Corner_ValueLR);
   ObjectSet("X07_ValueLR", OBJPROP_XDISTANCE, Xdist_ValueLR);
   ObjectSet("X07_ValueLR", OBJPROP_YDISTANCE, Ydist_X07);

} // iPlotGauge
    
   return(0);
  }

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---