Author: © 2021, Alexey Viktorov
Miscellaneous
It issuies visual alerts to the screen
0 Views
0 Downloads
0 Favorites
Troika
ÿþ/********************************************************************\

|                                                          Troika.mq4|

|                                            © 2021, Alexey Viktorov |

|                       https://www.mql5.com/ru/users/alexeyvik/news |

\********************************************************************/

#property copyright "© 2021, Alexey Viktorov"

#property link      "https://www.mql5.com/ru/users/alexeyvik/news"

#property version   "1.10"



#property strict

#property indicator_chart_window



#property indicator_buffers     2

#property indicator_type1   		DRAW_ARROW

#property indicator_color1      clrBlueViolet

#property indicator_type2   		DRAW_ARROW

#property indicator_color2      clrRed

#property indicator_width1      3

#property indicator_width2      3



sinput	bool	alert	=	false;	//	Alert 2:;NG5=\2K:;NG5=

double  otstup;

/****************indicator buffers****************/

double up[];

double dn[];

/********************************************************************\

|               Custom indicator initialization function             |

\********************************************************************/

int OnInit()

 {

  SetIndexBuffer(0, up, INDICATOR_DATA);

  SetIndexArrow(0, 159);

  SetIndexLabel(0,"Up");

  SetIndexBuffer(1, dn, INDICATOR_DATA);

  SetIndexArrow(1, 159);

  SetIndexLabel(1,"Dn");

  otstup = ((ChartGetDouble(ChartID(), CHART_PRICE_MAX)-ChartGetDouble(ChartID(), CHART_PRICE_MIN))*0.015);

  return(INIT_SUCCEEDED);

 }/******************************************************************/



/********************************************************************\

|                 Custom indicator iteration function                |

\********************************************************************/

int OnCalculate(const int rates_total,

                const int prev_calculated,

                const datetime &time[],

                const double &open[],

                const double &high[],

                const double &low[],

                const double &close[],

                const long &tick_volume[],

                const long &volume[],

                const int &spread[])

 {

  int copy = 0, i = prev_calculated == 0 ? rates_total-3 : 0;

  while(i >= 0 && !IsStopped())

   {

    up[i] = EMPTY_VALUE;

    dn[i] = EMPTY_VALUE;

    //---

    if(close[i] > open[i] && close[i+1] > open[i+1] && close[i+2] > open[i+2] &&

       high[i] > high[i+1] && high[i+1] > high[i+2] &&

       close[i]-open[i] < close[i+1]-open[i+1] && close[i+1]-open[i+1] < close[i+2]-open[i+2] &&

       high[i]-close[i] > high[i+1]-close[i+1] && high[i+1]-close[i+1] > high[i+2]-close[i+2])

     {

      up[i] = high[i]+otstup;

      if(prev_calculated > 0 && alert)

        Alert(_Symbol, " ");

       }

    //---

    if(close[i] < open[i] && close[i+1] < open[i+1] && close[i+2] < open[i+2] &&

       low[i] < low[i+1] && low[i+1] < low[i+2] &&

       open[i]-close[i] < open[i+1]-close[i+1] && open[i+1]-close[i+1] < open[i+2]-close[i+2] &&

       close[i]-low[i] > close[i+1]-low[i+1] && close[i+1]-low[i+1] > close[i+2]-low[i+2])

      {

       dn[i] = low[i]-otstup;

      if(prev_calculated > 0 && alert)

        Alert(_Symbol, " ");

      }

    //---

    i--;

   }

  return(rates_total);

 }/******************************************************************/



/**********************Expert OnDeinit function**********************/

void OnDeinit(const int reason)

 {

  Comment("");

//Print(__FUNCTION__);

 }/******************************************************************/

Comments