MQL4 - automated forex trading   /  

Code Base

Code Base  Indicators  NonLagAMA To post a new code, please log in or register

Download MetaTrader 5 and visit MQL5.community Code Base
and Trade on the Go!
Prepare for the Championship
Couldn't find the right code? Order it in the Jobs section

This library is for
MetaTrader 4
Download MT 4 - 455 Kb

and Trade on the Go!

Name:
NonLagAMA [ ru ]
Author: edwinodus (2008.12.05 08:52)
Downloaded: 6547
Download:
 NonLagAMA.mq4 (4.5 Kb) View
//+------------------------------------------------------------------+
//|                                                    NonLagAMA.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_chart_window
#property indicator_buffers 3
#property indicator_color1 Yellow
#property indicator_width1 2
#property indicator_color2 RoyalBlue
#property indicator_width2 2
#property indicator_color3 Red
#property indicator_width3 2
//---- input parameters
extern int     Price         =0;
extern int     Length        =25;
extern int     Displace      =0;
extern int     Filter        =0;
extern int     Color         =1;
extern int     ColorBarBack  =2;
extern double  Deviation     =0;
//----
double Cycle= 4;
//---- indicator buffers
double MABuffer[];
double UpBuffer[];
double DnBuffer[];
double price[];
double trend[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
  int init()
  {
   int ft=0;
   string short_name;
//---- indicator line
   IndicatorBuffers(5);
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,MABuffer);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,UpBuffer);
   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2,DnBuffer);
   SetIndexBuffer(3,price);
   SetIndexBuffer(4,trend);
   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
   SetIndexArrow(0,159);
   SetIndexArrow(1,159);
   SetIndexArrow(2,159);
   SetIndexArrow(3,159);
//---- name for DataWindow and indicator subwindow label
   short_name="NonLagAma("+Length+")";
   IndicatorShortName(short_name);
   SetIndexLabel(0,"NLD");
   SetIndexLabel(1,"Up");
   SetIndexLabel(2,"Dn");
//----
   SetIndexShift(0,Displace);
   SetIndexShift(1,Displace);
   SetIndexShift(2,Displace);
   SetIndexDrawBegin(0,Length*Cycle+Length);
   SetIndexDrawBegin(1,Length*Cycle+Length);
   SetIndexDrawBegin(2,Length*Cycle+Length);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| NonLagMA_v4                                                      |
//+------------------------------------------------------------------+
int start()
  {
   int    i,shift, counted_bars=IndicatorCounted(),limit;
   double alfa, beta, t, Sum, Weight, step,g;
   double pi=3.1415926535;
//----
   double Coeff= 3*pi;
   int Phase=Length-1;
   double Len=Length*Cycle + Phase;
//----
   if(counted_bars > 0) limit=Bars-counted_bars;
   if(counted_bars < 0) return(0);
   if(counted_bars ==0) limit=Bars-Len-1;
   if(counted_bars < 1)
      for(i=1;i<Length*Cycle+Length;i++)
        {
         MABuffer[Bars-i]=0;
         UpBuffer[Bars-i]=0;
         DnBuffer[Bars-i]=0;
        }
   for(shift=limit;shift>=0;shift--)
     {
      Weight=0; Sum=0; t=0;
      for(i=0;i<=Len-1;i++)
        {
         g=1.0/(Coeff*t+1);
         if (t<=0.5)g=1;
         beta=MathCos(pi*t);
         alfa=g * beta;
         price[i]=iMA(NULL,0,1,0,MODE_SMA,Price,shift+i);
         Sum+=alfa*price[i];
         Weight+=alfa;
         if(t < 1)t+=1.0/(Phase-1);
         else if(t < Len-1) t+=(2*Cycle-1)/(Cycle*Length-1);
        }
      if (Weight > 0) MABuffer[shift]=(1.0+Deviation/100)*Sum/Weight;
      if (Filter>0)
        {
         if(MathAbs(MABuffer[shift]-MABuffer[shift+1]) < Filter*Point)MABuffer[shift]=MABuffer[shift+1];
        }
      if (Color>0)
        {
         trend[shift]=trend[shift+1];
         if (MABuffer[shift]-MABuffer[shift+1] > Filter*Point) trend[shift]= 1;
         if (MABuffer[shift+1]-MABuffer[shift] > Filter*Point) trend[shift]=-1;
         if (trend[shift]>0)
           {
            UpBuffer[shift]=MABuffer[shift];
            if (trend[shift+ColorBarBack]<0) UpBuffer[shift+ColorBarBack]=MABuffer[shift+ColorBarBack];
            DnBuffer[shift]=EMPTY_VALUE;
           }
         if (trend[shift]<0)
           {
            DnBuffer[shift]=MABuffer[shift];
            if (trend[shift+ColorBarBack]>0) DnBuffer[shift+ColorBarBack]=MABuffer[shift+ColorBarBack];
            UpBuffer[shift]=EMPTY_VALUE;
           }
        }
     }
   return(0);
  }
//+------------------------------------------------------------------+
10 comments  To post a new comment, please log in or register
Another one which repaints itself. Basically, it says "Sorry, man, you should have made a decision 3 bars ago". Back to the future. Useless.
06.06.2010 13:12 firdavis

The latest is a length of 15 on M5


NonLagAMA.gif

01.01.2010 00:22 edwinodus

Hello Ed,


You can from this to write an EA?


Robert

21.10.2009 09:04 Roberto

You may also try Length of 10 on the H1.

Ed


nonlagAMA

26.08.2009 19:22 edwinodus

This indicator repaints. Rpainting goes back 3 bars. So every bar is using information from 2 bars in the future.

Is it possible to implement this indicator without repainting?

Is this indicator is Perry Kauman'`?

10.06.2009 18:25 jeet1970
edwinodus wrote:

If you prefer a quicker response you can change the Length from 60 to 40, and see if it works better for you.

Ed

The latest revision of the nonlagama is now publishe with length of 24 and timeframe of H1.

Ed

07.04.2009 06:11 edwinodus

well, whatewer you'e messed up - it repents like trooper - now you posted it, - you fix it

23.01.2009 01:15 fxxx

edwinodus, what did you do to Igorad's indi (nonlagma) exept changing arrows to lines?

why did you cut -off author's name and copyright (header)?

22.12.2008 02:44 fxxx
08.12.2008 01:50 edwinodus

If you prefer a quicker response you can change the Length from 60 to 40, and see if it works better for you.

Ed

05.12.2008 20:36 edwinodus