Download MetaTrader 5
To add comments, please log in or register
Sign up for MQL5.community to post your Forum topic
franko
53
franko 2014.03.25 12:29 

Hello,

Would like to know is it possible to make custom indicator based on these calculations:

Buf_0[i]=(((iADX("EURUSD",PERIOD_M1,28,PRICE_CLOSE,MODE_PLUSDI,(i-5)))-(iADX("EURUSD",PERIOD_M1,28,PRICE_CLOSE,MODE_MINUSDI,(i-5))))-((iADX("EURUSD",PERIOD_M1,28,PRICE_CLOSE,MODE_PLUSDI,i))-(iADX("EURUSD",PERIOD_M1,28,PRICE_CLOSE,MODE_MINUSDI,i))))

Buf_1[i]=(((iADX("EURGBP",PERIOD_M1,28,PRICE_CLOSE,MODE_PLUSDI,(i-5)))-(iADX("EURGBP",PERIOD_M1,28,PRICE_CLOSE,MODE_MINUSDI,(i-5))))-((iADX("EURGBP",PERIOD_M1,28,PRICE_CLOSE,MODE_PLUSDI,i))-(iADX("EURGBP",PERIOD_M1,28,PRICE_CLOSE,MODE_MINUSDI,i))))

Buf_2[i]=(((iADX("EURAUD",PERIOD_M1,28,PRICE_CLOSE,MODE_PLUSDI,(i-5)))-(iADX("EURAUD",PERIOD_M1,28,PRICE_CLOSE,MODE_MINUSDI,(i-5))))-((iADX("EURAUD",PERIOD_M1,28,PRICE_CLOSE,MODE_PLUSDI,i))-(iADX("EURAUD",PERIOD_M1,28,PRICE_CLOSE,MODE_MINUSDI,i))))

Buf_3[i]=(((iADX("EURCAD",PERIOD_M1,28,PRICE_CLOSE,MODE_PLUSDI,(i-5)))-(iADX("EURCAD",PERIOD_M1,28,PRICE_CLOSE,MODE_MINUSDI,(i-5))))-((iADX("EURCAD",PERIOD_M1,28,PRICE_CLOSE,MODE_PLUSDI,i))-(iADX("EURCAD",PERIOD_M1,28,PRICE_CLOSE,MODE_MINUSDI,i))))


Best regards,

Roberts

qjol
3243
qjol 2014.03.25 12:39  
in this century everything is possible
whroeder1
13644
whroeder1 2014.03.25 13:25  

  1. Play video
    Please edit your post.
    For large amounts of code, attach it.

  2. You probably mean i+5 not i-5, you can't see the future.
Tjipke de Vries
6283
Tjipke de Vries 2014.03.25 13:28  

A problem might be also

time bar5 EurCad is not time5 other currency

and number of bars one currency is different number of bars other currency

on 1 minute it can happen easily some missing bars

franko
53
franko 2014.03.25 14:56  
WHRoeder:

  1. Play video
    Please edit your post.
    For large amounts of code, attach it.

  2. You probably mean i+5 not i-5, you can't see the future.

sry, 5 bars ago.
franko
53
franko 2014.03.25 15:03  
deVries:

A problem might be also

time bar5 EurCad is not time5 other currency

and number of bars one currency is different number of bars other currency

on 1 minute it can happen easily some missing bars


Maybe someone already have tried to make custom indicator based on another indicator values?

Can someone help in solving this?


Best regards,

Roberts

franko
53
franko 2014.03.25 15:14  
#property indicator_separate_window   // Indicator is drawn in the main window
#property indicator_buffers 4       // Number of buffers
#property indicator_color1 Red     // Color of the 1st line
#property indicator_color2 Green      // Color of the 2nd line
#property indicator_color3 Blue     // Color of the 1st line
#property indicator_color4 Purple      // Color of the 2nd line

 
double Buf_0[];Buf_1[];Buf_2[];Buf_3[];             // Declaring arrays (for indicator buffers)

