#property copyright "AlievTM"
#property link "http://alievtm.blogspot.com/"
#property strict
#property version "1.32"
#property indicator_chart_window
extern int Bars_To_Count = 400;
extern int Bars_To_Recount = 1;
extern string pus1 = "////////////////////////////////////////////////";
extern string b_v = "Bars value settings";
extern int min_Bar_val = 1000;
extern int min_Bar_val_M1 = 8;
extern int min_Bar_val_M5 = 14;
extern int min_Bar_val_M15 = 18;
extern int min_Bar_val_M30 = 23;
extern int min_Bar_val_M60 = 40;
extern int min_Bar_val_M240 = 50;
extern int min_Bar_val_M1440 = 100;
extern string pus2 = "/////////////////////////////////////////////////";
extern string l_s = "Label settings";
extern int distamce_up = 6;
extern int distamce_down = 6;
extern int size = 12;
extern color Up_color = clrLime;
extern color Down_color = clrRed;
extern string pus3 = "/////////////////////////////////////////////////";
extern string so_set = "Alerts settings";
extern bool use_alert = true;
extern string alert = "Value =";
extern bool use_sound = false;
extern string sound = "nigniy alert karol";
extern bool Arrows = true;
extern int SignalBar = 0;
datetime prevtime;
double point;
int BarsCount;
bool count_chek;
datetime TimeBarD=0;
datetime TimeBarU=0;
/////////////////////////////////////////
void init()
{
BarsCount=Bars_To_Count;
point=Point;
//if(Symbol()!="USDRUB" && (Digits==3 || Digits==5 || Symbol()=="XAUUSD" || Symbol()=="XAGUSD")) point*=10;
//if(Symbol()=="USDRUB") point*=100;
if(Period()==1)
min_Bar_val=min_Bar_val_M1;
if(Period()==5)
min_Bar_val=min_Bar_val_M5;
if(Period()==15)
min_Bar_val=min_Bar_val_M15;
if(Period()==30)
min_Bar_val=min_Bar_val_M30;
if(Period()==60)
min_Bar_val=min_Bar_val_M60;
if(Period()==240)
min_Bar_val=min_Bar_val_M240;
if(Period()==1440)
min_Bar_val=min_Bar_val_M1440;
}
/////////////////
void deinit()
{
for (int i=ObjectsTotal()-1; i>=0; i--)
{
if(StringFind(ObjectName(i),"bar_val")!=-1) ObjectDelete(ObjectName(i));
}
}
////////////////
void start()
{
//true=up false=down
if((Close[SignalBar]-Open[SignalBar])>=min_Bar_val*point)
{
ob_cr(SignalBar,true);
if(TimeBarD!=Time[0])
{
if(use_alert) Alert(Symbol()+" ("+string(Period())+") "+alert+" "+DoubleToStr(MathAbs(Open[SignalBar]-Close[SignalBar])/point,0)+" - Signal DN");
if(use_sound) PlaySound(sound+".wav");
TimeBarD=Time[0];
}
}else{
if((Open[SignalBar]-Close[SignalBar])>=min_Bar_val*point)
{
ob_cr(SignalBar,false);
if(TimeBarU!=Time[0])
{
if(use_alert) Alert(Symbol()+" ("+string(Period())+") "+alert+" "+DoubleToStr(MathAbs(Open[SignalBar]-Close[SignalBar])/point,0)+" - Signal UP");
if(use_sound) PlaySound(sound+".wav");
TimeBarU=Time[0];
}
}else{
if(ObjectFind("bar_val"+string(Time[SignalBar]))!=-1) ObjectDelete("bar_val"+string(Time[SignalBar]));
}
}
//работа по открытию бара
if (Time[0] == prevtime) return;
prevtime = Time[0];
for (int i=BarsCount; i>0; i--)
{
if(i>Bars-1) i=Bars-1;
if((Close[i]-Open[i])>=min_Bar_val*point) ob_cr(i,true);
else
if((Open[i]-Close[i])>=min_Bar_val*point) ob_cr(i,false);
else
if(ObjectFind("bar_val"+DoubleToStr(i,0))!=-1) ObjectDelete("bar_val"+DoubleToStr(i,0));
}
/*
//alert
if(use_alert)
{
if(ObjectFind("bar_val"+string(Time[0]))!=-1)
Alert(Symbol()+" ("+string(Period())+") "+alert+" - "+DoubleToStr(MathAbs(Open[0]-Close[0])/point,0));
}
//sound
if(use_sound)
{
if(ObjectFind("bar_val"+string(Time[0]))!=-1)
PlaySound(sound+".wav");
}
*/
//recount chek
if(!count_chek)
{
count_chek=true;
BarsCount=Bars_To_Recount;
}
}
//func
//////////////////////////////
void ob_cr(int num_bar, bool up)
{
string name="bar_val"+string(Time[num_bar]);
color col=Up_color;
if(!up) col=Down_color;
double pric = High[num_bar]+distamce_up*point;
if(!up) pric=Low[num_bar]-distamce_down*point;
if(ObjectFind(name)==-1)
ObjectCreate(name,OBJ_TEXT,0,Time[num_bar],pric);
ObjectSet(name,OBJPROP_TIME1,Time[num_bar]);
ObjectSet(name,OBJPROP_PRICE1,pric);
if(!Arrows) ObjectSetText(name,DoubleToStr(MathAbs((Close[num_bar]-Open[num_bar])/point),0),size,"Arrial",col);
else{
ObjectSet(name, OBJPROP_ANCHOR,ANCHOR_CENTER);
if(up)
ObjectSetText(name, CharToStr(152), size, "Wingdings 3",Down_color);
else
ObjectSetText(name, CharToStr(151), size, "Wingdings 3",Up_color);
}
}
maksGruv