Price Data Components
Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
_TRO_Multi_Meter_SupRes
//+------------------------------------------------------------------+
//| _TRO_Multi_Meter_SupRes |
//| |
//| 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
// Replace SR1 with a unique 3 character code
#property indicator_chart_window
/*
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Blue
*/
extern bool Show_Heading = true;
extern string IndName = "SR1" ; // change
extern bool Corner_of_Chart_RIGHT_TOP = true;
extern int Shift_UP_DN =105;
extern int Adjust_Side_to_side = 20;
extern color BarLabel_color = LightBlue;
extern color CommentLabel_color = LightBlue;
//*******************
// change inputs for your indicator
extern int SR1_PERIOD = 14;
//*******************
extern double Level6 = 100 ;
extern double Level5 = 77 ;
extern double Level4 = 61 ;
extern double Level3 = 50 ;
extern double Level2 = 38 ;
extern double Level1 = 23 ;
extern double Level0 = 0 ;
extern color colorLevel6 = DeepPink ;
extern color colorLevel5 = Red ;
extern color colorLevel4 = Orange ;
extern color colorLevel3 = Yellow ;
extern color colorLevel2 = YellowGreen ;
extern color colorLevel1 = Blue ;
extern color colorLevel0 = DarkBlue;
//*******************
string ObjHead01,ObjHead02,ObjHead03,ObjHead04,ObjHead05,ObjHead06,ObjHead07,ObjHead08,ObjHead09;
string Obj0001,Obj0002,Obj0003,Obj0004,Obj0005,Obj0006,Obj0007,Obj0008,Obj0009;
//---- buffers
double v1_M1[], v2_M1[], val1_M1, val2_M1;
double v1_M5[];
double v2_M5[];
double val1_M5;
double val2_M5;
double v1_M15[];
double v2_M15[];
double val1_M15;
double val2_M15;
double v1_M30[];
double v2_M30[];
double val1_M30;
double val2_M30;
double v1_H1[], v2_H1[], val1_H1, val2_H1;
double v1_H4[], v2_H4[], val1_H4, val2_H4;
double v1_D1[], v2_D1[], val1_D1, val2_D1;
int i;
//+---------------
color MeterColor( double rsimeter )
{
if( rsimeter > Level6 ) { return( colorLevel6 ); }
if( rsimeter > Level5 ) { return( colorLevel5 ); }
if( rsimeter > Level4 ) { return( colorLevel4 ); }
if( rsimeter > Level3 ) { return( colorLevel3 ); }
if( rsimeter > Level2 ) { return( colorLevel2 ); }
if( rsimeter > Level1 ) { return( colorLevel1 ); }
return( colorLevel0 );
}
//+---------------
/*
double fResistance( int xPeriod, int i, double& fv1[] )
double fval1 = iFractals(NULL, 0, MODE_UPPER, i);
if(fval1 > 0) {fv1[i] = iHigh(NULL,xPeriod,i) ;
else fv1[i] = fv1[i+1];
return();
*/
//+---------------
//+---------------
/*
double iDeviation(double& array[], int total, int period,int shift)
{
double dMA = iMAOnArray(array,total,period,0,MODE_EMA,shift);
double dSum = 0.00;
int i;
for(i=0; i<period; i++) dSum += (array[shift+i]-dMA)*(array[shift+i]-dMA);
return(MathSqrt(dSum/period));
}
*/
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
/*
//---- drawing settings
SetIndexArrow(0, 119);
SetIndexArrow(1, 119);
//----
SetIndexStyle(0, DRAW_ARROW, STYLE_DOT , 1);
SetIndexDrawBegin(0, i-1);
SetIndexBuffer(0, v1_M5);
SetIndexLabel(0,"Resistance");
//----
SetIndexStyle(1, DRAW_ARROW, STYLE_DOT , 1);
SetIndexDrawBegin(1,i-1);
SetIndexBuffer(1, v2_M5);
SetIndexLabel(1,"Support");
*/
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
//***********************************************************************************************************************
string LabelTime="";
if (LabelTime=="") {LabelTime=TimeToStr(TimeLocal(),TIME_SECONDS); }
int counted_bars=IndicatorCounted();
ObjHead01 = "SR1ColHead01" + LabelTime ;
ObjHead02 = "SR1ColHead02" + LabelTime ;
ObjHead03 = "SR1ColHead03" + LabelTime ;
ObjHead04 = "SR1ColHead04" + LabelTime ;
ObjHead05 = "SR1ColHead05" + LabelTime ;
ObjHead06 = "SR1ColHead06" + LabelTime ;
ObjHead07 = "SR1ColHead07" + LabelTime ;
string SR1_ObjHead01 ="M1 " ;
string SR1_ObjHead02 ="M5 " ;
string SR1_ObjHead03 ="M15 " ;
string SR1_ObjHead04 =" M30 " ;
string SR1_ObjHead05 ="H1 " ;
string SR1_ObjHead06 ="H4 " ;
string SR1_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,SR1_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,SR1_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,SR1_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,SR1_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,SR1_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,SR1_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,SR1_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 ********************
//SR1 Signals
i = Bars;
while(i >= 0)
{
double val1_M1 = iFractals(NULL,PERIOD_M1, MODE_UPPER, i);
if(val1_M1 > 0) { v1_M1[i] = iHigh(NULL,PERIOD_M1,i); } else v1_M1[i] = v1_M1[i+1];
double R_M1 = v1_M1[i] ;
double val2_M1 = iFractals(NULL, PERIOD_M1, MODE_LOWER, i);
if(val2_M1 > 0) { v2_M1[i] = iLow(NULL,PERIOD_M1,i); } else v2_M1[i] = v2_M1[i+1];
double S_M1 = v2_M1[i] ;
double xRet_M1 = iClose(NULL,PERIOD_M1,i) - S_M1 ;
double xRange = R_M1 - S_M1 ;
if(xRange != 0) { double SR1_M1 = ( 100 * xRet_M1 ) / (xRange ); }
//********* M5 **********
double val1_M5 = iFractals(NULL,PERIOD_M5, MODE_UPPER, i);
if(val1_M5 > 0) { v1_M5[i] = iHigh(NULL,PERIOD_M5,i); } else v1_M5[i] = v1_M5[i+1];
double R_M5 = v1_M5[i] ;
double val2_M5 = iFractals(NULL, PERIOD_M5, MODE_LOWER, i);
if(val2_M5 > 0) { v2_M5[i] = iLow(NULL,PERIOD_M5,i); } else v2_M5[i] = v2_M5[i+1];
double S_M5 = v2_M5[i] ;
double xRet_M5 = iClose(NULL,PERIOD_M5,i) - S_M5 ;
xRange = R_M5 - S_M5 ;
if(xRange != 0) { double SR1_M5 = ( 100 * xRet_M5 ) / (xRange ); }
Print("Current time is ", TimeToStr(TimeCurrent()));
Print("val1_M5 is ", DoubleToStr(val1_M5,4) );
Print("R_M5 is ", DoubleToStr(R_M5,4) );
Print("S_M5 is ", DoubleToStr(S_M5,4) );
Print("xRet_M5 is ", DoubleToStr(xRet_M5,4) );
Print("SR1_M5 is ", DoubleToStr(SR1_M5,4) );
//******** M15 ******
double val1_M15 = iFractals(NULL,PERIOD_M15, MODE_UPPER, i);
if(val1_M15 > 0) { v1_M15[i] = iHigh(NULL,PERIOD_M15,i); double R_M15 = v1_M15[i] ;} else v1_M15[i] = v1_M15[i+1];
double val2_M15 = iFractals(NULL, PERIOD_M15, MODE_LOWER, i);
if(val2_M15 > 0) { v2_M15[i] = iLow(NULL,PERIOD_M15,i); double S_M15 = v2_M15[i] ; } else v2_M15[i] = v2_M15[i+1];
double xRet_M15 = iClose(NULL,PERIOD_M15,i) - S_M15 ;
xRange = R_M15 - S_M15 ;
if(xRange != 0) { double SR1_M15 = ( 100 * xRet_M15 ) / (xRange ); }
//******** M30 ******
double val1_M30 = iFractals(NULL,PERIOD_M30, MODE_UPPER, i);
if(val1_M30 > 0) { v1_M30[i] = iHigh(NULL,PERIOD_M30,i); double R_M30 = v1_M30[i] ;} else v1_M30[i] = v1_M30[i+1];
double val2_M30 = iFractals(NULL, PERIOD_M30, MODE_LOWER, i);
if(val2_M30 > 0) { v2_M30[i] = iLow(NULL,PERIOD_M30,i); double S_M30 = v2_M30[i] ; } else v2_M30[i] = v2_M30[i+1];
double xRet_M30 = iClose(NULL,PERIOD_M30,i) - S_M30 ;
xRange = R_M30 - S_M30 ;
if(xRange != 0) { double SR1_M30 = ( 100 * xRet_M30 ) / (xRange ); }
//******** H1 ******
double val1_H1 = iFractals(NULL,PERIOD_H1, MODE_UPPER, i);
if(val1_H1 > 0) { v1_H1[i] = iHigh(NULL,PERIOD_H1,i); double R_H1 = v1_H1[i] ;} else v1_H1[i] = v1_H1[i+1];
double val2_H1 = iFractals(NULL, PERIOD_H1, MODE_LOWER, i);
if(val2_H1 > 0) { v2_H1[i] = iLow(NULL,PERIOD_H1,i); double S_H1 = v2_H1[i] ; } else v2_H1[i] = v2_H1[i+1];
double xRet_H1 = iClose(NULL,PERIOD_H1,i) - S_H1 ;
xRange = R_H1 - S_H1 ;
if(xRange != 0) { double SR1_H1 = ( 100 * xRet_H1 ) / (xRange ); }
//******** H4 ******
double val1_H4 = iFractals(NULL,PERIOD_H4, MODE_UPPER, i);
if(val1_H4 > 0) { v1_H4[i] = iHigh(NULL,PERIOD_H4,i); double R_H4 = v1_H4[i] ;} else v1_H4[i] = v1_H4[i+1];
double val2_H4 = iFractals(NULL, PERIOD_H4, MODE_LOWER, i);
if(val2_H4 > 0) { v2_H4[i] = iLow(NULL,PERIOD_H4,i); double S_H4 = v2_H4[i] ; } else v2_H4[i] = v2_H4[i+1];
double xRet_H4 = iClose(NULL,PERIOD_H4,i) - S_H4 ;
xRange = R_H4 - S_H4 ;
if(xRange != 0) { double SR1_H4 = ( 100 * xRet_H4 ) / (xRange ); }
//******** D1 ******
double val1_D1 = iFractals(NULL,PERIOD_D1, MODE_UPPER, i);
if(val1_D1 > 0) { v1_D1[i] = iHigh(NULL,PERIOD_D1,i); double R_D1 = v1_D1[i] ;} else v1_D1[i] = v1_D1[i+1];
double val2_D1 = iFractals(NULL, PERIOD_D1, MODE_LOWER, i);
if(val2_D1 > 0) { v2_D1[i] = iLow(NULL,PERIOD_D1,i); double S_D1 = v2_D1[i] ; } else v2_D1[i] = v2_D1[i+1];
double xRet_D1 = iClose(NULL,PERIOD_D1,i) - S_D1 ;
xRange = R_D1 - S_D1 ;
if(xRange != 0) { double SR1_D1 = ( 100 * xRet_D1 ) / (xRange ); }
/* debug code
Print("Current time is ", TimeToStr(TimeCurrent()));
Print("xRange is ", DoubleToStr(xRange,4) );
Print("xRet_M1 is ", DoubleToStr(xRet_M1,4) );
Print("SR1_M1 is ", DoubleToStr(SR1_M1,4) );
string M1_SR1= "",M5_SR1= "", M15_SR1= "", M30_SR1= "", H1_SR1= "", H4_SR1= "", D1_SR1= "",PRC1;
color color_SR1m1,color_SR1m5,color_SR1m15,color_SR1m30,color_SR1m60,color_SR1m240,color_SR1m1440;
M1_SR1 = "-"; color_SR1m1 = MeterColor( 22 ) ; //
M5_SR1 = "-"; color_SR1m5 = MeterColor( 24 ) ;
M15_SR1 = "-"; color_SR1m15 = MeterColor( 33) ;
M30_SR1 = "-"; color_SR1m30 = MeterColor( 52 ) ;
H1_SR1 = "-"; color_SR1m60 = MeterColor( 65 ) ;
H4_SR1 = "-"; color_SR1m240 = MeterColor( 80 ) ;
D1_SR1 = "-"; color_SR1m1440 = MeterColor( 102 ) ;
*/
string M1_SR1= "",M5_SR1= "", M15_SR1= "", M30_SR1= "", H1_SR1= "", H4_SR1= "", D1_SR1= "",PRC1;
color color_SR1m1,color_SR1m5,color_SR1m15,color_SR1m30,color_SR1m60,color_SR1m240,color_SR1m1440;
M1_SR1 = "-"; color_SR1m1 = MeterColor( SR1_M1 ) ;
M5_SR1 = "-"; color_SR1m5 = MeterColor( SR1_M5 ) ;
M15_SR1 = "-"; color_SR1m15 = MeterColor( SR1_M15 ) ;
M30_SR1 = "-"; color_SR1m30 = MeterColor( SR1_M30 ) ;
H1_SR1 = "-"; color_SR1m60 = MeterColor( SR1_H1 ) ;
H4_SR1 = "-"; color_SR1m240 = MeterColor( SR1_H4 ) ;
D1_SR1 = "-"; color_SR1m1440 = MeterColor( SR1_D1 ) ;
Obj0002 = "SignalSR1M1t" + 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 = "SignalSR1M1" + LabelTime ;
ObjectCreate(Obj0003, OBJ_LABEL, 0, 0, 0);
ObjectSetText(Obj0003, M1_SR1, 40, "Tahoma Narrow", color_SR1m1);
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 = "SignalSR1M5" + LabelTime ;
ObjectCreate(Obj0004, OBJ_LABEL, 0, 0, 0);
ObjectSetText(Obj0004, M5_SR1, 40, "Tahoma Narrow", color_SR1m5);
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 = "SignalSR1M15" + LabelTime ;
ObjectCreate(Obj0005, OBJ_LABEL, 0, 0, 0);
ObjectSetText(Obj0005, M15_SR1, 40, "Tahoma Narrow", color_SR1m15);
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 = "SignalSR1M30" + LabelTime ;
ObjectCreate(Obj0006, OBJ_LABEL, 0, 0, 0);
ObjectSetText(Obj0006, M30_SR1, 40, "Tahoma Narrow", color_SR1m30);
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 = "SignalSR1M60" + LabelTime ;
ObjectCreate(Obj0007, OBJ_LABEL, 0, 0, 0);
ObjectSetText(Obj0007, H1_SR1, 40, "Tahoma Narrow", color_SR1m60);
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 = "SignalSR1M240" + LabelTime ;
ObjectCreate(Obj0008, OBJ_LABEL, 0, 0, 0);
ObjectSetText(Obj0008, H4_SR1, 40, "Tahoma Narrow", color_SR1m240);
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 = "SignalSR1M1440" + LabelTime ;
ObjectCreate(Obj0009, OBJ_LABEL, 0, 0, 0);
ObjectSetText(Obj0009, D1_SR1, 40, "Tahoma Narrow", color_SR1m1440);
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);
i--;
} // WHILE
//----
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
Markdown Formatting Guide
# H1
## H2
### H3
**bold text**
*italicized text*
[title](https://www.example.com)

`code`
```
code block
```
> blockquote
- Item 1
- Item 2
1. First item
2. Second item
---