int init()                          // Special function init()
  {
   SetIndexBuffer(0,Buf_0);         // Assigning an array to a buffer
   SetIndexStyle (0,DRAW_LINE,STYLE_SOLID,1);// Line style
    SetIndexBuffer(1,Buf_1);         // Assigning an array to a buffer
   SetIndexStyle (1,DRAW_LINE,STYLE_SOLID,1);// Line style
    SetIndexBuffer(2,Buf_2);         // Assigning an array to a buffer
   SetIndexStyle (2,DRAW_LINE,STYLE_SOLID,1);// Line style
    SetIndexBuffer(3,Buf_3);         // Assigning an array to a buffer
   SetIndexStyle (3,DRAW_LINE,STYLE_SOLID,1);// Line style

   return;                          // Exit the special funct. init()
  }
  
  
int start()                         // Special function start()
  {
   int i,                           // Bar index
       Counted_bars;                // Number of counted bars
//--------------------------------------------------------------------
   Counted_bars=IndicatorCounted(); // Number of counted bars
   i=Bars-Counted_bars-1;           // Index of the first uncounted
   while(i>=0)                      // Loop for uncounted bars
     
     {
      Buf_0[i]=(((iADX("EURUSD",PERIOD_M1,28,PRICE_CLOSE,MODE_PLUSDI,(i+5)))-(iADX("EURUSD",PERIOD_M1,28,PRICE_CLOSE,MODE_MINUSDI,(i+5))))-((iADX("EURUSD",PERIOD_M1,28,PRICE_CLOSE,MODE_PLUSDI,i))-(iADX("EURUSD",PERIOD_M1,28,PRICE_CLOSE,MODE_MINUSDI,i))))

      Buf_1[i]=(((iADX("EURGBP",PERIOD_M1,28,PRICE_CLOSE,MODE_PLUSDI,(i+5)))-(iADX("EURGBP",PERIOD_M1,28,PRICE_CLOSE,MODE_MINUSDI,(i+5))))-((iADX("EURGBP",PERIOD_M1,28,PRICE_CLOSE,MODE_PLUSDI,i))-(iADX("EURGBP",PERIOD_M1,28,PRICE_CLOSE,MODE_MINUSDI,i))))

      Buf_2[i]=(((iADX("EURAUD",PERIOD_M1,28,PRICE_CLOSE,MODE_PLUSDI,(i+5)))-(iADX("EURAUD",PERIOD_M1,28,PRICE_CLOSE,MODE_MINUSDI,(i+5))))-((iADX("EURAUD",PERIOD_M1,28,PRICE_CLOSE,MODE_PLUSDI,i))-(iADX("EURAUD",PERIOD_M1,28,PRICE_CLOSE,MODE_MINUSDI,i))))

      Buf_3[i]=(((iADX("EURCAD",PERIOD_M1,28,PRICE_CLOSE,MODE_PLUSDI,(i+5)))-(iADX("EURCAD",PERIOD_M1,28,PRICE_CLOSE,MODE_MINUSDI,(i+5))))-((iADX("EURCAD",PERIOD_M1,28,PRICE_CLOSE,MODE_PLUSDI,i))-(iADX("EURCAD",PERIOD_M1,28,PRICE_CLOSE,MODE_MINUSDI,i))))
      
    
     }
       return;                          // Exit the special funct. start()
  }



Here is the code:

how would you figure it?


Best regards,

Roberts

qjol
3243
qjol 2014.03.25 16:02  
use iCustom
franko
53
franko 2014.03.25 17:02  
#property indicator_separate_window   // Indicator is drawn in the main window
#property indicator_buffers 4       // Number of buffers
#property indicator_color1 Red     // Color of the 1st line
#property indicator_color2 Green      // Color of the 2nd line
#property indicator_color3 Blue     // Color of the 1st line
#property indicator_color4 Purple      // Color of the 2nd line

 
double Buf_0[],Buf_1[],Buf_2[],Buf_3[];             // Declaring arrays (for indicator buffers)

