Author: Copyright 2016, BestXerof Corp.
Miscellaneous
Implements a curve of type %1It issuies visual alerts to the screen
0 Views
0 Downloads
0 Favorites
arrowsen
//+------------------------------------------------------------------+
//|                                                  #Arrow#Sen#.mq4 |
//|                                  Copyright 2016, BestXerof Corp. |
//|                                              bestxerof@gmail.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, BestXerof Corp."
#property link      "bestxerof@gmail.com"
#property version   "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Green
#property indicator_width1  1
#property indicator_color2 Red
#property indicator_width2  1

#define SIGNAL_BAR 1

extern bool use_alert=false;
extern int Kijun=26;
extern int ShiftKijun=3;
extern bool ShowLevel=true;
extern double Level=60.0;

double up_buffer[],dn_buffer[];

static int prev_time = 0;
static int prev_sign = 0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
   SetIndexBuffer(0,up_buffer);
   SetIndexBuffer(1,dn_buffer);

   SetIndexStyle(0,DRAW_ARROW);
   SetIndexArrow(0,233);
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexArrow(1,234);

   SetIndexEmptyValue(0,0.0);
   SetIndexEmptyValue(1,0.0);

   SetIndexLabel(0,"Buy");
   SetIndexLabel(1,"Sell");

   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
   ObjectsDeleteAll();

   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   RefreshRates();

   int limit=1000;
   int i,counted_bars=IndicatorCounted();

   i=Bars-counted_bars-1;

   if(i>limit-1)
      i=limit-1;

   while(i>=0)
     {
      
      double Kijun_Up=iCustom(Symbol(),PERIOD_CURRENT,"KijunSenLevel",Kijun,ShiftKijun,ShowLevel,Level,1,i);
      double Kijun_Dn=iCustom(Symbol(),PERIOD_CURRENT,"KijunSenLevel",Kijun,ShiftKijun,ShowLevel,Level,2,i);

      // BUY SIGNAL    
      if(Open[i]<Kijun_Dn && Close[i]>Kijun_Dn)
        {
         up_buffer[i]=Low[i]-30*MarketInfo(Symbol(),MODE_POINT);
        }

      // SELL SIGNAL
      if(Open[i]>Kijun_Up && Close[i]<Kijun_Up)
        {
         dn_buffer[i]=High[i]+30*MarketInfo(Symbol(),MODE_POINT);
        }

      i--;
     }

// USE ALERT

   if(SIGNAL_BAR>0 && Time[0]<=prev_time)
      return(0);

   prev_time=(int)Time[0];

   if(prev_sign<=0 && use_alert==true)
     {
      if(Close[SIGNAL_BAR]-up_buffer[SIGNAL_BAR]>0)
        {
         prev_sign=1;
         Alert("Signal (",Symbol(),", M",Period(),")  -  BUY!!!");
        }
     }
   if(prev_sign>=0 && use_alert==true)
     {
      if(dn_buffer[SIGNAL_BAR]-Close[SIGNAL_BAR]>0)
        {
         prev_sign=-1;
         Alert("Signal (",Symbol(),", M",Period(),")  -  SELL!!!");
        }
     }
   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 ---