TrendMagic indicator

If you need an Indicator or Signal developed or translated from other language, please post all Indicator development REQUESTS to this section here.

Moderator: admin

TrendMagic indicator

Postby WWMMACAU » Tue Mar 30, 2010 12:36 pm

Hi somebody can help to create lua file for MT4TrendMagic indicator.
Thanks.

Code: Select all
//+------------------------------------------------------------------+
//|                                                   TrendMagic.mq4 |
//|                              Tidied up by TudorGirl  28 May 2009 |
//|                                              AnneTudor@ymail.com |
//+------------------------------------------------------------------+

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_width1 5
#property indicator_color2 Red
#property indicator_width2 5

//+------------------------------------------------------------------+

extern int CCI = 50;
extern int ATR = 5;

//+------------------------------------------------------------------+

double bufferUp[];
double bufferDn[];

//+------------------------------------------------------------------+

int init()
{
   SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 2);
   SetIndexBuffer(0, bufferUp);
   SetIndexStyle(1, DRAW_LINE, STYLE_SOLID, 2);
   SetIndexBuffer(1, bufferDn);
   return (0);
}

//+------------------------------------------------------------------+

int deinit()
{
   return (0);
}

//+------------------------------------------------------------------+

int start()
{
   double thisCCI;
   double lastCCI;

   int counted_bars = IndicatorCounted();
   if (counted_bars < 0) return (-1);
   if (counted_bars > 0) counted_bars--;
   int limit = Bars - counted_bars;

   for (int shift = limit; shift >= 0; shift--)
   {
      thisCCI = iCCI(NULL, 0, CCI, PRICE_TYPICAL, shift);
      lastCCI = iCCI(NULL, 0, CCI, PRICE_TYPICAL, shift + 1);

      if (thisCCI >= 0 && lastCCI < 0) bufferUp[shift + 1] = bufferDn[shift + 1];
      if (thisCCI <= 0 && lastCCI > 0) bufferDn[shift + 1] = bufferUp[shift + 1];

      if (thisCCI >= 0)
      {
         bufferUp[shift] = Low[shift] - iATR(NULL, 0, ATR, shift);
         if (bufferUp[shift] < bufferUp[shift + 1])
            bufferUp[shift] = bufferUp[shift + 1];
      }
      else
      {
         if (thisCCI <= 0)
         {
            bufferDn[shift] = High[shift] + iATR(NULL, 0, ATR, shift);
            if (bufferDn[shift] > bufferDn[shift + 1])
               bufferDn[shift] = bufferDn[shift + 1];
         }
      }
   }

   return (0);
}

//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
WWMMACAU
 
Posts: 23
Joined: Mon Mar 22, 2010 4:12 am

Re: TrendMagic indicator

Postby Alexander.Gettinger » Sun Apr 04, 2010 9:31 pm

Alexander.Gettinger
FXCodeBase: Confirmed User
 
Posts: 3785
Joined: Wed Mar 31, 2010 9:40 pm
Location: Russia, Omsk


Return to Indicator and Signal Requests

Who is online

Users browsing this forum: No registered users and 16 guests