Jump to content
Sign in to follow this  
Gsmnet

Увеличить шрифт в Shi chanell

Recommended Posts

Gsmnet

Скрипт выдает коммент с указанием ширины канала в пунктах. Шрифт очень мелкий. Возможно кто-нибудь захочет усовершенствовать?

//+------------------------------------------------------------------+
//|                                             SHI_Channel_true.mq4 |
//|                                 Copyright © 2004, Shurka & Kevin |
//|                                    alerts 11.2013 by fxdaytrader |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, Shurka & Kevin (alerts by fxdaytrader)"
#property link      "http://forexBaron.net"
//----
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Red

double ExtMapBuffer1[];

//---- input parameters
extern int AllBars = 240;
extern int BarsForFract = 0;

//alerts/misc, fxdaytrader:
extern bool   ShowScreenComment      = true;
extern string ahi="******* ALERT SETTINGS:";
extern int    AlertCandle            = 0;//0:current, 1:last bar, etc.
extern bool   PopupAlerts            = true;
extern bool   EmailAlerts            = false;
extern bool   PushNotificationAlerts = false;
extern bool   SoundAlerts            = false;
extern string SoundFileHigh          = "alert.wav";
extern string SoundFileLow           = "alert2.wav";
int lastAlert=3;
//end alerts/misc

int    CurrentBar = 0;
double Step = 0;
int    B1 = -1, B2 = -1;
int    UpDown = 0;
double P1 = 0, P2 = 0, PP = 0;
int    i = 0, AB = 300, BFF = 0;
int    ishift = 0;
double iprice = 0;
datetime T1, T2;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0, DRAW_ARROW);
   SetIndexArrow(0, 164);
   SetIndexBuffer(0, ExtMapBuffer1);
   SetIndexEmptyValue(0, 0.0);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
	  ObjectDelete("TL1");
	  ObjectDelete("TL2");
	  ObjectDelete("MIDL");
	  if (ShowScreenComment) Comment("");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void DelObj()
  {
	  ObjectDelete("TL1");
	  ObjectDelete("TL2");
	  ObjectDelete("MIDL");
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int counted_bars = IndicatorCounted();
//---- 
	  if((AllBars == 0) || (Bars < AllBars)) 
	      AB = Bars; 
	  else AB = AllBars; //AB-количество обсчитываемых баров
	  if(BarsForFract > 0) 
		     BFF = BarsForFract; 
	  else
		     switch (Period())
		       {
			        case     1: BFF = 12; break;
			        case     5: BFF = 48; break;
			        case    15: BFF = 24; break;
			        case    30: BFF = 24; break;
			        case    60: BFF = 12; break;
			        case   240: BFF = 15; break;
			        case  1440: BFF = 10; break;
			        case 10080: BFF = 6;  break;
			        default: DelObj(); return(-1); break;
		       }
   CurrentBar = 2; //считаем с третьего бара, чтобы фрактал "закрепился
   B1 = -1; 
   B2 = -1; 
   UpDown = 0;
   while(((B1 == -1) || (B2==-1)) && (CurrentBar<AB))
     {
		     //UpDown = 1 значит первый фрактал найден сверху, UpDown = -1 значит первый фрактал
		     //найден снизу, UpDown = 0 значит фрактал ещё не найден.
		     //В1 и В2 - номера баров с фракталами, через них строим опорную линию.
		     //Р1 и Р2 - соответственно цены через которые будем линию проводить
		     if((UpDown < 1) && (CurrentBar == Lowest(Symbol(), Period(), MODE_LOW, BFF*2 + 1,
		        CurrentBar - BFF))) 
		       {
			        if(UpDown == 0) 
			          { 
			            UpDown = -1; 
			            B1 = CurrentBar; 
			            P1 = Low[B1]; 
			          }
			        else 
			          { 
			            B2 = CurrentBar; 
			            P2 = Low[B2];
			          }
		       }
		     if((UpDown > -1) && (CurrentBar == Highest(Symbol(), Period(), MODE_HIGH, BFF*2 + 1,
		        CurrentBar - BFF))) 
		       {
			        if(UpDown == 0) 
			          { 
			            UpDown = 1; 
			            B1 = CurrentBar; 
			            P1 = High[B1]; 
			          }
			        else 
			          { 
			            B2 = CurrentBar; 
			            P2 = High[B2]; 
			          }
		       }
		     CurrentBar++;
	    }
	  if((B1 == -1) || (B2 == -1)) 
	    {
	      DelObj(); 
	      return(-1);
	    } // Значит не нашли фракталов среди 300 баров 8-)
	  Step = (P2 - P1) / (B2 - B1); //Вычислили шаг, если он положительный, то канал нисходящий
	  P1 = P1 - B1*Step; 
	  B1 = 0; //переставляем цену и первый бар к нулю
//А теперь опорную точку противоположной линии канала.
	  ishift = 0; 
	  iprice = 0;
	  if(UpDown == 1)
	    { 
		     PP = Low[2] - 2*Step;
		     for(i = 3; i <= B2; i++) 
		       {
			        if(Low[i] < PP + Step*i) 
			            PP = Low[i] - i*Step; 
		       }
		     if(Low[0] < PP) 
		       {
		         ishift = 0; 
		         iprice = PP;
		       }
		     if(Low[1] < PP + Step) 
		       {
		         ishift = 1; 
		         iprice = PP + Step;
		       }
		     if(High[0] > P1) 
		       {
		         ishift = 0; 
		         iprice = P1;
		       }
		     if(High[1] > P1 + Step) 
		       {
		         ishift = 1; 
		         iprice = P1 + Step;
		       }
	    } 
	  else
	    { 
		     PP = High[2] - 2*Step;
		     for(i = 3; i <= B2; i++) 
		       {
			        if(High[i] > PP + Step*i) 
			            PP = High[i] - i*Step;
		       }
		     if(Low[0] < P1) 
		       {
		         ishift = 0; 
		         iprice = P1;
		       }
		     if(Low[1] < P1 + Step) 
		       {
		         ishift = 1; 
		         iprice = P1 + Step;
		       }
		     if(High[0] > PP) 
		       {
		         ishift = 0; 
		         iprice = PP;
		       }
		     if(High[1] > PP + Step) 
		       {
		         ishift = 1; 
		         iprice = PP + Step;
		       }
	    }
//Теперь переставим конечную цену и бар на АВ, чтобы линии канала рисовались подлиннее
	  P2 = P1 + AB*Step;
	  T1 = Time[B1]; 
	  T2 = Time[AB];
//Если не было пересечения канала, то 0, иначе ставим псису.
	  if(iprice != 0) 
	      ExtMapBuffer1[ishift] = iprice;
	  DelObj();
	  ObjectCreate("TL1", OBJ_TREND, 0, T2, PP + Step*AB, T1, PP); 
		 ObjectSet("TL1", OBJPROP_COLOR, Lime); 
		 ObjectSet("TL1", OBJPROP_WIDTH, 2); 
		 ObjectSet("TL1", OBJPROP_STYLE, STYLE_SOLID); 
	  ObjectCreate("TL2", OBJ_TREND, 0, T2, P2, T1, P1); 
		 ObjectSet("TL2", OBJPROP_COLOR, Lime); 
		 ObjectSet("TL2", OBJPROP_WIDTH, 2); 
		 ObjectSet("TL2", OBJPROP_STYLE, STYLE_SOLID); 
	  ObjectCreate("MIDL", OBJ_TREND, 0, T2, (P2 + PP + Step*AB) / 2, T1, (P1 + PP) / 2);
		 ObjectSet("MIDL", OBJPROP_COLOR, Lime); 
		 ObjectSet("MIDL", OBJPROP_WIDTH, 1); 
		 ObjectSet("MIDL", OBJPROP_STYLE, STYLE_DOT);
		 if (ShowScreenComment) Comment(" .................................................................................................................Channel size = "+DoubleToStr(MathAbs(PP - P1) / Point, 0)+" Slope = "+DoubleToStr(-Step / Point, 2)+", channel borders="+DoubleToStr(GetObjectPrice("TL2",0),Digits)+", "+DoubleToStr(GetObjectPrice("TL1",0),Digits));

     CheckForLineTouch();
//----
   return(0);
  }
