Price Data Components
Miscellaneous
0
Views
0
Downloads
0
Favorites
AnalysisOnBars
//+------------------------------------------------------------------+
//| AnalysisOnBars.mq4 |
//| PozitiF |
//| mail: alex-w-@bk.ru |
//+------------------------------------------------------------------+
#property copyright "PozitiF"
#property link "mail: alex-w-@bk.ru"
#property indicator_separate_window
#property indicator_level1 0
#property indicator_buffers 4
#property indicator_color1 Red // Òåëî áàðà
#property indicator_color2 Black // Òåíü
#property indicator_color3 Black // Òåíü down
#property indicator_width1 3
#property indicator_width2 1
#property indicator_width3 1
#property indicator_color4 Blue // Òåëî áàðà
#property indicator_width4 3
//================ Íàñòðàèâàåìûå ïàðàìåòðû èíäèêàòîðà ================
extern string Symb ="";
extern int LimitBars = 500;
//================ Ãëîáàëüíûå ïåðåìåííûå èíäèêàòîðà ==================
double Buffer1[];
double Buffer2[];
double Buffer3[];
double Buffer4[];
string IndName="AnalysisOnBars";
string sy;
//================ Ïîäêëþ÷àåìûå áèáëèîòåêè èíäèêàòîðà ================
//+------------------------------------------------------------------+
//| #############--- expert initialization function ---############# |
//+------------------------------------------------------------------+
int init()
{
//----
SetIndexStyle(0, DRAW_HISTOGRAM);
SetIndexBuffer(0, Buffer1);
SetIndexStyle(1, DRAW_HISTOGRAM);
SetIndexBuffer(1, Buffer2);
SetIndexStyle(2, DRAW_HISTOGRAM);
SetIndexBuffer(2, Buffer3);
SetIndexStyle(3, DRAW_HISTOGRAM);
SetIndexBuffer(3, Buffer4);
if(Symb=="")sy=Symbol();
else sy=Symb;
IndicatorShortName(IndName+": "+sy+" | ");
//----
return(0);
}
//+------------------------------------------------------------------+
//| ###########--- expert deinitialization function ---############# |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| ##############--- expert start function ---#################### |
//+------------------------------------------------------------------+
int start()
{
//----------------- Variable Initialization -------------------------+
int limit, counted_bars, spr, window;
static int st_spr, spr_max, spr_min;
double point, OpenBar, CloseBar, LowBar, HighBar;
//----
point = MarketInfo(sy, MODE_POINT);
spr = MarketInfo(sy,MODE_SPREAD);
window = WindowFind(IndName+": "+sy+" | ");
counted_bars=IndicatorCounted();
if(LimitBars > 0){
if(counted_bars>0) limit = LimitBars - 1;
limit = LimitBars - limit;
}
else {
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
}
for(int i=0; i<limit; i++)
{
OpenBar=iOpen(sy,0,i);
CloseBar=iClose(sy,0,i);
LowBar=iLow(sy,0,i);
HighBar=iHigh(sy,0,i);
if(OpenBar<CloseBar){
Buffer1[i]=(CloseBar-OpenBar)/point;
Buffer4[i]=EMPTY_VALUE;
}else{
Buffer4[i]=(CloseBar-OpenBar)/point;
Buffer1[i]=EMPTY_VALUE;
}
//--- Òåíü îäèíàêîâîãî öâåòà è äëÿ áû÷úèõ è äëÿ ìåäâåæüèõ áàðîâ
Buffer2[i]=(HighBar-OpenBar)/point;
Buffer3[i]=(LowBar-OpenBar)/point;
}
// =========================== Âàëþòíàÿ ïàðà ===================================
SetLabelText(sy+"_Symbol", sy, 180, 1, Green, 1, "Times New Roman", 10, window);
// ============================== Ñïðåä =======================================
if(st_spr != spr){
string Spread = "Ñïðåä: " + DoubleToStr(spr, 0);
SetLabelText(sy+"_spread", Spread, 110, 1, Blue, 1, "Times New Roman", 10, window);
st_spr = spr;
if(st_spr!=spr_max && st_spr > spr_max){
spr_max=st_spr;
Spread="Max: " + DoubleToStr(spr_max, 0);
SetLabelText(sy+"_max", Spread, 10, 1, Blue, 1, "Times New Roman", 10, window);
}
if((st_spr!=spr_min && st_spr!=0 && st_spr < spr_min) || (spr_min==0)){
spr_min=st_spr;
Spread="Min: " + DoubleToStr(spr_min, 0);
SetLabelText(sy+"_min", Spread, 60, 1, Blue, 1, "Times New Roman", 10, window);
}
}
//----
return(0);
}
//+------------------------------------------------------------------+
//| àâòîð: Pozitif mail: alex-w-@bk.ru |
//+------------------------------------------------------------------+
//| Ñîçäà¸ò òåêñòîâóþ ìåòêó |
//+------------------------------------------------------------------+
//| ïàðàìåòðû: |
//| id - èäåíòèôèêàòîð ìåòêè (óíèêàëüíîå èìÿ) |
//| tx - òåêñò ìåòêè |
//| x - êîîðäèíàòà â ïèêñåëÿõ, ïî ãîðèçîíòàëè |
//| y - êîîðäèíàòà â ïèêñåëÿõ ïî âåðòèêàëè |
//| cl - öâåò |
//| bd - Binding, óãîë ïðèâÿçêè îáúåêòà 0-3 |
//| ft - øðèôò |
//| sz - ðàçìåð øðèôòà |
//| wd - íîìåð îêíà â êîòîðîì ñîçäàâàòü ìåòêó |
//| rt - âðàùåíèå îáúåêòà â ãðàäóñàõ |
//+------------------------------------------------------------------+
void SetLabelText(string id, string tx="NULL", int x=0, int y=0, color cl=Black, int bd=0, string ft="Georgia", int sz=12, int wd=0, int rt=0){
//--- Åñëè ìåòêà óæå åñòü íî íå ïåðåäàíû êîîðäèíàòû òî óäàëÿåì ---
if(tx!="NULL"){
if(ObjectFind(id)<0)ObjectCreate(id, OBJ_LABEL, wd, 0, 0);
ObjectSetText(id, tx, sz, ft, cl);
ObjectSet(id, OBJPROP_CORNER, bd);
ObjectSet(id, OBJPROP_XDISTANCE, x);
ObjectSet(id, OBJPROP_YDISTANCE, y);
ObjectSet(id,OBJPROP_ANGLE,rt);
}else{
if(tx=="NULL"&&ObjectFind(id)>=0)ObjectDelete(id);
}
}
//+------------------------------------------------------------------+
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
---