TRUE Forex

Просмотр кода форекс индикатора !X-UK.TREND.mq4

// FOR THOSE OF YOU THAT IMPROVE UPON THIS HERE CODE I ASK YOU ONE THING
// PLEASE POST A COPY UP ON THE FOREX FORUMS FOR YOUR FELLOW TRADERS

#property indicator_chart_window
 
#property indicator_buffers 8

#property indicator_color1  Navy
#property indicator_color2  Maroon
#property indicator_color3  Green
#property indicator_width1 10
#property indicator_width2 14
#property indicator_width3 14
#property indicator_color4 CLR_NONE


#property indicator_color5 Magenta
#property indicator_color6 DodgerBlue
#property indicator_color7 CLR_NONE
#property indicator_width5 4
#property indicator_width6 4

#property indicator_color8 CLR_NONE
#property indicator_width8 1
 
double PeriodX2;

double buf1[];
int PeriodX1 = 0, ModeX1 = 1, PriceX1 = 0;

double  buf2[], buf3[], buf4[];
int ModeX2 = 1, PriceX2 = 0;

double buf5[], buf6[], buf7[];
int PeriodX3 = 0,  ModeX3 = 1, PriceX3 = 0;

double buf8[];
int PeriodX4 = 3,  ModeX4 = 1, PriceX4 = 0;

double MA4,MA8,MA32,RSI8;

#define DarkRedLight -2
#define RedLight -1
#define YellowLight 0
#define GreenLight 1
#define DarkGreenLight 2
#define OrangeLight 3
#define PowerFailure -999

color  PanelBgd1          = DimGray;
color  PanelBgd2          = C'40,50,60';

int    Corner=0;
int    Window=0;
int    addx               = 2;
int    addy               = 8;
 
//------------------------------------------------------------------------------ //

int init()
  {

   switch ( Period() )
   {
   case     1: PeriodX2 =   32;break;
   case     5: PeriodX2 =   32;break;
   case    15: PeriodX2 =   32;break;
   case    30: PeriodX2 =   32;break;
   case    60: PeriodX2 =   32;break;
   case   240: PeriodX2 =   32;break;
   case  1440: PeriodX2 =   32;break;
   case 10080: PeriodX2 =   32;break;
   default   : PeriodX2 =   32;break;
   }



   IndicatorBuffers(8);
   
   SetIndexBuffer(0, buf1);  SetIndexStyle(0,DRAW_LINE);
   
   SetIndexBuffer(1, buf2);  SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(2, buf3);  SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(3, buf4);  SetIndexStyle(3,DRAW_NONE);
   
   SetIndexBuffer(4, buf5);  SetIndexStyle(4, DRAW_LINE);
   SetIndexBuffer(5, buf6);  SetIndexStyle(5, DRAW_LINE);
   SetIndexBuffer(6, buf7);  SetIndexStyle(6, DRAW_NONE);
   
   SetIndexBuffer(7, buf8);  SetIndexStyle(7, DRAW_LINE);    

   return(0);
  }

// ------------------------------------------------------------------------------------------ //
//                            D E - I N I T I A L I S A T I O N                               //
// ------------------------------------------------------------------------------------------ //

int deinit()
{
   deleteObjects();
   return(0);
}

// ------------------------------------------------------------------------------------------ //
//                                M A I N   P R O C E D U R E                                 //
// ------------------------------------------------------------------------------------------ //

