Группа "Стол заказов MQL"

Рейтинг 2088



РЕКОМЕНДУЮ



Доработка индикатора

Здравствуйте. Можно прикрутить стрелки к данному индикатору TREND.mq4 (3 Kb) при смене цвета линии
  • 0
  • Просмотров: 1566
  • 12 марта 2021, 20:18
  • soh28
Понравилcя материал? Не забудьте поставить плюс и поделиться в социальной сети!

Вступите в группу "Стол заказов MQL", чтобы следить за обновлениями
ПРИСОЕДИНИТЬСЯ К ГРУППЕ
присоединиться
  Предыдущая запись в группе
Индикатор импульсов
Следующая запись в группе  
Советник на двух индикаторах.
12 марта 2021
13 марта 2021

Комментарии (2)

+
0
на 22-е
avatar

  34  AM2 Сообщений: 15882 - Андрей

  • 12 марта 2021, 22:14
+
0
//+------------------------------------------------------------------+ 
//|                                     индикатор направления Тренда |                                      
//|                                     Зотов ИВ zot@pisem.net       |
//+------------------------------------------------------------------+
#property copyright "zot@pisem.net" 
#property link      "zot@pisem.net" 
#property indicator_chart_window 
#property indicator_buffers 4 
#property indicator_color1 Green 
#property indicator_color2 Red
//---- input parameters 
extern int       period=34; 
extern int       method=3;                         // MODE_SMA 
extern int       price=0;                          // PRICE_CLOSE 
//---- buffers 
double Uptrend[];
double Dntrend[];
double ExtMapBuffer[]; 
double Buy[],Sel[]; //стрелочки
bool UP = true;
bool DN = true;


//+------------------------------------------------------------------+ 
//| Custom indicator initialization function                         | 
//+------------------------------------------------------------------+ 
int init() 
{ 
    IndicatorBuffers(5);  
    SetIndexBuffer(0, Uptrend); SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1,clrGreen);//ArraySetAsSeries(Uptrend, true);  
    SetIndexBuffer(1, Dntrend); SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,1,clrRed);//ArraySetAsSeries(Dntrend, true);  
    SetIndexBuffer(2, Buy); SetIndexStyle(2,DRAW_ARROW,EMPTY,1,clrGreen); SetIndexArrow(2,233); SetIndexEmptyValue(2,0.0); //strelka vverh Buy[i]= Low[i]-10*Point;
    SetIndexBuffer(3, Sel); SetIndexStyle(3,DRAW_ARROW,EMPTY,1,clrRed ); SetIndexArrow(3,234); SetIndexEmptyValue(3,0.0); //strelka vniz  Sel[i]= High[i]+10*Point;
    SetIndexBuffer(4, ExtMapBuffer); 
    ArraySetAsSeries(ExtMapBuffer, true);
    IndicatorShortName("Trend("+period+")"); 
    return(0); 
} 

//+------------------------------------------------------------------+ 
//| Custor indicator deinitialization function                       | 
//+------------------------------------------------------------------+ 
int deinit() 
{ 

    return(0); 
} 


//+------------------------------------------------------------------+ 
double WMA(int x, int p) 
{ 
    return(iMA(NULL, 0, p, 0, method, price, x));    
} 

//+------------------------------------------------------------------+ 
//| Custom indicator iteration function                              | 
//+------------------------------------------------------------------+ 
int start() 
{ 
    int counted_bars = IndicatorCounted(); 
    
    if(counted_bars < 0) 
        return(-1); 
                  
    int x = 0; 
    int p = MathSqrt(period);              
    int e = Bars - counted_bars + period + 1; 
    
    double vect[], trend[]; 
    
    if(e > Bars) 
        e = Bars;    

    ArrayResize(vect, e); 
    ArraySetAsSeries(vect, true);
    ArrayResize(trend, e); 
    ArraySetAsSeries(trend, true); 
    
    for(x = 0; x < e; x++) 
    { 
        vect[x] = 2*WMA(x, period) - WMA(x, period);        
        //Print("Bar date/time: ", TimeToStr(Time[x]), " close: ", Close[x], " vect[", x, "] = ", vect[x], " 2*WMA(p/2) = ", 2*WMA(x, period/2), " WMA(p) = ",  WMA(x, period)); 
    } 

    for(x = 0; x < e-period; x++)
     
        ExtMapBuffer[x] = iMAOnArray(vect, 0, p, 0, method, x);        
    
    for(x = e-period; x >= 0; x--)
    {     
        trend[x] = trend[x+1];
        if (ExtMapBuffer[x]> ExtMapBuffer[x+1]) trend[x] =1;
        if (ExtMapBuffer[x]< ExtMapBuffer[x+1]) trend[x] =-1;
    
    if (trend[x]>0)
    { 
      Uptrend[x] = ExtMapBuffer[x];
      if (UP == true)
      { 
      Buy[x]= Low[x]-10*Point; UP = false; DN = true;
      }
      if (trend[x+1]<0) Uptrend[x+1]=ExtMapBuffer[x+1];
      Dntrend[x] = EMPTY_VALUE;
    }
    else 
                 
    if (trend[x]<0)
    { 
      Dntrend[x] = ExtMapBuffer[x]; 
      if (DN == true)
      {
      Sel[x]= High[x]+10*Point; DN = false; UP = true;
      }
      if (trend[x+1]>0) Dntrend[x+1]=ExtMapBuffer[x+1];
      Uptrend[x] = EMPTY_VALUE;
    }              
    
    //Print( " trend=",trend[x]);
    }
    
    return(0); 
} 
//+------------------------------------------------------------------+ 
avatar

  6  kalabster Сообщений: 39 - Tester_robotov

  • 12 марта 2021, 23:32

Зарегистрируйтесь или авторизуйтесь, чтобы оставить комментарий
Начать торговлю с Альпари