Conversione Hendrick-Prescot ex4 a itf

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #140443 quote
    alex20258
    Participant
    Average

    Buongiorno a tutti,

    recentemente ho trovato questo indicatore scritto in mt4

    simile a una media mobile trova il punto medio tra diverse candele

    allego un immagine per spiegarvi meglio

    se riuscite a convertirlo in prt potrebbe essere davvero utile

    Grazie in anticipo

    Alex

    //+------------------------------------------------------------------+
    //|                                                         HP_2.mq4 |
    //|                                        AP-Àëåêñàäð Ïàê, Àëìà-Àòà |
    //|                                                   ekr-ap@mail.ru |
    //| Hendrick-Prescot indi ïåðåâîä ñ VB Excell                        |
    //+------------------------------------------------------------------+
    
    //http://forum.mql4.com/ru/18404 - ôîðóì
    //http://en.wikipedia.org/wiki/Hodrick-Prescott_filter - wiki
    //http://www.web-reg.de/hp_addin.html#  - ïðîãðàììà VB Excell
    //ïðè èñïîëüçîâàíèè êîäà ñîîáùàòü àâòîðó ïðîãðàììû VB Excell
    #property copyright "AP"
    #property link      "ekr-ap@mail.ru"
    #property indicator_chart_window
    #property indicator_buffers 1
    #property indicator_color1 Black
    
    //Input parameters
    extern int nobs   =1000; //Number of bars to smooth
    extern int lambda =1600; //Higher lambda leads to the smoother data
    
    //Indicator buffers
    double hpf[];
    
    int init()
    {
       SetIndexBuffer(0,hpf);
       SetIndexStyle(0,DRAW_LINE,EMPTY,2);
       return(0);
    }
    //+----------------------------------------------------------------------------------------+
    int start()
    {
       HPF(nobs,lambda,hpf);
       return(0);
    }
    // Hodrick-Prescott Filter-----------------------------------------------------------------+
    void HPF(int nobs, int lambda, double& output[])
    {
       double a[],b[],c[],H1,H2,H3,H4,H5,HH1,HH2,HH3,HH4,HH5,HB,HC,Z;
       ArrayResize(a,nobs);
       ArrayResize(b,nobs);
       ArrayResize(c,nobs);
       for(int i=0;i<nobs;i++) output[i]=Close[i];
            
       a[0]=1.0+lambda;
       b[0]=-2.0*lambda;
       c[0]=lambda;
       for(i=1;i<nobs-2;i++)
       {
          a[i]=6.0*lambda+1.0;
          b[i]=-4.0*lambda;
          c[i]=lambda;
       }
       a[1]=5.0*lambda+1;
       a[nobs-1]=1.0+lambda;
       a[nobs-2]=5.0*lambda+1.0;
       b[nobs-2]=-2.0*lambda;
       b[nobs-1]=0.0;
       c[nobs-2]=0.0;
       c[nobs-1]=0.0;
       
       //Forward
       for(i=0;i<nobs;i++)
       {
          Z=a[i]-H4*H1-HH5*HH2;
          HB=b[i];
          HH1=H1;
          H1=(HB-H4*H2)/Z;
          b[i]=H1;
          HC=c[i];
          HH2=H2;
          H2=HC/Z;
          c[i]=H2;
          a[i]=(output[i]-HH3*HH5-H3*H4)/Z;
          HH3=H3;
          H3=a[i];
          H4=HB-H5*HH1;
          HH5=H5;
          H5=HC;
       }
       
       //Backward 
       H2=0;
       H1=a[nobs-1];
       output[nobs-1]=H1;
       for(i=nobs-2;i>=0;i--)
       {
          output[i]=a[i]-b[i]*H1-c[i]*H2;
          H2=H1;
          H1=output[i];
       }
    }
    
    
    HP.mq4 HP.ex4
    #145661 quote
    Nicolas
    Keymaster
    Master

    Questo indicatore sta ridipingendo il passato per abbinare perfettamente il prezzo. Penso che potrei provare a tradurlo, ma solo per PRT v11.

    #145672 quote
    Nicolas
    Keymaster
    Master

    Ho tradotto con successo il codice del filtro HP in ProRealTime. La curva si sta ridipingendo in tempo reale. Il codice è compatibile con PRT v11 e successivi. Puoi scaricarlo dalla libreria: Filtro Hodrick-Prescott (HP)

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

Conversione Hendrick-Prescot ex4 a itf


ProBuilder: Indicatori & Strumenti Personalizzati

New Reply
Author
author-avatar
alex20258 @alex20258 Participant
Summary

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

Topic Details
Forum: ProBuilder: Indicatori & Strumenti Personalizzati
Language: Italian
Started: 07/30/2020
Status: Active
Attachments: 2 files
Logo Logo
Loading...