Traducir de mq4 a Prt:"Relative Strength rank"

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #101812 quote
    Fr7
    Participant
    Master

    Nicolás sería tan amable de traducir este código a PRT?Lo encuentro muy interesante para determinar la fortaleza de cualquier valor.

    Gracias

    //------------------------------------------------------------------
    //                                                  
    //------------------------------------------------------------------
    #property copyright 
    #property link      
    
    #property indicator_separate_window
    #property indicator_buffers 6
    #property indicator_color1  DeepSkyBlue
    #property indicator_color2  DeepSkyBlue
    #property indicator_color3  PaleVioletRed
    #property indicator_color4  PaleVioletRed
    #property indicator_color5  DimGray
    #property indicator_color6  DimGray
    #property indicator_width1  2
    #property indicator_width3  2
    #property indicator_width5  2
    #property indicator_style6  STYLE_DOT
    
    //
    //
    //
    //
    //
    
    extern int  RsrPrice       = PRICE_CLOSE;
    extern int  RsrShortPeriod = 20;
    extern int  RsrLongPeriod  = 140;
    extern int  RsrMaMode      = MODE_SMA;
    extern int  AtrPeriod      = 10;
    extern bool ShowHistogram  = true;
    
    //
    //
    //
    //
    //
    
    double rsr[];
    double rsrHuu[];
    double rsrHud[];
    double rsrHdu[];
    double rsrHdd[];
    double zli[];
    
    //------------------------------------------------------------------
    //                                                                  
    //------------------------------------------------------------------
    //
    //
    //
    //
    //
    
    int init()
    {
       if (ShowHistogram)
             int drawStyle = DRAW_HISTOGRAM;
       else      drawStyle = DRAW_NONE;         
       
       //
       //
       //
       //
       //
       
          SetIndexBuffer(0,rsrHuu); SetIndexStyle(0,drawStyle);
          SetIndexBuffer(1,rsrHud); SetIndexStyle(1,drawStyle);
          SetIndexBuffer(2,rsrHdd); SetIndexStyle(2,drawStyle);
          SetIndexBuffer(3,rsrHdu); SetIndexStyle(3,drawStyle);
          SetIndexBuffer(4,rsr);
          SetIndexBuffer(5,zli);
          IndicatorShortName("Relative Strength Rank ("+RsrShortPeriod+","+RsrLongPeriod+","+AtrPeriod+")");
       return(0);
    }
    int deinit() { return(0); }
    
    //------------------------------------------------------------------
    //                                                                  
    //------------------------------------------------------------------
    //
    //
    //
    //
    //
    
    double work[][2];
    #define _trend 0
    #define _slope 1
    
    int start()
    {
       int i,r,limit,counted_bars=IndicatorCounted();
    
       if(counted_bars<0) return(-1);
       if(counted_bars>0) counted_bars--;
             limit = MathMin(Bars-counted_bars,Bars-2);
             if (ArrayRange(work,0)!=Bars) ArrayResize(work,Bars);
    
       //
       //
       //
       //
       //
    
       for(i=limit, r=Bars-i-1; i>=0; i--,r++) 
       {
          double price = iMA(NULL,0,1             ,0,MODE_SMA ,RsrPrice,i);
          double mas   = iMA(NULL,0,RsrShortPeriod,0,RsrMaMode,RsrPrice,i);
          double mal   = iMA(NULL,0,RsrLongPeriod ,0,RsrMaMode,RsrPrice,i);
          double atr   = iATR(NULL,0,AtrPeriod,i);
             if (atr!=0)
                   rsr[i] = (price-mas+price-mal)/(2.0*atr);
             else  rsr[i] = 0;          
    
             //
             //
             //
             //
             //
             
             zli[i]    = 0;
             rsrHuu[i] = EMPTY_VALUE;
             rsrHud[i] = EMPTY_VALUE;
             rsrHdu[i] = EMPTY_VALUE;
             rsrHdd[i] = EMPTY_VALUE;
             work[r][_slope] = work[r-1][_slope];
                if (rsr[i]>rsr[i+1]) work[r][_slope] =  1;
                if (rsr[i]<rsr[i+1]) work[r][_slope] = -1;
                if (rsr[i]>0)
                   if (work[r][_slope]==1)
                         rsrHuu[i] = rsr[i];
                   else  rsrHud[i] = rsr[i];
                if (rsr[i]<0)
                   if (work[r][_slope]==-1)
                         rsrHdd[i] = rsr[i];
                   else  rsrHdu[i] = rsr[i];
       }
       return(0);
    }
    #102053 quote
    Fr7
    Participant
    Master

    Hola Nicolás….¿Puede hacerlo?

    #102137 quote
    Nicolas
    Keymaster
    Master

    Codifiqué el indicador, puede descargarlo aquí: Indicador de Rango de Fuerza Relativa

    Fr7 thanked this post
    #102162 quote
    Fr7
    Participant
    Master

    Muchas gracias Nicolás por su tiempo y dedicación!!!

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

Traducir de mq4 a Prt:"Relative Strength rank"


ProBuilder: Indicadores y Herramientas

New Reply
Author
author-avatar
Fr7 @fr7 Participant
Summary

This topic contains 3 replies,
has 2 voices, and was last updated by Fr7
6 years, 7 months ago.

Topic Details
Forum: ProBuilder: Indicadores y Herramientas
Language: Spanish
Started: 07/02/2019
Status: Active
Attachments: 2 files
Logo Logo
Loading...