Miscellaneous
0
Views
0
Downloads
0
Favorites
Ticks_mod_v1.0a
//+------------------------------------------------------------------+
//| Ticks.mq4 |
//| MetaQuotes |
//| http://www.alpari-idc.ru/ru/experts/articles/ |
//+------------------------------------------------------------------+
#property copyright "Rosh"
#property link "http://www.alpari-idc.ru/ru/experts/articles/"
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Aqua
#property indicator_color2 Red
#property indicator_color3 Lime
//---- buffers
extern int MaxDrawTicks=500;
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
int myBars;
int tickCounter;
int delimeterCounter;
string nume1,nume2,nume3;
//-----------------------
string Path;
int Counter;
int CounterPlus;
int CounterMinus;
double BidPrev;
//----------------------
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
int i;
init_tick();
nume1 ="Bid_"+Symbol();
nume2 ="Ask_"+Symbol();
nume3 ="Open_"+Symbol();
GlobalVariableSet(nume1,0);
GlobalVariableSet(nume2,0);
GlobalVariableSet(nume3,0);
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0, ExtMapBuffer1);
SetIndexEmptyValue(0,0.0);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1, ExtMapBuffer2);
SetIndexEmptyValue(1,0.0);
SetIndexStyle(2,DRAW_LINE);
SetIndexBuffer(2, ExtMapBuffer3);
SetIndexEmptyValue(2,0.0);
Print("Îáíóëÿåì òèêè");
for (i=Bars-1;i>=0;i--) ExtMapBuffer1[i]=0.0;
for (i=Bars-1;i>=0;i--) ExtMapBuffer2[i]=0.0;
for (i=Bars-1;i>=0;i--) ExtMapBuffer3[i]=0.0;
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| ñäâèíåì ìàññèâ |
//+------------------------------------------------------------------+
void SetDelimeter()
{
//----
string delimeterDate=TimeToStr(Time[0]);
if (myBars!=0)
{
Print("Ñòàâèì ðàçäåëèòåëü");
int handle=WindowFind("Ticks_mod_v1.0");
if(!ObjectCreate(delimeterDate,OBJ_VLINE,handle,Time[0],0))
{
//Alert("Íåäà÷íàÿ ïîïûòêà ñîçäàíèÿ ðàçäåëèòåëÿ â îêíå ",
//handle," ïî âðåìåíè ",TimeToStr(CurTime()));
Print("Îøèáêà ¹",GetLastError(),", èìÿ ðàçäåëèòåëÿ ",delimeterDate);
}
else
{
ObjectSet(delimeterDate,OBJPROP_COLOR,Yellow);
ObjectSet(delimeterDate,OBJPROP_STYLE,STYLE_DASHDOT);
ObjectsRedraw();
}
}
//----
return(0);
}
//+------------------------------------------------------------------+
//| ñäâèíåì ìàññèâ |
//+------------------------------------------------------------------+
void ShiftArray()
{
//----
int V_lines,i1;
string delimeterName;
datetime firstTime;
int BarFirstTime;
if (tickCounter>2*MaxDrawTicks)
{
for (i1=tickCounter;i1>=MaxDrawTicks;i1--) ExtMapBuffer1[i1]=0.0;
for (i1=tickCounter;i1>=MaxDrawTicks;i1--) ExtMapBuffer2[i1]=0.0;
for (i1=tickCounter;i1>=MaxDrawTicks;i1--) ExtMapBuffer3[i1]=0.0;
tickCounter=MaxDrawTicks;
}
for(int cnt=tickCounter;cnt>0;cnt--)
{
ExtMapBuffer1[cnt]=ExtMapBuffer1[cnt-1];
ExtMapBuffer2[cnt]=ExtMapBuffer2[cnt-1];
ExtMapBuffer3[cnt]=ExtMapBuffer3[cnt-1];
}
V_lines=ObjectsTotal();
for (int z=0;z<V_lines;z++)
{
delimeterName=ObjectName(z);
if (ObjectFind(delimeterName)!=-1)
{
if (ObjectType(delimeterName)==OBJ_VLINE)
{
firstTime=ObjectGet(delimeterName,OBJPROP_TIME1);
BarFirstTime=iBarShift(NULL,0,firstTime);
firstTime=Time[BarFirstTime+1];
ObjectSet(delimeterName,OBJPROP_TIME1,firstTime);
}
}
}
//----
return(0);
}
//+------------------------------------------------------------------+
//| ïðèçíàê íîâîãî áàðà |
//+------------------------------------------------------------------+
bool isNewBar()
{
//----
bool res=false;
if (myBars!=Bars)
{
res=true;
myBars=Bars;
}
//----
return(res);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
//----
if (isNewBar())
{
// óñòàíîâèòü ðàçäåëèòåëü
//tickCounter++;
init_tick();
SetDelimeter();
ExtMapBuffer1[0]=Bid;
ExtMapBuffer2[0]=Ask;
ExtMapBuffer3[0]=Open[0];
GlobalVariableSet(nume1,Bid);
GlobalVariableSet(nume2,Ask);
GlobalVariableSet(nume3,Open[0]);
}
else
{
tickCounter++;
ShiftArray();
ExtMapBuffer1[0]=Bid;
ExtMapBuffer2[0]=Ask;
ExtMapBuffer3[0]=Open[0];
GlobalVariableSet(nume1,Bid);
GlobalVariableSet(nume2,Ask);
GlobalVariableSet(nume3,Open[0]);
}
//----
path1(Symbol());
Comment("");
Comment("\nPath: ",Path,
"\nPlus:",CounterPlus," Minus:",CounterMinus);
return(0);
}
//+------------------------------------------------------------------+
void init_tick()
{
Path="";
Counter=0;
CounterPlus=0;
CounterMinus=0;
BidPrev=MarketInfo(Symbol(),MODE_BID);
}
void path1(string symbol1)
{
int PathLimit =767;
double Deltha = MarketInfo(symbol1,MODE_BID) * MathPow(10, MarketInfo(symbol1,MODE_DIGITS)) -
BidPrev * MathPow(10, MarketInfo(symbol1,MODE_DIGITS));
//if(Deltha !=0)
if (Deltha >= 0)
Path = StringConcatenate("+",DoubleToStr ( Deltha, 0 ), Path);
else
Path = StringConcatenate( DoubleToStr ( Deltha, 0 ), Path );
Path = StringSubstr ( Path, 0, PathLimit );
if (MarketInfo(symbol1,MODE_BID)!= BidPrev){
Counter ++;
if ((Deltha > 0) && (Deltha !=0))
CounterPlus++;
if ((Deltha < 0) && (Deltha !=0))
CounterMinus++;
BidPrev = MarketInfo(symbol1,MODE_BID); //
}
}
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
---