_TRO_Multi_Meter_LinReg
Download scriptThis script functions as a multi-timeframe visual dashboard, designed to provide traders with a quick glance at market trends across several different time intervals simultaneously. Instead of forcing you to switch back and forth between charts to see what is happening on various periods (like 1 minute vs. Daily), it aggregates that information into a single display area on your current chart.
Core Logic and Functionality
Multi-Timeframe Analysis The tool automatically gathers data from multiple timeframes, specifically: 1 Minute (M1), 5 Minutes (M5), 15 Minutes (M15), 30 Minutes (M30), 1 Hour (H1), 4 Hours (H4), and Daily (D1). It looks at the mathematical direction of a Linear Regression trend for each of these periods.
Trend Detection To determine the "trend," the script calculates the difference between two specific points in time on the linear regression line:
- It compares the current value against a value from 59 bars ago.
- If the current value is higher than the past value, it identifies an upward trend.
- If the current value is lower than or equal to the past value, it identifies a downward trend.
Visual Dashboard Display Once the data is gathered, the script creates a clean, organized dashboard on your screen (usually in the top right corner).
- Headings: It labels each row so you know which timeframe you are looking at (e.g., "M1", "H4", etc.).
- Color Coding: The trend for each timeframe is displayed using a simple color-coded system:
- Lime (Green): Indicates a positive/upward trend.
- Red: Indicates a negative/downward trend.
- Dynamic Positioning: It includes settings to adjust the "Shift" and "Side-to-Side" positioning, allowing users to move the dashboard around the screen so it doesn't overlap with price bars or other indicators.
Automatic Cleanup The script is designed to be "clean." When you remove the indicator from your chart, it includes a routine to delete all the labels and objects it created, ensuring that no leftover text or lines remain on your workspace.
//+------------------------------------------------------------------+
//| _TRO_Multi_Meter_LR |
//| |
//| Copyright © 2007, Avery T. Horton, Jr. aka TheRumpledOne |
//| |
//| PO BOX 43575, TUCSON, AZ 85733 |
//| |
//| GIFT AND DONATIONS ACCEPTED |
//| |
//| therumpldone@gmail.com |
//+------------------------------------------------------------------+
//| |
//| go to www.kreslik.com for the latest indicator updates |
//+------------------------------------------------------------------+
//| |
//| Use www.efxgroup.com as your forex broker... |
//| ...tell them therumpledone sent you! |
//+------------------------------------------------------------------+
// thank you Xard777 from www.forex-tsd.com for showing me how to delete the objects properly.
// thank you mladen from www.forex-tsd.com for showing me I had a locals and global variables with same name
#property indicator_chart_window
extern bool Show_Heading = false;
extern string IndName = "LR" ; // change
extern bool Corner_of_Chart_RIGHT_TOP = true;
extern int Shift_UP_DN =120;
extern int Adjust_Side_to_side = 20;
extern color BarLabel_color = LightBlue;
extern color CommentLabel_color = LightBlue;
//*******************
// change inputs for your indicator
extern bool show_m1_LRlines = true;
extern color m1_line_color = LavenderBlush;
extern bool show_m5_LRlines = true;
extern color m5_line_color = Honeydew;
extern bool show_m15_LRlines = true;
extern color m15_line_color = AntiqueWhite;
extern bool show_m30_LRlines = true;
extern color m30_line_color = LightPink;
extern bool show_H1_LRlines = true;
extern color H1_line_color = Yellow;
extern bool show_H4_LRlines = true;
extern color H4_line_color = Blue;
extern bool show_D1_LRlines = true;
extern color D1_line_color = Red;
extern bool show_W1_LRlines = true;
extern color W1_line_color = DarkOrange;
extern bool show_MN_LRlines = false;
extern color MN_line_color = White;
//*******************
string ObjHead01,ObjHead02,ObjHead03,ObjHead04,ObjHead05,ObjHead06,ObjHead07,ObjHead08,ObjHead09;
string Obj0001,Obj0002,Obj0003,Obj0004,Obj0005,Obj0006,Obj0007,Obj0008,Obj0009;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
//***********************************************************************************************************************
string LabelTime="";
if (LabelTime=="") {LabelTime=TimeToStr(TimeLocal(),TIME_SECONDS); }
int counted_bars=IndicatorCounted();
ObjHead01 = "LRColHead01" + LabelTime ;
ObjHead02 = "LRColHead02" + LabelTime ;
ObjHead03 = "LRColHead03" + LabelTime ;
ObjHead04 = "LRColHead04" + LabelTime ;
ObjHead05 = "LRColHead05" + LabelTime ;
ObjHead06 = "LRColHead06" + LabelTime ;
ObjHead07 = "LRColHead07" + LabelTime ;
string LR_ObjHead01 ="M1 " ;
string LR_ObjHead02 ="M5 " ;
string LR_ObjHead03 ="M15 " ;
string LR_ObjHead04 =" M30 " ;
string LR_ObjHead05 ="H1 " ;
string LR_ObjHead06 ="H4 " ;
string LR_ObjHead07 ="D1 " ;
if ( Show_Heading) {
if (Corner_of_Chart_RIGHT_TOP == true)
{
int Col01x = 130+Adjust_Side_to_side ;
int Col01y = 28+Shift_UP_DN ;
}
if (Corner_of_Chart_RIGHT_TOP == false)
{
Col01x = 119+Adjust_Side_to_side ;
Col01y = 24+Shift_UP_DN ;
}
int ColAdj = -20 ;
int Col02x = Col01x + ColAdj ;
int Col03x = Col01x + ColAdj*2 ;
int Col04x = Col01x + ColAdj*3 ;
int Col05x = Col01x + ColAdj*4 ;
int Col06x = Col01x + ColAdj*5 ;
int Col07x = Col01x + ColAdj*6 ;
ObjectCreate(ObjHead01, OBJ_LABEL, 0, 0, 0);
ObjectSetText(ObjHead01,LR_ObjHead01 , 7, "Tahoma Narrow", BarLabel_color);
ObjectSet(ObjHead01, OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP);
ObjectSet(ObjHead01, OBJPROP_XDISTANCE, Col01x);
ObjectSet(ObjHead01, OBJPROP_YDISTANCE, Col01y);
ObjectCreate(ObjHead02, OBJ_LABEL, 0, 0, 0);
ObjectSetText(ObjHead02,LR_ObjHead02 , 7, "Tahoma Narrow", BarLabel_color);
ObjectSet(ObjHead02, OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP);
ObjectSet(ObjHead02, OBJPROP_XDISTANCE, Col02x);
ObjectSet(ObjHead02, OBJPROP_YDISTANCE, Col01y);
ObjectCreate(ObjHead03, OBJ_LABEL, 0, 0, 0);
ObjectSetText(ObjHead03,LR_ObjHead03 , 7, "Tahoma Narrow", BarLabel_color);
ObjectSet(ObjHead03, OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP);
ObjectSet(ObjHead03, OBJPROP_XDISTANCE, Col03x);
ObjectSet(ObjHead03, OBJPROP_YDISTANCE, 28+Shift_UP_DN);
ObjectCreate(ObjHead04, OBJ_LABEL, 0, 0, 0);
ObjectSetText(ObjHead04,LR_ObjHead04 , 7, "Tahoma Narrow", BarLabel_color);
ObjectSet(ObjHead04, OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP);
ObjectSet(ObjHead04, OBJPROP_XDISTANCE, Col04x);
ObjectSet(ObjHead04, OBJPROP_YDISTANCE, 28+Shift_UP_DN);
ObjectCreate(ObjHead05, OBJ_LABEL, 0, 0, 0);
ObjectSetText(ObjHead05,LR_ObjHead05 , 7, "Tahoma Narrow", BarLabel_color);
ObjectSet(ObjHead05, OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP);
ObjectSet(ObjHead05, OBJPROP_XDISTANCE, Col05x);
ObjectSet(ObjHead05, OBJPROP_YDISTANCE, 28+Shift_UP_DN);
ObjectCreate(ObjHead06, OBJ_LABEL, 0, 0, 0);
ObjectSetText(ObjHead06,LR_ObjHead06 , 7, "Tahoma Narrow", BarLabel_color);
ObjectSet(ObjHead06, OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP);
ObjectSet(ObjHead06, OBJPROP_XDISTANCE, Col06x);
ObjectSet(ObjHead06, OBJPROP_YDISTANCE, 28+Shift_UP_DN);
ObjectCreate(ObjHead07, OBJ_LABEL, 0, 0, 0);
ObjectSetText(ObjHead07,LR_ObjHead07 , 7, "Tahoma Narrow", BarLabel_color);
ObjectSet(ObjHead07, OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP);
ObjectSet(ObjHead07, OBJPROP_XDISTANCE, Col07x);
ObjectSet(ObjHead07, OBJPROP_YDISTANCE, 28+Shift_UP_DN);
} // Show_Heading
//******************* change for your indicator ********************
//LR Signals
// string CustomInd1 = "#(SF_LR_LINES)" ;
// string CustomInd1 = "_TRO_SF_LR" ;
// string CustomInd1 = "_Slope Direction Line" ;
// string CustomInd1 = "_TRO_Test" ;
string CustomInd1 = "_LinReg" ;
double LR_M1, LR_M5 , LR_M15, LR_M30, LR_H1, LR_H4, LR_D1;
/*
LR_M1 = iCustom(NULL,1,CustomInd1,80,3,0 ,0,0 );
LR_M5 = iCustom(NULL,5,CustomInd1,80,3,0 ,0,0 );
LR_M15 = iCustom(NULL,15,CustomInd1,80,3,0 ,0,0 );
LR_M30 = iCustom(NULL,30,CustomInd1,80,3,0 ,0,0 );
LR_H1 = iCustom(NULL,60,CustomInd1,80,3,0 ,0,0 );
LR_H4 = iCustom(NULL,240,CustomInd1,80,3,0 ,0,0 );
LR_D1 = iCustom(NULL,1440,CustomInd1,80,3,0 ,0,0 );
*/
int myShiftA = 0 , myShiftB = 59 ;
LR_M1 = iCustom(NULL,1,CustomInd1, 60 ,0,myShiftA ) - iCustom(NULL,1,CustomInd1, 60 ,0, myShiftB );
LR_M5 = iCustom(NULL,5,CustomInd1, 60 ,0,myShiftA ) - iCustom(NULL,5,CustomInd1, 60 ,0, myShiftB );
LR_M15 = iCustom(NULL,15,CustomInd1, 60 ,0,myShiftA ) - iCustom(NULL,15,CustomInd1, 60 ,0, myShiftB );
LR_M30 = iCustom(NULL,30,CustomInd1, 60 ,0,myShiftA ) - iCustom(NULL,30,CustomInd1, 60 ,0, myShiftB );
LR_H1 = iCustom(NULL,60,CustomInd1, 60 ,0,myShiftA ) - iCustom(NULL,60,CustomInd1, 60 ,0, myShiftB );
LR_H4 = iCustom(NULL,240,CustomInd1, 60 ,0,myShiftA ) - iCustom(NULL,240,CustomInd1, 60 ,0, myShiftB );
LR_D1 = iCustom(NULL,1440,CustomInd1, 60 ,0,myShiftA ) - iCustom(NULL,1440,CustomInd1, 60 ,0, myShiftB );
double x0 = iCustom(NULL,1440,CustomInd1, 60 ,0, myShiftB );
double x59 = iCustom(NULL,1440,CustomInd1, 60 ,0,myShiftA );
Comment( "D1 0 " + DoubleToStr( x0, 4) + " D1 59 " + DoubleToStr( x59, 4) + " LR_D1 " + DoubleToStr(LR_D1, 4) );
/*
if (show_m1_LRlines) {
double LR_M1 = iCustom(NULL,1,CustomInd1,m1_line_color,240,0,0,0);
}
if (show_m5_LRlines) {
double LR_M5 = iCustom(NULL,5,CustomInd1,m5_line_color,240,0,0,0);
}
if (show_m15_LRlines) {
double LR_M15 = iCustom(NULL,15,CustomInd1,m15_line_color,240,0,0,0);
}
if (show_m30_LRlines) {
double LR_M30 = iCustom(NULL,30,CustomInd1,m30_line_color,240,0,0,0);
}
if (show_H1_LRlines) {
double LR_H1 = iCustom(NULL,60,CustomInd1,H1_line_color,240,0,0,0);
}
if (show_H4_LRlines) {
double LR_H4 = iCustom(NULL,240,CustomInd1,H4_line_color,240,0,0,0);
}
if (show_D1_LRlines) {
double LR_D1 = iCustom(NULL,1440,CustomInd1,D1_line_color,240,0,0,0);
}
*/
string M1_LR= "",M5_LR= "", M15_LR= "", M30_LR= "", H1_LR= "", H4_LR= "", D1_LR= "",PRC1;
color color_LRm1,color_LRm5,color_LRm15,color_LRm30,color_LRm60,color_LRm240,color_LRm1440;
if (LR_M1 > 0) {M1_LR= "-";color_LRm1 = Lime; }
if (LR_M1 <= 0) {M1_LR= "-";color_LRm1 = Red; }
if (LR_M5 > 0) {M5_LR= "-";color_LRm5 = Lime; }
if (LR_M5 <= 0) {M5_LR= "-";color_LRm5 = Red; }
if (LR_M15 > 0) {M15_LR= "-";color_LRm15 = Lime; }
if (LR_M15 <= 0) {M15_LR= "-";color_LRm15 = Red; }
if (LR_M30 > 0) {M30_LR= "-";color_LRm30 = Lime; }
if (LR_M30 <= 0) {M30_LR= "-";color_LRm30 = Red; }
if (LR_H1 > 0) {H1_LR= "-";color_LRm60 = Lime; }
if (LR_H1 <= 0) {H1_LR= "-";color_LRm60 = Red; }
if (LR_H4 > 0) {H4_LR= "-";color_LRm240 = Lime; }
if (LR_H4 <= 0) {H4_LR= "-";color_LRm240 = Red; }
if (LR_D1 > 0) {D1_LR= "-";color_LRm1440 = Lime; }
if (LR_D1 <= 0) {D1_LR= "-";color_LRm1440 = Red; }
Obj0002 = "SignalLRM1t" + LabelTime ;
ObjectCreate(Obj0002, OBJ_LABEL, 0, 0, 0);
ObjectSetText(Obj0002,IndName, 7, "Tahoma Narrow", BarLabel_color);
ObjectSet(Obj0002, OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP);
ObjectSet(Obj0002, OBJPROP_XDISTANCE, 155+Adjust_Side_to_side);
ObjectSet(Obj0002, OBJPROP_YDISTANCE, 50+Shift_UP_DN);
Obj0003 = "SignalLRM1" + LabelTime ;
ObjectCreate(Obj0003, OBJ_LABEL, 0, 0, 0);
ObjectSetText(Obj0003, M1_LR, 40, "Tahoma Narrow", color_LRm1);
ObjectSet(Obj0003, OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP);
ObjectSet(Obj0003, OBJPROP_XDISTANCE, 130+Adjust_Side_to_side);
ObjectSet(Obj0003, OBJPROP_YDISTANCE, 20+Shift_UP_DN);
Obj0004 = "SignalLRM5" + LabelTime ;
ObjectCreate(Obj0004, OBJ_LABEL, 0, 0, 0);
ObjectSetText(Obj0004, M5_LR, 40, "Tahoma Narrow", color_LRm5);
ObjectSet(Obj0004, OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP);
ObjectSet(Obj0004, OBJPROP_XDISTANCE, 110+Adjust_Side_to_side);
ObjectSet(Obj0004, OBJPROP_YDISTANCE, 20+Shift_UP_DN);
Obj0005 = "SignalLRM15" + LabelTime ;
ObjectCreate(Obj0005, OBJ_LABEL, 0, 0, 0);
ObjectSetText(Obj0005, M15_LR, 40, "Tahoma Narrow", color_LRm15);
ObjectSet(Obj0005, OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP);
ObjectSet(Obj0005, OBJPROP_XDISTANCE, 90+Adjust_Side_to_side);
ObjectSet(Obj0005, OBJPROP_YDISTANCE, 20+Shift_UP_DN);
Obj0006 = "SignalLRM30" + LabelTime ;
ObjectCreate(Obj0006, OBJ_LABEL, 0, 0, 0);
ObjectSetText(Obj0006, M30_LR, 40, "Tahoma Narrow", color_LRm30);
ObjectSet(Obj0006, OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP);
ObjectSet(Obj0006, OBJPROP_XDISTANCE, 70+Adjust_Side_to_side);
ObjectSet(Obj0006, OBJPROP_YDISTANCE, 20+Shift_UP_DN);
Obj0007 = "SignalLRM60" + LabelTime ;
ObjectCreate(Obj0007, OBJ_LABEL, 0, 0, 0);
ObjectSetText(Obj0007, H1_LR, 40, "Tahoma Narrow", color_LRm60);
ObjectSet(Obj0007, OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP);
ObjectSet(Obj0007, OBJPROP_XDISTANCE, 50+Adjust_Side_to_side);
ObjectSet(Obj0007, OBJPROP_YDISTANCE, 20+Shift_UP_DN);
Obj0008 = "SignalLRM240" + LabelTime ;
ObjectCreate(Obj0008, OBJ_LABEL, 0, 0, 0);
ObjectSetText(Obj0008, H4_LR, 40, "Tahoma Narrow", color_LRm240);
ObjectSet(Obj0008, OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP);
ObjectSet(Obj0008, OBJPROP_XDISTANCE, 30+Adjust_Side_to_side);
ObjectSet(Obj0008, OBJPROP_YDISTANCE, 20+Shift_UP_DN);
Obj0009 = "SignalLRM1440" + LabelTime ;
ObjectCreate(Obj0009, OBJ_LABEL, 0, 0, 0);
ObjectSetText(Obj0009, D1_LR, 40, "Tahoma Narrow", color_LRm1440);
ObjectSet(Obj0009, OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP);
ObjectSet(Obj0009, OBJPROP_XDISTANCE, 10+Adjust_Side_to_side);
ObjectSet(Obj0009, OBJPROP_YDISTANCE, 20+Shift_UP_DN);
//----
return(0);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
ObjectsDeleteAll(0,OBJ_HLINE);
ObjectsDeleteAll(0,OBJ_TEXT);
ObjectsDeleteAll(0,OBJ_LABEL);
deleteObject();
//----
return(0);
}
void deleteObject()
{
//ObjectDelete(Obj0001);
ObjectDelete(Obj0002);
ObjectDelete(Obj0003);
ObjectDelete(Obj0004);
ObjectDelete(Obj0005);
ObjectDelete(Obj0006);
ObjectDelete(Obj0007);
ObjectDelete(Obj0008);
ObjectDelete(Obj0009);
ObjectDelete(ObjHead01);
ObjectDelete(ObjHead02);
ObjectDelete(ObjHead03);
ObjectDelete(ObjHead04);
ObjectDelete(ObjHead05);
ObjectDelete(ObjHead06);
ObjectDelete(ObjHead07);
//ObjectDelete(ObjHead08);
//ObjectDelete(ObjHead09);
}
Comments