TRO_Multi_Meter_LinReg#Pr1
Download scriptThis script is a multi-timeframe visual dashboard designed to help traders quickly assess market momentum across various time periods simultaneously. Instead of requiring you to switch between different charts to see what is happening on the 1-minute, 5-minute, or Daily levels, this tool gathers that information and displays it in a neat, organized dashboard directly on your current screen.
Core Logic and Functionality
Multi-Timeframe Analysis The primary logic of the script involves "looking" at multiple different timeframes at once. It specifically pulls data from:
- 1-Minute (M1)
- 5-Minutes (M5)
- 15-Minutes (M15)
- 30-Minutes (M30)
- 1-Hour (H1)
- 4-Hours (H4)
- Daily (D1)
Trend Detection For each of these timeframes, the script calculates a specific movement value. It compares the current trend against the previous price movement to determine direction.
- If the trend is moving upward on a specific timeframe, the dashboard will visually signal this using a Lime (Green) color.
- If the trend is moving downward or stagnant, it will signal this using a Red color.
Visual Dashboard Display The script handles all the "heavy lifting" of UI design so that you don't have to:
- Dynamic Positioning: It automatically creates and places text labels on your chart. You can choose whether these appear in the top-right or top-left corner.
- Automatic Alignment: It organizes the different timeframes into a clean row, ensuring they don't overlap and remain easy to read regardless of your screen size.
- Clean Updates: The script is designed to refresh constantly. It identifies the specific labels it created and updates their colors and positions in real-time as the market moves, ensuring you always see the most current data.
User Customization The logic includes several "user-friendly" toggles that allow you to tailor the experience without touching any code:
- Visibility: You can turn specific timeframes on or off (e.g., if you only trade the H1 and D1, you can hide the smaller timeframes).
- Aesthetics: You can customize the colors of the lines/labels and adjust the "Shift" or "Side-to-side" spacing to make sure the dashboard fits perfectly within your specific layout.
- Automatic Cleanup: When you remove the script from your chart, it includes a "cleanup" routine that automatically deletes all its labels and objects, leaving your chart clean and clutter-free.
//+------------------------------------------------------------------+
//| _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 = true;
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 int LRPeriod=13;
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);
}
string CustomInd1 = "_linreg" ;
double LR_M1, LR_M5 , LR_M15, LR_M30, LR_H1, LR_H4, LR_D1;
int myShiftA = 0 , myShiftB = 1 ;
LR_M1 = iCustom(NULL,1,CustomInd1, LRPeriod ,0,myShiftA ) - iCustom(NULL,1,CustomInd1, LRPeriod ,0, myShiftB );
LR_M5 = iCustom(NULL,5,CustomInd1, LRPeriod ,0,myShiftA ) - iCustom(NULL,5,CustomInd1, LRPeriod ,0, myShiftB );
LR_M15 = iCustom(NULL,15,CustomInd1, LRPeriod ,0,myShiftA ) - iCustom(NULL,15,CustomInd1, LRPeriod ,0, myShiftB );
LR_M30 = iCustom(NULL,30,CustomInd1, LRPeriod ,0,myShiftA ) - iCustom(NULL,30,CustomInd1, LRPeriod ,0, myShiftB );
LR_H1 = iCustom(NULL,60,CustomInd1, LRPeriod ,0,myShiftA ) - iCustom(NULL,60,CustomInd1, LRPeriod ,0, myShiftB );
LR_H4 = iCustom(NULL,240,CustomInd1, LRPeriod ,0,myShiftA ) - iCustom(NULL,240,CustomInd1, LRPeriod ,0, myShiftB );
LR_D1 = iCustom(NULL,1440,CustomInd1, LRPeriod ,0,myShiftA ) - iCustom(NULL,1440,CustomInd1, LRPeriod ,0, myShiftB );
double x0 = iCustom(NULL,1440,CustomInd1, LRPeriod ,0, myShiftB );
double x59 = iCustom(NULL,1440,CustomInd1, LRPeriod ,0,myShiftA );
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);
}
Comments