Custom indicator based on another indicator values

 

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

 
in this century everything is possible
 

  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.
 

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

 
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.
 
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

 
#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

 
use iCustom
 
#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

 
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)))));