int start()
  {
   int i,limit,counted_bars=IndicatorCounted();
   
   
   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
   
   //STOPLIGHT MA & RSI CODE
    MA4=iMA(NULL,0, 4,0,1,0,0);
    MA8=iMA(NULL,0, 8,0,1,0,0);
   MA32=iMA(NULL,0,32,0,1,0,0);
   RSI8=iRSI(NULL,0,8,PRICE_CLOSE,0);

   
   for(i=0; i<limit; i++){
           
         buf1[i]=iMA(NULL,0,PeriodX1, 0, ModeX1, PriceX1, i);
         buf8[i]=iMA(NULL,0,PeriodX4, 0, ModeX4, PriceX4, i);   
      }
    
   for (int X1 = Bars - 10; X1 >= 0; X1--) buf4[X1] = iMA(NULL, 0, PeriodX2, 0, ModeX2, PriceX2, X1);
   for (int X2 = Bars - 10; X2 >= 0; X2--) {
      buf2[X2] = buf4[X2]; buf3[X2] = buf4[X2];
      if (buf4[X2] > buf4[X2 + 1]) {
         buf2[X2] = EMPTY_VALUE; buf3[X2 + 1] = buf4[X2 + 1];
      } else {
         if (buf4[X2] < buf4[X2 + 1]) {
            buf3[X2] = EMPTY_VALUE; buf2[X2 + 1] = buf4[X2 + 1];
         }}} 
         
         
    for (int X3 = Bars - 10; X3 >= 0; X3--) buf7[X3] = iMA(NULL, 0, PeriodX3, 0, ModeX3, PriceX3, X3);
   for (int X4 = Bars - 10; X4 >= 0; X4--) {
      buf5[X4] = buf6[X4]; buf6[X4] = buf7[X4];
      if (buf7[X4] > buf7[X4 + 1]) {
         buf5[X4] = EMPTY_VALUE; buf6[X4 + 1] = buf7[X4 + 1];
      } else {
         if (buf7[X4] < buf7[X4 + 1]) {
            buf6[X4] = EMPTY_VALUE; buf5[X4 + 1] = buf7[X4 + 1];
         }}}          
    
    
   int LightBulb=Determine_StopLight();
//   Show_TrafficLights(LightBulb);
            
   return(0);
  }
  
int Determine_StopLight()
{

   if(!IsConnected())                           return(PowerFailure);
   //GREENLIGHT
   if(MA4 > MA32 && MA8 > MA32 && RSI8 >= 60 && RSI8 < 75)   return(GreenLight);
   if(MA4 < MA32 && MA8 < MA32 && RSI8 <= 40 && RSI8 > 25)   return(GreenLight);
   
   //DARKGREENLIGHT
   if(MA4 > MA32 && MA8 > MA32 && RSI8 >= 55 && RSI8 < 75)   return(DarkGreenLight);
   if(MA4 < MA32 && MA8 < MA32 && RSI8 <= 45 && RSI8 > 25)   return(DarkGreenLight);

  //ORANGELIGHT
   if(MA4 > MA32 && MA8 > MA32 && RSI8 < 55)    return(OrangeLight);
   if(MA4 < MA32 && MA8 < MA32 && RSI8 > 45)    return(OrangeLight);
   
   if(RSI8 >= 75)   return(OrangeLight);
   if(RSI8 <= 25)   return(OrangeLight);

   //REDLIGHT
   if(RSI8 < 55 && RSI8 > 45)                   return(RedLight);
  

   return(PowerFailure);
}


int Create.traffic.light.system( string buffer, int buffer.x, int buffer.y ) {
   ObjectCreate( buffer, OBJ_LABEL,Window, 0, 0 );
   ObjectSet( buffer, OBJPROP_CORNER, Corner );
   ObjectSet( buffer, OBJPROP_XDISTANCE,buffer.x+addx);
   ObjectSet( buffer, OBJPROP_YDISTANCE,buffer.y+addy);
   ObjectSet( buffer, OBJPROP_BACK, false );
   }
   