int init()                          // Special function init()
  {
   SetIndexBuffer(0,Buf_0);         // Assigning an array to a buffer
   SetIndexStyle (0,DRAW_LINE,STYLE_SOLID,1);// Line style
    SetIndexBuffer(1,Buf_1);         // Assigning an array to a buffer
   SetIndexStyle (1,DRAW_LINE,STYLE_SOLID,1);// Line style
    SetIndexBuffer(2,Buf_2);         // Assigning an array to a buffer
   SetIndexStyle (2,DRAW_LINE,STYLE_SOLID,1);// Line style
    SetIndexBuffer(3,Buf_3);         // Assigning an array to a buffer
   SetIndexStyle (3,DRAW_LINE,STYLE_SOLID,1);// Line style

   return;                          // Exit the special funct. init()
  }
  
  
int start()                         // Special function start()
  {
   int i,                           // Bar index
       Counted_bars;                // Number of counted bars
//--------------------------------------------------------------------
   Counted_bars=IndicatorCounted(); // Number of counted bars
   i=Bars-Counted_bars-1;           // Index of the first uncounted
   if(i>=0)                      // Loop for uncounted bars
     
     {
      Buf_0[i]=(((iADX("EURUSD",PERIOD_M1,28,PRICE_CLOSE,MODE_MAIN,(i+5)))-(iADX("EURUSD",PERIOD_M1,28,PRICE_CLOSE,MODE_MAIN,(i)))))
      Buf_1[i]=(((iADX("EURUSD",PERIOD_M1,28,PRICE_CLOSE,MODE_MAIN,(i+5)))-(iADX("EURUSD",PERIOD_M1,28,PRICE_CLOSE,MODE_MAIN,(i)))))
      Buf_2[i]=(((iADX("EURUSD",PERIOD_M1,28,PRICE_CLOSE,MODE_MAIN,(i+5)))-(iADX("EURUSD",PERIOD_M1,28,PRICE_CLOSE,MODE_MAIN,(i)))))
      Buf_3[i]=(((iADX("EURUSD",PERIOD_M1,28,PRICE_CLOSE,MODE_MAIN,(i+5)))-(iADX("EURUSD",PERIOD_M1,28,PRICE_CLOSE,MODE_MAIN,(i)))))
     
    
     }
       return;                          // Exit the special funct. start()
  }

When I changed the code only with Buf_0 everything worked fine, but with Buf_1, Buf_2, Buf_3 at compile it shows Buf_1 -some operator expected, Buf_2 -some operator expected, Buf_3 -some operator expected. Why is that?


Best regards,

Roberts

Alain Verleyen
Moderator
28672
Alain Verleyen 2014.03.25 17:09  
Franko:

When I changed the code only with Buf_0 everything worked fine, but with Buf_1, Buf_2, Buf_3 at compile it shows Buf_1 -some operator expected, Buf_2 -some operator expected, Buf_3 -some operator expected. Why is that?


Best regards,

Roberts


      Buf_0[i]=(((iADX("EURUSD",PERIOD_M1,28,PRICE_CLOSE,MODE_MAIN,(i+5)))-(iADX("EURUSD",PERIOD_M1,28,PRICE_CLOSE,MODE_MAIN,(i)))));
      Buf_1[i]=(((iADX("EURUSD",PERIOD_M1,28,PRICE_CLOSE,MODE_MAIN,(i+5)))-(iADX("EURUSD",PERIOD_M1,28,PRICE_CLOSE,MODE_MAIN,(i)))));
      Buf_2[i]=(((iADX("EURUSD",PERIOD_M1,28,PRICE_CLOSE,MODE_MAIN,(i+5)))-(iADX("EURUSD",PERIOD_M1,28,PRICE_CLOSE,MODE_MAIN,(i)))));
      Buf_3[i]=(((iADX("EURUSD",PERIOD_M1,28,PRICE_CLOSE,MODE_MAIN,(i+5)))-(iADX("EURUSD",PERIOD_M1,28,PRICE_CLOSE,MODE_MAIN,(i)))));
/
To add comments, please log in or register