Results 1 to 4 of 4
 0 Attachment(s)    

Thread: Laguerre

  1. #1

    Question Laguerre

    Hi! I would like to have the Laguerre indicator coded directly in the expert start funcition, is it possible?

    #property copyright "Emerald King"
    #property link "mailto:info@emerald-king.com"

    #property indicator_separate_window
    #property indicator_color1 Magenta
    #property indicator_level2 0.75
    #property indicator_level3 0.45
    #property indicator_level4 0.15
    //---- input parameters
    extern double gamma = 0.7;
    extern int CountBars = 950;
    //----
    double L0 = 0;
    double L1 = 0;
    double L2 = 0;
    double L3 = 0;
    double L0A = 0;
    double L1A = 0;
    double L2A = 0;
    double L3A = 0;
    double LRSI = 0;
    double CU = 0;
    double CD = 0;
    //---- buffers
    double val1[];
    //+------------------------------------------------------------------+
    //| Custom indicator initialization function |
    //+------------------------------------------------------------------+
    int init()
    {
    //---- indicators
    SetIndexBuffer(0, val1);
    //----
    if (CountBars > Bars)
    CountBars = Bars;
    SetIndexDrawBegin(0, Bars - CountBars);
    //----
    return(0);
    }
    //+------------------------------------------------------------------+
    //| Custor indicator deinitialization function |
    //+------------------------------------------------------------------+
    int deinit()
    {
    //----
    return(0);
    }
    //+------------------------------------------------------------------+
    //| Custom indicator iteration function |
    //+------------------------------------------------------------------+
    int start()
    {
    int i;
    int counted_bars = IndicatorCounted();
    i = CountBars - 1;
    //----
    while(i >= 0)
    {
    L0A = L0;
    L1A = L1;
    L2A = L2;
    L3A = L3;
    L0 = (1 - gamma)*Close[i] + gamma*L0A;
    L1 = - gamma *L0 + L0A + gamma *L1A;
    L2 = - gamma *L1 + L1A + gamma *L2A;
    L3 = - gamma *L2 + L2A + gamma *L3A;
    //----
    CU = 0;
    CD = 0;
    //----
    if(L0 >= L1)
    CU = L0 - L1;
    else
    CD = L1 - L0;
    //----
    if(L1 >= L2)
    CU = CU + L1 - L2;
    else
    CD = CD + L2 - L1;
    //----
    if(L2 >= L3)
    CU = CU + L2 - L3;
    else
    CD = CD + L3 - L2;
    //----
    if(CU + CD != 0)
    LRSI = CU / (CU + CD);
    val1[i] = LRSI;
    i--;
    }
    return(0);
    }

    Thanks in advance for any help!

  2. #2

    Question

    Hi! Please, could anyone help me?

  3. #3
    Administrator funyoo's Avatar
    Join Date
    Sep 2008
    Posts
    7,003

    Default

    Hi szmvscla,

    That's a good question.

    I have made a function :

    In the extern parameters, add :

    Code:
    extern double gamma=0.7;
    After the extern parameters, add :

    Code:
    double L0=0;
    double L1=0;
    double L2=0;
    double L3=0;
    double L0A=0;
    double L1A=0;
    double L2A=0;
    double L3A=0;
    double LRSI=0;
    double CU=0;
    double CD=0;
    After the start body, add :

    Code:
    double laguerre(int bar){
       int j=Bars;
       while(j>=bar){
          L0A=L0;
          L1A=L1;
          L2A=L2;
          L3A=L3;
          L0=(1-gamma)*Close[j]+gamma*L0A;
          L1=-gamma*L0+L0A+gamma*L1A;
          L2=-gamma*L1+L1A+gamma*L2A;
          L3=-gamma*L2+L2A+gamma*L3A;
          CU=0;
          CD=0;
          if(L0>=L1)CU=L0-L1;else CD=L1-L0;
          if(L1>=L2)CU=CU+L1-L2;else CD=CD+L2-L1;
          if(L2>=L3)CU=CU+L2-L3;else CD=CD+L3-L2;
          if(CU+CD!=0)LRSI=CU/(CU+CD);
          j--;
       }
       return(LRSI);
    }
    In the start body, when you want to know the value of the Laguerre on the previous bar, call the function :

    Code:
    laguerre(1)
    The second previous bar :

    Code:
    laguerre(2)
    Etc...

  4. #4

    Smile

    Quote Originally Posted by funyoo View Post
    Hi szmvscla,

    That's a good question.

    I have made a function :

    In the extern parameters, add :

    Code:
    extern double gamma=0.7;
    After the extern parameters, add :

    Code:
    double L0=0;
    double L1=0;
    double L2=0;
    double L3=0;
    double L0A=0;
    double L1A=0;
    double L2A=0;
    double L3A=0;
    double LRSI=0;
    double CU=0;
    double CD=0;
    After the start body, add :

    Code:
    double laguerre(int bar){
       int j=Bars;
       while(j>=bar){
          L0A=L0;
          L1A=L1;
          L2A=L2;
          L3A=L3;
          L0=(1-gamma)*Close[j]+gamma*L0A;
          L1=-gamma*L0+L0A+gamma*L1A;
          L2=-gamma*L1+L1A+gamma*L2A;
          L3=-gamma*L2+L2A+gamma*L3A;
          CU=0;
          CD=0;
          if(L0>=L1)CU=L0-L1;else CD=L1-L0;
          if(L1>=L2)CU=CU+L1-L2;else CD=CD+L2-L1;
          if(L2>=L3)CU=CU+L2-L3;else CD=CD+L3-L2;
          if(CU+CD!=0)LRSI=CU/(CU+CD);
          j--;
       }
       return(LRSI);
    }
    In the start body, when you want to know the value of the Laguerre on the previous bar, call the function :

    Code:
    laguerre(1)
    The second previous bar :

    Code:
    laguerre(2)
    Etc...
    Thank you very much!

Similar Threads

  1. Laguerre RSI EA ( EMA Filter) need Coding help
    By munaa in forum Ideas for expert advisors
    Replies: 0
    Last Post: 02-18-2016, 20:16
  2. Laguerre RSI EA
    By funyoo in forum Expert advisors backtesting
    Replies: 11
    Last Post: 02-18-2016, 19:44
  3. On-chart arrows based on Laguerre
    By Brimspark in forum MQL programming
    Replies: 0
    Last Post: 05-25-2011, 05:46
  4. HELP - Put an Alert on Laguerre Indicator
    By plcapital in forum Indicators
    Replies: 1
    Last Post: 06-08-2009, 01:43
  5. Adaptive Laguerre Filter..Help Please.
    By MadCow in forum Indicators
    Replies: 0
    Last Post: 03-31-2009, 20:34

Tags for this Thread

color, custom indicator, expert, indicator, level

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •