#property indicator_separate_window
#property indicator_buffers 8
#property indicator_color1 Aqua
#property indicator_color2 White
#property indicator_color3 Yellow
#property indicator_color4 C'0,55,0'
#property indicator_color5 FireBrick
#property indicator_color6 Silver
#property indicator_color7 FireBrick
#property indicator_color8 Orange
#property indicator_width4 3
#property indicator_width5 3
#property indicator_width8 2
extern bool Show_VISUAL_Alerts=true;
extern int TimeFrame = 10080;
extern int P1=9;
extern int P2=9;
extern int P3=9;
extern int P4=1;
extern int P5=21;
extern int P6=7;
extern int P7=1;
extern int P8=4;
extern int P9=21;
double A[],B[],C[],D[],E[],F[],G[],H[];
string INDNAME ="Batt";
int init(){
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,E);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,C);
SetIndexStyle(2,DRAW_LINE);
SetIndexBuffer(2,D);
SetIndexStyle(3,DRAW_LINE);
SetIndexBuffer(3,G);
SetIndexStyle(4,DRAW_LINE);
SetIndexBuffer(4,H);
SetIndexStyle(5,DRAW_LINE);
SetIndexBuffer(5,B);
SetIndexStyle(6,DRAW_NONE);
SetIndexBuffer(6,A);
SetIndexStyle(7,DRAW_LINE);
SetIndexBuffer(7,F);
IndicatorShortName(INDNAME);
return(0);
}
int start(){
int counted_bars=IndicatorCounted();
for (int i = Bars; i >= 0; i--){
A[i] = (iMA(Symbol(), TimeFrame, 2,0,0, PRICE_TYPICAL, i)*10000)-(iMA(Symbol(), TimeFrame, P1,0,0, PRICE_TYPICAL, i)*10000);
B[i] = SS(P2,i);
D[i] = SS(P3,i);
C[i] = QQ(A,P4,i);
E[i] = QQ(C,P5,i);
D[i] = QQ(C,P7,i);
F[i] = QQ(D,P6,i);
B[i] = QQ(C,P8,i);
D[i] = QQ(B,P7,i);
F[i] = QQ(B,P6,i);
E[i] = QQ(B,P9,i);
G[i] = C[i];
H[i] = C[i];
if(C[i] <=C[i+1])
G[i] = EMPTY_VALUE;
if(C[i] >=C[i+1])
H[i] = EMPTY_VALUE;
}
if(Show_VISUAL_Alerts==true){
string Mountains_direct="";
string Mountains_text="";
color Mountains_colordirect;
color Mountains_colortext;
if(G[0]==C[0] && G[0]>0){Mountains_direct="l"; Mountains_colordirect=Lime;}
if(G[0]==C[0] && G[0]>0){Mountains_text="BUY_"+TimeFrame; Mountains_colortext=DarkGoldenrod;}
if(H[0]==C[0] && H[0]<0){Mountains_direct="l"; Mountains_colordirect=Red;}
if(H[0]==C[0] && H[0]<0){Mountains_text="SELL_"+TimeFrame; Mountains_colortext=DarkGoldenrod;}
if(G[0]==C[0] && G[0]<0){Mountains_direct="l"; Mountains_colordirect=Red;}
if(G[0]==C[0] && G[0]<0){Mountains_text="SELL_"+TimeFrame; Mountains_colortext=DarkGoldenrod;}
if(H[0]==C[0] && H[0]>0){Mountains_direct="l"; Mountains_colordirect=Lime;}
if(H[0]==C[0] && H[0]>0){Mountains_text="BUY_"+TimeFrame; Mountains_colortext=DarkGoldenrod;}
string Mountains2_direct="";
string Mountains2_text="";
color Mountains2_colordirect;
color Mountains2_colortext;
if(G[0]==C[0] && G[0]>0){Mountains2_direct="l"; Mountains2_colordirect=C'0x50,0x50,0x99';}
if(H[0]==C[0] && H[0]<0){Mountains2_direct="l"; Mountains2_colordirect=C'0x50,0x50,0x99';}
if(G[0]==C[0] && G[0]<0){Mountains2_direct="l"; Mountains2_colordirect=Orange;}
if(H[0]==C[0] && H[0]>0){Mountains2_direct="l"; Mountains2_colordirect=Orange;}
ObjectDelete(INDNAME+"a_sigal");
ObjectCreate(INDNAME+"a_sigal", OBJ_LABEL,WindowFind(INDNAME), 0, 0);
ObjectSetText(INDNAME+"a_sigal",Mountains_direct, 15, "Wingdings",Mountains_colordirect );
ObjectSet(INDNAME+"a_sigal", OBJPROP_CORNER, 3);
ObjectSet(INDNAME+"a_sigal", OBJPROP_XDISTANCE, 10);
ObjectSet(INDNAME+"a_sigal", OBJPROP_YDISTANCE, 10);
ObjectDelete(INDNAME+"b_sigal");
ObjectCreate(INDNAME+"b_sigal", OBJ_LABEL,WindowFind(INDNAME), 0, 0);
ObjectSetText(INDNAME+"b_sigal",Mountains_text, 10, "Neuropol",Mountains_colortext);
ObjectSet(INDNAME+"b_sigal", OBJPROP_CORNER, 3);
ObjectSet(INDNAME+"b_sigal", OBJPROP_XDISTANCE, 80);
ObjectSet(INDNAME+"b_sigal", OBJPROP_YDISTANCE, 13);
ObjectDelete(INDNAME+"c_sigal");
ObjectCreate(INDNAME+"c_sigal", OBJ_LABEL,WindowFind(INDNAME), 0, 0);
ObjectSetText(INDNAME+"c_sigal",Mountains2_direct, 15, "Wingdings",Mountains2_colordirect );
ObjectSet(INDNAME+"c_sigal", OBJPROP_CORNER, 3);
ObjectSet(INDNAME+"c_sigal", OBJPROP_XDISTANCE, 10);
ObjectSet(INDNAME+"c_sigal", OBJPROP_YDISTANCE, 30);
}
return(0);
}
double SS(int vv, int bar){double nn = 9999, rr = -5555;
for(int i = 0; i < vv; i++){
if (nn > A[bar + i]) nn = A[bar + i];
if (rr < A[bar + i]) rr = A[bar + i];
}
if (nn == rr) return (B[bar+1]);
return (100 * (A[bar] - nn) / (rr - nn));
}
double QQ (double array[], int period, int shift){double ss = 0;
for (int i = shift + period - 1; i >= shift; i--){ss += array[i];
}
return (ss / period);
}