//+------------------------------------------------------------------+


//////////////////////////////////////////////////////////////////////
//stuff by fxdaytrader:
double GetObjectPrice(string objname,int objshift) {
 return(ObjectGetValueByShift(objname,objshift));
}//double GetObjectPrice(string objname,int objshift) {

bool ObjTouched(string objname,int shift) {
 double price=ObjectGetValueByShift(objname,shift);
  if (iHigh(NULL,0,shift)>=price && iClose(NULL,0,shift+1)<price) return(true);
  if (iLow(NULL,0,shift)<=price && iClose(NULL,0,shift)>price) return(true);
 return(false);
}//bool ObjTouched(string objname,int shift) {

void CheckForLineTouch() {
 double price1=GetObjectPrice("TL1",AlertCandle);
 double price2=GetObjectPrice("TL2",AlertCandle);
 string msg="SHI Channel Alert on "+Symbol()+", period "+TFtoStr(Period())+": ";

 if (lastAlert!=1 && ((ObjTouched("TL2",AlertCandle) && price2>price1) || (ObjTouched("TL1",AlertCandle) && price1>price2)) ) {
  msg=msg+"UPPER LINE TOUCHED";
  doAlerts(msg,SoundFileHigh);
  lastAlert=1;
 }

 if (lastAlert!=2 && ((ObjTouched("TL2",AlertCandle) && price2<price1) || (ObjTouched("TL1",AlertCandle) && price1<price2)) ) {
  msg=msg+"LOWER LINE TOUCHED";
  doAlerts(msg,SoundFileLow);
  lastAlert=2;
 }
}//void CheckForLineTouch() {

void doAlerts(string msg,string SoundFile) {
 string emailsubject="MT4 alert on acc. "+AccountNumber()+", "+WindowExpertName()+" - Alert on "+Symbol()+", period "+TFtoStr(Period());
  if (PopupAlerts) Alert(msg);
  if (EmailAlerts) SendMail(emailsubject,msg);
  if (PushNotificationAlerts) SendNotification(msg);
  if (SoundAlerts) PlaySound(SoundFile);
}//void doAlerts(string msg,string SoundFile) {

string TFtoStr(int period) {
 switch(period) {
  case 1     : return("M1");  break;
  case 5     : return("M5");  break;
  case 15    : return("M15"); break;
  case 30    : return("M30"); break;
  case 60    : return("H1");  break;
  case 240   : return("H4");  break;
  case 1440  : return("D1");  break;
  case 10080 : return("W1");  break;
  case 43200 : return("MN1"); break;
  default    : return(DoubleToStr(period,0));
 }
 return("UNKNOWN");
}//string TFtoStr(int period) {
//end stuff by fxdaytrader
//////////////////////////////////////////////////////////////////////

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×