Documente Academic
Documente Profesional
Documente Cultură
//| FractalZigZagNoRepaint.mq4
//| Copyright Pointzero-indicator.com
//| Shows ZigZag signals without repainting, ever.
//+------------------------------------------------------------------+
#property copyright "Copyright Arturo Lopez Perez"
#property
#property
#property
#property
indicator_chart_window
indicator_buffers 2
indicator_color1 Blue
indicator_color2 Red
#define IName
#define ZZBack
=
=
=
=
0;
EMPTY_VALUE;
EMPTY_VALUE;
EMPTY_VALUE;
// zzvalues
double zzhigh = 0;
double zzlow = 0;
// Offset in chart
int
nShift;
//+------------------------------------------------------------------+
//| Custom indicator initialization function
|
//+------------------------------------------------------------------+
int init()
{
// Arrows
SetIndexStyle(0, DRAW_ARROW, STYLE_DOT, 1);
SetIndexArrow(0, 233);
SetIndexBuffer(0, ExtMapBuffer1);
SetIndexStyle(1, DRAW_ARROW, STYLE_DOT, 1);
SetIndexArrow(1, 234);
SetIndexBuffer(1, ExtMapBuffer2);
// Data window
IndicatorShortName("Fractal Zig Zag No Repaint");
SetIndexLabel(0, "Fractal Up");
SetIndexLabel(1, "Fractal Down");
// Copyright
Comment("Copyright http://www.pointzero-indicator.com");
// Chart offset calculation
switch(Period())
{
case
1: nShift = 1;
case
5: nShift = 3;
case
15: nShift = 5;
case
30: nShift = 10;
case
60: nShift = 15;
case 240: nShift = 20;
case 1440: nShift = 80;
case 10080: nShift = 100;
case 43200: nShift = 200;
}
nShift = nShift * 2;
return(0);
break;
break;
break;
break;
break;
break;
break;
break;
break;
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function
|
//+------------------------------------------------------------------+
int deinit()
{
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function
|
//+------------------------------------------------------------------+
int start()
{
// Start, limit, etc..
int start = 0;
int limit;
int counted_bars = IndicatorCounted();
// nothing else to do?
if(counted_bars < 0)
return(-1);
// do not check repeated bars
limit = Bars - 1 - counted_bars;
// Check if ignore bar 0
if(CalculateOnBarClose == true) start = 1;
// Check the signal foreach bar from past to present
for(int i = limit; i >= start; i--)
{
// Zig Zag high
double zzhighn = iCustom(Symbol(), 0, "ZigZag", ZZDepth, ZZDev, ZZBack,
1, i);
if(zzhighn != 0) zzhigh = zzhighn;