void deleteObjects(){
   for(int i=0;   i<10;i++) ObjectDelete("tls000"+ i);
   for(    i=0;   i<10;i++) ObjectDelete("tls00" + i);
   GetLastError();
   }
 double Calculate_Profits()
  {
  double PL,total;

  for (int i = OrdersTotal()-1 ; i >= 0; i--) 
      if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES) == true)
         { 
         if(OrderSymbol() != Symbol()) continue;
         if(OrderType() == OP_BUY)  
            {
            PL = (OrderClosePrice()-OrderOpenPrice())/MarketInfo(OrderSymbol(),MODE_POINT)/10;
            total = total + PL;
            }
         else if(OrderType() == OP_SELL)  
            {
            PL = (OrderOpenPrice()-OrderClosePrice())/MarketInfo(OrderSymbol(),MODE_POINT)/10;
            total = total + PL;
            }    
         } 
   return(total);
  }
void  Show_TrafficLights(int TrafficLight)
    { 
 static int counter; 
      ObjectDelete("tls0010");         ObjectDelete("tls0011");
      double Pips=Calculate_Profits();
      if(Pips !=0)
         {
         color cPips=DeepSkyBlue;
         if(Pips<0)  cPips=Orange;
         ObjectDelete("tls0010");         ObjectDelete("tls0011");
         Create.traffic.light.system("tls0010",5, 26);  ObjectSetText("tls0010", "gggg", 17, "Webdings", DarkSlateGray);
         Create.traffic.light.system("tls0011",6, 27 );  ObjectSetText("tls0011", "Pips:  " + DoubleToStr(Pips,0), 12, "Arial Black", cPips);
         }
      color cStopLights[3];
      switch(TrafficLight)
         {
         case RedLight:       cStopLights[0]=Red;         cStopLights[1]=PanelBgd2;    cStopLights[2]=PanelBgd2;  break;
         case DarkRedLight:   cStopLights[0]=Maroon;      cStopLights[1]=PanelBgd2;    cStopLights[2]=PanelBgd2;  break;
         case YellowLight:    cStopLights[0]=PanelBgd2;   cStopLights[1]=Yellow;       cStopLights[2]=PanelBgd2;  break;
         case GreenLight:     cStopLights[0]=PanelBgd2;   cStopLights[1]=PanelBgd2;    cStopLights[2]=Aqua;       break;
         case DarkGreenLight: cStopLights[0]=PanelBgd2;   cStopLights[1]=PanelBgd2;    cStopLights[2]=LimeGreen;  break;
         case OrangeLight:    cStopLights[0]=PanelBgd2;   cStopLights[2]=PanelBgd2;    cStopLights[1]=Orange; 
                              counter++;
                              if(cPips == 0 && counter>2)
                                 {
                                 ObjectDelete("tls008");
                                 ObjectDelete("tls009");
                           //      Create.traffic.light.system("tls009",0, 0);  ObjectSetText("tls0009", "ggggg", 14, "Webdings",PanelBgd2);
                           //      Create.traffic.light.system("tls008",1, 1);  ObjectSetText("tls008", "Open Trade", 11, "Arial Black", Orange);
                                 counter=0;
                                 }
                              break;
         case PowerFailure:   cStopLights[0]=PanelBgd2;   cStopLights[1]=Blue;        cStopLights[2]=PanelBgd2;  break;
         default:             cStopLights[0]=PanelBgd2;   cStopLights[1]=PanelBgd2;   cStopLights[2]=PanelBgd2;  break;
         
         } 
      Create.traffic.light.system("tls0001",2,22);  ObjectSetText("tls0001", "g", 21, "Webdings", PanelBgd1);
      Create.traffic.light.system("tls0002",2,50);  ObjectSetText("tls0002", "g", 21, "Webdings", PanelBgd1);
      Create.traffic.light.system("tls0003",2,78);  ObjectSetText("tls0003", "g", 21, "Webdings", PanelBgd1);
      
      Create.traffic.light.system("tls001",4,25);   ObjectSetText("tls001", "n", 18, "Webdings", PanelBgd2);
      Create.traffic.light.system("tls002",4,53);   ObjectSetText("tls002", "n", 18, "Webdings", PanelBgd2);
      Create.traffic.light.system("tls003",4,81);   ObjectSetText("tls003", "n", 18, "Webdings", PanelBgd2);
      for(int i=0;i<3;i++)
         {
         Create.traffic.light.system("tls00" +(i+4),6, 25+i*28);  ObjectSetText("tls00" +(i+4), "n", 15, "Webdings", cStopLights[i]);
        }
        
   }
