Miscellaneous
0
Views
0
Downloads
0
Favorites
YY
//+------------------------------------------------------------------+
//| YY.mq4 |
//| |
//| |
//+------------------------------------------------------------------+
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Orange
#property indicator_color2 MediumTurquoise
#property indicator_width1 2
#property indicator_width2 2
//---- input parameters
extern int Q = 122; // Êîëè÷åñòâî áàðîâ â ðàñ÷åòàõ. Ðàñ÷åò ñïðàâà íàëåâî, îò ïåðâîãî èëè íóëåâîãî áàðà. Åñëè Q = 0, òî
// â ðàñ÷åòàõ áóäóò èñïîëüçîâàòüñÿ âñå áàðû.
extern bool Show_6_Last_Ext = false; // Ïîêàçàòü çíà÷åíèÿ ïîñëåäíèå 6 êðàòêîñðî÷íûõ ýêñòðåìóìîâ è èõ èíäåêñû â êîììåíòàðèÿõ:
// Show_6_Last_Ext_ZigZag >= true.
extern int SpacePoints = 3; // Ðàññòîÿíèå â ïèïñàõ ìåæäó çíà÷êîì è ýêñòðåìóìîì áàðà
double Buffer0[];
double Buffer1[];
double Buffer2[];
double Buffer3[];
double A[192];
double I[192];
int H[192];
int L[192];
double p;
datetime time;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
IndicatorBuffers( 2 );
IndicatorDigits( Digits );
SetIndexBuffer( 0, Buffer0 );
SetIndexStyle( 0,DRAW_ARROW );
SetIndexArrow( 0,159 );
SetIndexBuffer( 1, Buffer1 );
SetIndexStyle( 1,DRAW_ARROW );
SetIndexArrow( 1,159 );
//---- name for DataWindow and indicator subwindow label
IndicatorShortName( "YY" );
if ( Q > Bars || Q == 0 ) Q = Bars - 34;
p = SpacePoints * Point;
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
Comment( " " );
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
//----
if ( time == Time[0] ) return(0); // ðàñ÷åò îäèí ðàç íà îòêðûòèè íîâîãî áàðà
time = Time[0];
int e, f;
for ( int i = 2; i < Q; i++ )
{
Buffer0[i] = EMPTY_VALUE; // çàïîëíÿåì ïóñòîòîé
Buffer1[i] = EMPTY_VALUE;
double high = High[i];
double low = Low[i];
int b1 = 0;
int b2 = 0;
int c1 = 0;
int c2 = 0;
//------------------------------------------------- right side
for ( int z = 1; z < 33; z++ )
{
if ( i - z > 0 )
{
if ( high > High[i - z] && low > Low[i - z] && b1 == 0 )
{
c1 = 1;
break;
}
else
{
if ( high <= High[i - z] && c1 == 0 )
{
b1 = 1;
}
}
//----
if ( low < Low[i - z] && high < High[i - z] && b2 == 0 )
{
c2 = 1;
break;
}
else
{
if ( low >= Low[i - z] && c2 == 0 )
{
b2 = 1;
}
}
}
}
//------------------------------------------------- left side
for ( z = 1; z < 33; z++ )
{
if ( high > High[i + z] && low > Low[i + z] && c1 == 1 )
{
Buffer0[i] = high + p;
f++;
H[f] = i;
A[f] = high;
break;
}
else
{
if ( high < High[i + z] && c1 == 1 )
{
c1 = 2;
}
}
//----
if ( low < Low[i + z] && high < High[i + z] && c2 == 1 )
{
Buffer1[i] = low - p;
e++;
L[e] = i;
I[e] = low;
break;
}
else
{
if ( low > Low[i + z] && c2 == 1 )
{
c2 = 2;
}
}
}
}
//----------------------------------------------------------------------------------------------------- Comments
if ( Show_6_Last_Ext == true )
Comment( " Maxs: ",A[1]," [ "+H[1]+" ] ", A[2]," [ "+H[2]+" ] ",
A[3]," [ "+H[3]+" ] ",A[4]," [ "+H[4]+" ] ",A[5]," [ "+H[5]+" ] ",A[6], " [ "+H[6]+" ]",
"\n\n Mins: ",I[1]," [ "+L[1]+" ] ", I[2]," [ "+L[2]+" ] ",
I[3]," [ "+L[3]+" ] ",I[4]," [ "+L[4]+" ] ",I[5]," [ "+L[5]+" ] ",I[6], " [ "+L[6]+" ] " );
//----
return(0);
}
//+------------------------------------------------------------------+
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
---