MUV indicator

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #132089 quote
    Loop
    Participant
    Senior

    Hi everybody,

    I found these “MUV” indicators for Metatrader interesting:

    https://www.mql5.com/en/code/8549

    Would it be possible to obtain the corresponding version in Prorealtime code (if not exsisting already).

    Thanks a lot in advance

    Loop

    +------------------------------------------------------------------+ 
    //|                                                          111.mq4 | 
    //|                      Copyright © 2008, MetaQuotes Software Corp. | 
    //|                                        http://www.metaquotes.net | 
    //+------------------------------------------------------------------+ 
    #property copyright "Copyright © 2008, MetaQuotes Software Corp." 
    #property link      "http://www.metaquotes.net" 
    
    #property indicator_separate_window 
    #property indicator_buffers 4 
    #property indicator_color1 Green 
    #property indicator_color2 Yellow 
    #property indicator_color3 Red 
    #property indicator_color4 Blue 
    
    //extern int MAMetod = 0; 
    extern int MAPeriod = 14; 
    extern int KPeriod = 14; 
    extern bool ShowDif = true; 
    extern bool ShowMUV = true; 
    //---- buffers 
    double ExtMapBuffer1[]; 
    double ExtMapBuffer2[]; 
    double ExtMapBuffer3[]; 
    double ExtMapBuffer4[]; 
    //double ExtMapBuffer1[]; 
    //double ExtMapBuffer2[]; 
    //double K[]; 
    double K0[]; 
    double K1[]; 
    double K2[]; 
    double K3[]; 
    
    //+------------------------------------------------------------------+ 
    //| Custom indicator initialization function                         | 
    //+------------------------------------------------------------------+ 
    int init() 
      { 
    //---- indicators 
    IndicatorBuffers(8); 
       if (ShowDif) {SetIndexStyle(0,DRAW_LINE); SetIndexStyle(1,DRAW_LINE);} 
       else {SetIndexStyle(0,DRAW_NONE); SetIndexStyle(1,DRAW_NONE);} 
       if (ShowMUV) {SetIndexStyle(2,DRAW_LINE); SetIndexStyle(3,DRAW_LINE);} 
       else {SetIndexStyle(2,DRAW_NONE); SetIndexStyle(3,DRAW_NONE);}   
       SetIndexBuffer(0,ExtMapBuffer1); 
       SetIndexBuffer(1,ExtMapBuffer2); 
       SetIndexBuffer(2,ExtMapBuffer3); 
       SetIndexBuffer(3,ExtMapBuffer4);   
       SetIndexBuffer(4,K0);   
       SetIndexBuffer(5,K1); 
       SetIndexBuffer(6,K2);   
       SetIndexBuffer(7,K3);       
    //---- 
       return(0); 
      } 
    //+------------------------------------------------------------------+ 
    //| Custom indicator deinitialization function                       | 
    //+------------------------------------------------------------------+ 
    int deinit() 
      { 
    //---- 
       
    //---- 
       return(0); 
      } 
    //+------------------------------------------------------------------+ 
    //| Custom indicator iteration function                              | 
    //+------------------------------------------------------------------+ 
    int start() 
      { 
       int counted_bars = IndicatorCounted(); 
       if(counted_bars < 0)  return(-1); 
       if(counted_bars > 0)   counted_bars--; 
       int limit = Bars - counted_bars; 
       if(counted_bars==0) limit-=1+1; 
    //---- 
    
      for (int i = limit;i >=0; i--) 
      { 
    
      K0[i] = iCustom(NULL,0,"MUV",MAPeriod,0,1,i)-iCustom(NULL,0,"MUV",MAPeriod,0,1,i+1); 
      K1[i] = iCustom(NULL,0,"MUV",MAPeriod,1,1,i)-iCustom(NULL,0,"MUV",MAPeriod,1,1,i+1); 
      K2[i] = iCustom(NULL,0,"MUV",MAPeriod,0,1,i); 
      K3[i] = iCustom(NULL,0,"MUV",MAPeriod,1,1,i); 
       
      double K0mx = K0[ArrayMaximum(K0,KPeriod,i)]; 
      double K0mm = K0[ArrayMinimum(K0,KPeriod,i)]; 
         
      double K1mx = K1[ArrayMaximum(K1,KPeriod,i)]; 
      double K1mm = K1[ArrayMinimum(K1,KPeriod,i)]; 
         
      double K2mx = K2[ArrayMaximum(K2,MAPeriod,i)]; 
      double K2mm = K2[ArrayMinimum(K2,MAPeriod,i)]; 
         
      double K3mx = K3[ArrayMaximum(K3,MAPeriod,i)]; 
      double K3mm = K3[ArrayMinimum(K3,MAPeriod,i)]; 
       
      if ((K0mx - K0mm)>0) double k0 = 1-((K0mx-K0[i])/(K0mx-K0mm)); else k0 = 1;         
      if ((K1mx - K1mm)>0) double k1 = 1-((K1mx-K1[i])/(K1mx-K1mm)); else k1 = 1; 
      if ((K2mx - K2mm)>0) double k2 = 1-((K2mx-K2[i])/(K2mx-K2mm)); else k2 = 0; 
      if ((K3mx - K3mm)>0) double k3 = 1-((K3mx-K3[i])/(K3mx-K3mm)); else k3 = 0; 
    
      ExtMapBuffer1[i] = k0; 
      ExtMapBuffer2[i] = k1; 
      ExtMapBuffer3[i] = k2; 
      ExtMapBuffer4[i] = k3; 
      } 
    //---- 
       return(0);
    //+------------------------------------------------------------------+ 
    //|                                                          MUV.mq4 | 
    //|  3 ноября 2008г.                                    Yuriy Tokman | 
    //| ICQ#:481-971-287                           yuriytokman@gmail.com | 
    //+------------------------------------------------------------------+ 
    #property copyright "Yuriy Tokman" 
    #property link      "yuriytokman@gmail.com" 
    
    #property indicator_chart_window 
    
    #property indicator_buffers 2 
    
    #property indicator_color1 LightYellow 
    #property indicator_color2 Red 
    
    extern int period     = 14; 
    extern int ma_method  = 0;  //MODE_SMA   0   Простое скользящее среднее  
                                //MODE_EMA   1   Экспоненциальное скользящее среднее  
    //MODE_SMMA  2   Сглаженное скользящее среднее  
    //MODE_LWMA  3   Линейно-взвешенное скользящее среднее  
    
    double Buf0[]; 
    double Buf1[]; 
    //+------------------------------------------------------------------+ 
    //| Custom indicator initialization function                         | 
    //+------------------------------------------------------------------+ 
    int init() 
      { 
    //---- indicators 
       SetIndexBuffer(0,Buf0); 
       SetIndexBuffer(1,Buf1); 
    
       SetIndexStyle(0,DRAW_NONE); 
       SetIndexStyle(1,DRAW_LINE); 
    
    //---- 
       return(0); 
      } 
    //+------------------------------------------------------------------+ 
    //| Custom indicator deinitialization function                       | 
    //+------------------------------------------------------------------+ 
    int deinit() 
      { 
    //---- 
    
    //---- 
       return(0); 
      } 
    //+------------------------------------------------------------------+ 
    //| Custom indicator iteration function                              | 
    //+------------------------------------------------------------------+ 
    int start() 
      { 
       int limit; 
       int counted_bars=IndicatorCounted(); 
       if(counted_bars<0)  return(-1); 
       if(counted_bars>0) counted_bars--; 
       limit=Bars-counted_bars; 
       for(int i=0; i<limit; i++) 
         { 
          double x=0.0, 
          h = iHigh(NULL,0,i), 
          l = iLow(NULL,0,i), 
          o = iOpen(NULL,0,i), 
          c = iClose(NULL,0,i); 
          if(c<o) { x=(h+l+c+l)/2;} 
          else if(c>o) { x=(h+l+c+h)/2;} 
          else if(c==o){ x=(h+l+c+c)/2;} 
          Buf0[i]=((x-l)+(x-h))/2; 
         } 
    
       for(i=0; i<limit; i++) 
         { 
          Buf1[i]=iMAOnArray(Buf0,0,period,0,ma_method,i); 
         } 
    //---- 
       return(0);
    //+------------------------------------------------------------------+ 
    //|                                                          111.mq4 | 
    //|                      Copyright © 2008, MetaQuotes Software Corp. | 
    //|                                        http://www.metaquotes.net | 
    //+------------------------------------------------------------------+ 
    #property copyright "Copyright © 2008, MetaQuotes Software Corp." 
    #property link      "http://www.metaquotes.net" 
    
    #property indicator_separate_window 
    #property indicator_buffers 2 
    #property indicator_color1 Blue 
    #property indicator_color2 Yellow 
    #property indicator_level1 0 
    
    extern int MAPeriod=14; 
    //---- buffers 
    double ExtMapBuffer1[]; 
    double ExtMapBuffer2[]; 
    //+------------------------------------------------------------------+ 
    //| Custom indicator initialization function                         | 
    //+------------------------------------------------------------------+ 
    int init() 
      { 
    //---- indicators 
       SetIndexStyle(0,DRAW_LINE); 
       SetIndexBuffer(0,ExtMapBuffer1); 
       SetIndexStyle(1,DRAW_LINE); 
       SetIndexBuffer(1,ExtMapBuffer2); 
    //---- 
       return(0); 
      } 
    //+------------------------------------------------------------------+ 
    //| Custom indicator deinitialization function                       | 
    //+------------------------------------------------------------------+ 
    int deinit() 
      { 
    //---- 
    
    //---- 
       return(0); 
      } 
    //+------------------------------------------------------------------+ 
    //| Custom indicator iteration function                              | 
    //+------------------------------------------------------------------+ 
    int start() 
      { 
       int counted_bars=IndicatorCounted(); 
       if(counted_bars < 0)  return(-1); 
       if(counted_bars>0) counted_bars--; 
       int limit=Bars-counted_bars; 
       if(counted_bars==0) limit-=1+1; 
    //---- 
       for(int i=limit;i>=0; i--) 
         { 
          ExtMapBuffer1[i] = iCustom(NULL,0,"MUV",MAPeriod,0,1,i)-iCustom(NULL,0,"MUV",MAPeriod,0,1,i+1); 
          ExtMapBuffer2[i] = iCustom(NULL,0,"MUV",MAPeriod,1,1,i)-iCustom(NULL,0,"MUV",MAPeriod,1,1,i+1); 
         } 
    //---- 
       return(0);
    muv-indicator.png muv-indicator.png
    #132127 quote
    Nicolas
    Keymaster
    Master

    Why interesting please? This MUV indicator is a moving average based of different price calculation depending of the candlestick form:

    //MUV indicator
    
    period     = 14
    mamethod  = 0
    
    hh = high
    l = low
    o = open
    c = close
    if(c<o) then 
    x=(hh+l+c+l)/2
    elsif(c>o) then
     x=(hh+l+c+hh)/2
    elsif(c=o)then
    x=(hh+l+c+c)/2
    endif
    Buf0=((x-l)+(x-hh))/2
    
    Buf1=average[period,mamethod](Buf0)
    
    return buf1

    Then, the other indicators are just difference of this one from a period to another or a stochastic based oscillator.

    #132192 quote
    Loop
    Participant
    Senior

    Thanks Nico anyway…

    Loop

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.

MUV indicator


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Loop @loop Participant
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by Loop
5 years, 9 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 05/18/2020
Status: Active
Attachments: 1 files
Logo Logo
Loading...