Profit (ZigZag)

Author: cashgrade
Miscellaneous
Implements a curve of type %1It issuies visual alerts to the screen
0 Views
0 Downloads
0 Favorites
Profit (ZigZag)
//+------------------------------------------------------------------+
//|                                              Profit (ZigZag).mq4 |
//|                                                        cashgrade |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "cashgrade"
#property link      "http://www.metaquotes.net"
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Red
extern int ReturnPoint=60;
extern bool   Sound.Alert    = true ;
//---- buffers
double EBuffer1[];
int Trend=1,InTrend,ttime;
double Points,Last_High, Last_Low;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
  string short_name;
  Points = MarketInfo (Symbol(), MODE_POINT);
//---- indicator line
   SetIndexBuffer(0,EBuffer1);
  SetIndexStyle(0,DRAW_SECTION,EMPTY,4,Red);
  SetIndexEmptyValue(0,0);
   
   //---- name for DataWindow and indicator subwindow label
   short_name="Reverspoint";
   IndicatorShortName(short_name);
   SetIndexLabel(0,short_name);

//----
   SetIndexDrawBegin(0,100);
//----

   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
  //----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted(),i,shift;

//---- TODO: add your code here
i=(Bars-counted_bars)-1;

for (shift=i; shift>=0;shift--)
{

if (Time[shift]!=ttime) InTrend=InTrend+1; 
ttime=Time[shift];
EBuffer1[shift]=0;
if (High[shift+1]>Last_High && Trend==1)  InTrend=1;
if (Low[shift+1]<Last_Low   && Trend==0)   InTrend=1;
if (High[shift+1]>Last_High) Last_High=High[shift+1];
if (Low[shift+1]<Last_Low)   Last_Low=Low[shift+1];

if (Trend==1 && Low[shift+1]<Last_High-ReturnPoint*Points && InTrend>1)
{
Trend=0;
EBuffer1[shift+InTrend]=High[shift+InTrend];
Last_High=Low[shift+1];
Last_Low=Low[shift+1];
InTrend=1; 
}

if (Trend==0 && High[shift+1]>Last_Low+ReturnPoint*Points && InTrend>1)
{
Trend=1;
EBuffer1[shift+InTrend]=Low[shift+InTrend];
Last_Low=High[shift+1];
Last_High=High[shift+1];
InTrend=1;
}   
//----
if(Sound.Alert) 
      { 
        if(Trend==1 && Low[shift+1]<Last_High) { if(Sound.Alert) {Alert("Profit (ZigZag)  ::  Symbol: "+Symbol()+"  ::  Zeit: "+TimeToStr(Time[0]));} }
        if(Trend==0 && High[shift+1]>Last_Low) { if(Sound.Alert) {Alert("Profit (ZigZag)  ::  Symbol: "+Symbol()+"  ::  Zeit: "+TimeToStr(Time[0]));} }
 }
 }
 
  return(0);
}
//+------------------------------------------------------------------+

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---