RWI mt4 ----> lua

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

RWI mt4 ----> lua

Postby boursicoton » Wed May 26, 2010 12:42 pm

Code: Select all
#property  copyright "Ramdass"
//----
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Green
#property indicator_color2 Red
#property indicator_width1 2
#property indicator_width2 2
#property indicator_level1 1
//---- buffers
double RWI_High[];
double RWI_Low[];
//----
int RWI_Period = 64; 
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicator line
   IndicatorBuffers(2);
   SetIndexStyle(0, DRAW_LINE);
   SetIndexBuffer(0, RWI_High);
   SetIndexStyle(1, DRAW_LINE);
   SetIndexBuffer(1, RWI_Low);
//----
   IndicatorShortName("RWI");
   SetIndexLabel(0, "RWI_High");
   SetIndexLabel(1, "RWI_Low"); 
//----
   SetIndexDrawBegin(0, RWI_Period + 1);
   SetIndexDrawBegin(1, RWI_Period + 1);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| RWI                                                              |
//+------------------------------------------------------------------+
int start()
  {
   int i,j;
   double max_1,max_2,max_High,max_Low,atr,sqrt;
//----
   if(Bars <= RWI_Period)
       return(0);
   int limit = Bars - IndicatorCounted();
//----
   for(i = 0; i < limit; i++)
     {
       max_High=0.0; max_Low=0.0;
       for(j = 1; j <= RWI_Period; j++)
         {
           sqrt = MathSqrt(j + 1);
           atr = iATR(NULL, 0, j + 1, i + 1);
           if(atr != 0.0)
             {
               max_1 = (High[i] - Low[i+j]) / (atr / sqrt);   // RWI_High Index
               max_2 = (High[i+j] - Low[i]) / (atr / sqrt);   // RWI_Low Index
               if(max_1 > max_High)
                   max_High = max_1;  // Maximum_RWI_High Index
               if(max_2 > max_Low)
                   max_Low = max_2;   // Maximum_RWI_Low Index
             }
         }
       RWI_High[i] = max_High;
       RWI_Low[i] = max_Low;
     } 
//----
   return(0);
  }
//+------------------------------------------------------------------+


rwi modified....possible ?
boursicoton
FXCodeBase: Confirmed User
 
Posts: 78
Joined: Sat Feb 06, 2010 1:33 pm

Re: RWI mt4 ----> lua

Postby Apprentice » Wed May 26, 2010 2:54 pm

An interesting task, this time tomorrow you will have this indicator.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36437
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: RWI mt4 ----> lua

Postby boursicoton » Wed May 26, 2010 3:34 pm

the original take * sqrt....but i try /sqrt and i think that signal is very better.
two parameters ? * or /....
thanks for your work ! lua isn't easy for me.
boursicoton
FXCodeBase: Confirmed User
 
Posts: 78
Joined: Sat Feb 06, 2010 1:33 pm

Re: RWI mt4 ----> lua

Postby Apprentice » Thu May 27, 2010 5:51 am

RWI indicator can be found here.
http://fxcodebase.com/code/viewtopic.php?f=17&t=1166#p2217

As far as additional option.
I can send you an indicator with this option.

Soon I will write the corresponding signal.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36437
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia


Return to Indicator and Signal Requests

Who is online

Users browsing this forum: No registered users and 32 guests