cm ind High Low double

Author: Copyright © 2020, cmillion@narod.ru
Price Data Components
Series array that contains the highest prices of each barSeries array that contains the lowest prices of each bar
Miscellaneous
It issuies visual alerts to the screen
1 Views
0 Downloads
0 Favorites
cm ind High Low double
ÿþ#property copyright "Copyright © 2020, cmillion@narod.ru"

#property link      "http://cmillion.ru"

#property strict

#property description "A;8 =0 2K1@0==>< B09<D@59<5, hi 8;8 low ?>A;54=53> 10@0, @02=> hi 8;8 low 4@C3>3> 10@0 2 0=0;878@C5<>< ?5@8>45, B> 8=48:0B>@ A83=0;878@C5B >1 MB><."

#property indicator_chart_window



input ENUM_TIMEFRAMES TF = 0;   //"09<D@59<

input int candles=50; //?5@8>4

input int level=5; //4>?CA:

datetime timealert=0;

//+------------------------------------------------------------------+

void OnDeinit(const int reason)

{

   ObjectsDeleteAll(0,"UP");

   ObjectsDeleteAll(0,"DN");

}

//+------------------------------------------------------------------+

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[])

{

   double H = iHigh(NULL,TF,1);

   double L = iLow(NULL,TF,1);

   for(int i=2; i<candles; i++)

   {

      if (MathAbs(H-iHigh(NULL,TF,i))<=level*Point) 

      {

         TrendCreate(0,StringConcatenate("UP",iTime(NULL,TF,i)),0,iTime(NULL,TF,1),H,iTime(NULL,TF,i),H,clrGreen,STYLE_SOLID,5);

         if (timealert!=Time[0]) Alert("High = ",i," 10@5 ",StrTF(TF)); timealert=Time[0];

      }

      if (MathAbs(L-iLow(NULL,TF,i))<=level*Point) 

      {

         TrendCreate(0,StringConcatenate("DN",iTime(NULL,TF,i)),0,iTime(NULL,TF,1),L,iTime(NULL,TF,i),L,clrRed,STYLE_SOLID,5);

         if (timealert!=Time[0]) Alert("Low = ",i," 10@5 ",StrTF(TF)); timealert=Time[0];

      }

   }

   return(rates_total);

}

//--------------------------------------------------------------------

string StrTF(int t=0)

{

   if (t==0) t=Period();

   switch(t)

   {

      case 1:

         return("M1");

      case 5:

         return("M5");

      case 15:

         return("M15");

      case 30:

         return("M30");

      case 60:

         return("H1");

      case 240:

         return("H4");

      case 1440:

         return("D1");

      default:

         return(IntegerToString(t));

   }

}

//+------------------------------------------------------------------+

bool TrendCreate(const long            chart_ID=0,        // ID 3@0D8:0

                 const string          name="TrendLine",  // 8<O ;8=88

                 const int             sub_window=0,      // =><5@ ?>4>:=0

                 datetime              time1=0,           // 2@5<O ?5@2>9 B>G:8

                 double                price1=0,          // F5=0 ?5@2>9 B>G:8

                 datetime              time2=0,           // 2@5<O 2B>@>9 B>G:8

                 double                price2=0,          // F5=0 2B>@>9 B>G:8

                 const color           clr=clrRed,        // F25B ;8=88

                 const ENUM_LINE_STYLE style=STYLE_SOLID, // AB8;L ;8=88

                 const int             width=1,           // B>;I8=0 ;8=88

                 const bool            back=false,        // =0 704=5< ?;0=5

                 const bool            selection=false,   // 2K45;8BL 4;O ?5@5<5I5=89

                 const bool            ray_left=false,    // ?@>4>;65=85 ;8=88 2;52>

                 const bool            ray_right=false,   // ?@>4>;65=85 ;8=88 2?@02>

                 const bool            hidden=true,       // A:@KB 2 A?8A:5 >1J5:B>2

                 const long            z_order=0)         // ?@8>@8B5B =0 =060B85 <KHLN

  {

   if (!ObjectFind(name)) ObjectDelete(chart_ID,name);

   ObjectCreate(chart_ID,name,OBJ_TREND,sub_window,time1,price1,time2,price2);

   ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr);

   ObjectSetInteger(chart_ID,name,OBJPROP_STYLE,style);

   ObjectSetInteger(chart_ID,name,OBJPROP_WIDTH,width);

   ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back);

   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,selection);

   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,selection);

   ObjectSetInteger(chart_ID,name,OBJPROP_RAY_LEFT,ray_left);

   ObjectSetInteger(chart_ID,name,OBJPROP_RAY_RIGHT,ray_right);

   ObjectSetInteger(chart_ID,name,OBJPROP_HIDDEN,hidden);

   ObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,z_order);

   return(true);

  }

//+------------------------------------------------------------------+

Comments