//--------------------------------------------Xard@hotmail.co.uk-----+
/*                                                                   
                              ud$$$**$$$$$$$bc.                          
                          u@**"        4$$$$$$$Nu                       
                        J                ""#$$$$$$r                     
                       @                       $$$$b                    
                     .F                        ^*3$$$                   
                    :% 4                         J$$$N                  
                    $  :F                       :$$$$$                  
                   4F  9                       J$$$$$$$                 
                   4$   k             4$$$$bed$$$$$$$$$                 
                   $$r  'F            $$$$$$$$$$$$$$$$$r                
                   $$$   b.           $$$$$$$$$$$$$$$$$N                
                   $$$$$k 3eeed$$b    XARD777."$$$$$$$$$                
    .@$**N.        $$$$$" $$$$$$F'L $$$$$$$$$$$  $$$$$$$                
    :$$L  'L       $$$$$ 4$$$$$$  * $$$$$$$$$$F  $$$$$$F         edNc   
   @$$$$N  ^k      $$$$$  3$$$$*%   $F4$$$$$$$   $$$$$"        d"  z$N  
   $$$$$$   ^k     '$$$"   #$$$F   .$  $$$$$c.u@$$$          J"  @$$$$r 
   $$$$$$$b   *u    ^$L            $$  $$$$$$$$$$$$u@       $$  d$$$$$$ 
    ^$$$$$$.    "NL   "N. z@*     $$$  $$$$$$$$$$$$$P      $P  d$$$$$$$ 
       ^"*$$$$b   '*L   9$E      4$$$  d$$$$$$$$$$$"     d*   J$$$$$r   
            ^$$$$u  '$.  $$$L     "#" d$$$$$$".@$$    .@$"  z$$$$*"     
              ^$$$$. ^$N.3$$$       4u$$$$$$$ 4$$$  u$*" z$$$"          
                '*$$$$$$$$ *$b      J$$$$$$$b u$$P $"  d$$P             
                   #$$$$$$ 4$ 3*$"$*$ $"$'c@@$$$$ .u@$$$P               
                     "$$$$  ""F~$ $uNr$$$^&J$$$$F $$$$#                 
                       "$$    "$$$bd$.TZUMAN$$$$F $$"                   
                         ?k         ?$$$$$$$$$$$F'*                     
                          9$$bL     z$$$$$$$$$$$F                       
                           $$$$    $$$$$$$$$$$$$                        
                            '#$$c  '$$$$$$$$$"                          
                             .@"#$$$$$$$$$$$$b                          
                           z*      $$$$$$$$$$$$N.                       
                         e"      z$$"  #$$$k  '*$$.                     
                     .u*      u@$P"      '#$$c   "$$c                   
              u@$*"""       d$$"            "$$$u  ^*$$b.               
            :$F           J$P"                ^$$$c   '"$$$$$$bL        
           d$$  ..      @$#                      #$$b         '#$       
           #ISMAEL#   4$$                          ^$$k         '$      
            "$$6""$b u$$                             '$    d$$$$$P      
              '$F $$$$$"                              ^b  ^$$$$b$       
               '$W$$$$"                                'b@$$$$"         
                                                        ^$$$*  
*/

Комментарии к исходному коду форекс индикатора !X-UK.TREND.mq4
В целях безопасности и борьбы со спамом в тексте комментариев запрещено размещать html-теги и ссылки. Благодарим за понимание.

  • X
  • 0% загружено
« индикатор !X-UK.NMA.4.mq4
индикатор !XARD TIMEFRAME.mq4 »