Miscellaneous
0
Views
0
Downloads
0
Favorites
Tick_v1
//+------------------------------------------------------------------+
//| Tick.mq4 |
//| Denis Orlov |
//| http://denis-or-love.narod.ru |
//+------------------------------------------------------------------+
#property copyright "Denis Orlov"
#property link "http://denis-or-love.narod.ru"
//#include <Trend.mqh>
#property indicator_separate_window
double Line1[],Line2[],Line3[],Line4[],Line5[];
#property indicator_buffers 3
#property indicator_color1 Green
#property indicator_color2 Red
#property indicator_color3 Green
//#property indicator_color4 Green
//#property indicator_color5 Red
double oldPrice;
double UpSumm, DnSumm, MaxDiff;
datetime per;
extern int Diff_Line=6;
extern bool Diff_Alert=True;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
IndicatorShortName("Volume");
int Win=WindowFind("Volume");
DrawLabels("Diff", 1, 30, 10, "...", Blue, Win, 12);
DrawLabels("MaxDiff", 1, 30, 30, "...", Blue, Win, 14);
//ObjectSet("MaxDiff", OBJPROP_FONTSIZE, 14);
ObjectSetText("MaxDiff","...",14,"Arial",Blue);
//---- indicators
SetIndexBuffer(0,Line1);
SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,2);//DRAW_LINE
SetIndexShift(0,2);
SetIndexBuffer(1,Line2);
SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,2);
SetIndexShift(1,2);
SetIndexBuffer(2,Line3);
SetIndexStyle(2,DRAW_HISTOGRAM,STYLE_SOLID,2);
SetIndexShift(2,2);
/* SetIndexBuffer(4,Line4);
SetIndexStyle(4,DRAW_LINE,STYLE_SOLID,2);//
SetIndexBuffer(5,Line5);
SetIndexStyle(5,DRAW_LINE,STYLE_SOLID,2);*/
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
//----
int i, Counted_bars=IndicatorCounted();
i=Bars-Counted_bars-1; // Èíäåêñ ïåðâîãî íåïîñ÷èòàííîãî
//if (History>0 && i>History-1) // Åñëè ìíîãî áàðîâ òî ..
// i=History-1;
/* while(i>=2) // Öèêë ïî íåïîñ÷èòàííûì áàðàì
{
if(Bull_Bear(i)>0) {Line1[i+1]=Volume[i]; Line2[i+1]=Volume[i]-Volume[i]/24;}
if(Bull_Bear(i)<0) {Line2[i+1]=Volume[i]; Line3[i+1]=Volume[i]-Volume[i]/24;}
i--;
}*/
if (per == Time[0])//òîò æå áàð
{
double Razn=(Close[0]-oldPrice)/Point;
//Alert("Bid="+Bid+";oldPrice="+oldPrice+";Razn="+Razn);
if(Razn>0)
{
UpSumm=UpSumm+Razn;
}
if(Razn<0)
{
DnSumm=DnSumm+Razn;
}
oldPrice=Close[0];
Line1[1]=UpSumm;
Line2[0]=-DnSumm;
//if(Line1[0]<Line2[0])Line3[0]=UpSumm; else Line3[0]=0;
int Win=WindowFind("Volume");
double Diff=Line1[1]-Line2[0];
string DiffS=DoubleToStr(Diff, 1);
if(Line1[1]>Line2[0])
{color clr=Green; DrawLabels("Diff", 1, 30, 10, DiffS ,clr , Win, 12);
}//Line4[0]=Diff*2;
else
if(Line1[1]<Line2[0])
{clr=Red; DrawLabels("Diff", 1, 30, 10, DiffS, clr, Win, 12);
}//Line5[0]=-Diff*2;
// else
//if(Line1[1]==Line2[0])
//{clr=Blue; DrawLabels("Diff", 1, 30, 10, "..." ,clr , Win, 12);
//}// Line5[0]=0; Line4[0]=0;
if(MathAbs(Diff)>=MathAbs(MaxDiff))
{
MaxDiff=Diff;
DrawLabels("MaxDiff", 1, 30, 30, DiffS ,clr , Win, 14);
if(Diff_Line!=0 && MathAbs(MaxDiff)>=Diff_Line)
{
string name="Diff "+TimeToStr(Time[0],TIME_MINUTES);
if(Diff_Alert && ObjectFind(name)==-1)
Alert(Symbol()+" : Ðàçíèöà ìåæäó òèêàìè äîñòèãëà "+DiffS);
if(ObjectFind(name)==-1)
ObjectCreate(name, OBJ_VLINE,Win, Time[0], 0);
ObjectSet(name, OBJPROP_COLOR, clr ) ;
ObjectSetText( name, DiffS);
}
}
}
else// íîâûé áàð
{
per = Time[0];
Line1[3]=UpSumm;
Line2[3]=-DnSumm;
if(Line1[3]<Line2[3])Line3[3]=UpSumm; else Line3[3]=0;
Line1[2]=0;
Line2[2]=0;
Line1[1]=0;
Line2[1]=0;
UpSumm=0; DnSumm=0; MaxDiff=0;
// Line5[0]=Line5[1]; Line4[0]=Line4[1];
oldPrice=Open[0];
}
//----
return(0);
}
//+------------------------------------------------------------------+
int DrawLabels(string name, int corn, int X, int Y, string Text, color Clr=Green, int W=0, int FSize=10)
{
int Error=ObjectFind(name);// Çàïðîñ
if (Error!=W)// Åñëè îáúåêòà â óê. îêíå íåò :(
{
ObjectCreate(name,OBJ_LABEL,W, 0,0); // Ñîçäàíèå îáúåêòà
}
ObjectSet(name, OBJPROP_CORNER, corn); // Ïðèâÿçêà ê óãëó
ObjectSet(name, OBJPROP_XDISTANCE, X); // Êîîðäèíàòà Õ
ObjectSet(name,OBJPROP_YDISTANCE,Y);// Êîîðäèíàòà Y
ObjectSetText(name,Text,FSize,"Arial",Clr);
}
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
---