Download MetaTrader 5

the difference of task for computer when Indicator and function do the same work

To add comments, please log in or register
Fa Cao
1141
Fa Cao  

for example, now I have made an Indicator "x_y" and an function "x_y", and they make all most the same work---draw two lines, one connect all the low points, the other connect all the high points, and of course some of the points should be use in function start().

for Indicator x_y, I should use iCustom() to get the points ;

for the function x_y, I just use global variable to get.

then I don;t know whether they are very different for computer's computing task for this by the two different way.

whroeder1
15598
whroeder1  
vx0532: I don;t know whether they are very different

Do you really expect us to know? There are no mind readers here. We can't see your code. Did you post the indicator code, the iCustom code, the function code and call?

For someone that has posted 120 messages on this forum - your post is ridiculous.

Alain Verleyen
Moderator
32524
Alain Verleyen  
vx0532:

for example, now I have made an Indicator "x_y" and an function "x_y", and they make all most the same work---draw two lines, one connect all the low points, the other connect all the high points, and of course some of the points should be use in function start().

for Indicator x_y, I should use iCustom() to get the points ;

for the function x_y, I just use global variable to get.

then I don;t know whether they are very different for computer's computing task for this by the two different way.

Why not test it and let us know the result ?
Fa Cao
1141
Fa Cao  
angevoyageur:
Why not test it and let us know the result ?


in the fact, I ask this question just because I have to complete a function(), and I am considering which method should I use, by indicator or function().

I heard that indicator occupied much RAM and processor.

whatever I have made the indicator, and when I test it in EA(import by iCumstom()), I find it is very slow; so now I have trying to write function code to complete it.

My indicator code is as below:

#property copyright "Copyright 2013, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Yellow // High Points Array Line
#property indicator_color2 Red    // Low Points Array Line

extern int Seek_Period=20,Mini_Swing=200,Trade_Range=20; // these 3 parameters should be offered by iCustom();

double Bar_High[],Bar_Low[],HL_Latest[2]; // high point bars array, low point bars array, array contains the latest high and low point bars
double H_L[2];                               // save time according to Bar_High[] and Bar_Low[] array, these two array get one value more,  


int init()
  {
  IndicatorShortName("High_Low_Two_Lines");
  IndicatorBuffers(4);
  SetIndexBuffer(0,Bar_High);
  SetIndexStyle(0,DRAW_LINE);
  SetIndexLabel(0,"High Point Line");
  SetIndexDrawBegin(0,0);
  SetIndexBuffer(1,Bar_Low);
  SetIndexStyle(1,DRAW_LINE);
  SetIndexLabel(1,"Low Point Line");
  SetIndexDrawBegin(1,0);
  SetIndexBuffer(2,HL_Latest);
  SetIndexBuffer(3,H_L);
  return(0);
  }

int deinit()
  {
   return(0);
  }

int start()
  {
   int    counted_bars=IndicatorCounted();
   
   int i=Seek_Period,i_0;
   HL_Latest[0]=0.0;
   HL_Latest[1]=0.0;
   while(i>6)
   {
     i_0=iHighest(NULL,0,MODE_HIGH,i,3); // set 3 to ensure left trade
     if(i_0>=5&&iHighest(NULL,0,MODE_HIGH,i_0+5,i_0)<High[i_0]) // left conditions
     if(iHighest(NULL,0,MODE_HIGH,i_0,i_0-5)<High[i_0]&&High[i_0]-iLowest(NULL,0,MODE_LOW,i_0,3)>=Mini_Swing) // right conditions 
     if(Close[0]>=High[i_0]-Trade_Range*Point/3&&Close[0]<=High[i_0]+Trade_Range*Point)    // touch trading ranges
     if(Close[0]<Low[1]&&iHighest(NULL,0,MODE_HIGH,3,0)<High[i_0]+(Trade_Range+5)*Point)   //triger trading
     { 
        H_L[0]=i_0;
        HL_Latest[0]=High[i_0];
        if(Bar_High[0]!=High[i_0]) Bar_High[0]=High[i_0];  //a new High bar coming  
        break;
     }
         
     i_0=iLowest(NULL,0,MODE_LOW,i,3); // set 3 to ensure left trade
     if(i_0>=5&&iLowest(NULL,0,MODE_LOW,i_0+5,i_0)>Low[i_0]) // left conditions
     if(iLowest(NULL,0,MODE_LOW,i_0,i_0-5)>Low[i_0]&&iHighest(NULL,0,MODE_HIGH,i_0,3)-Low[i_0]>=Mini_Swing) // right conditions 
     if(Close[0]<=Low[i_0]+Trade_Range*Point/2&&Close[0]>=Low[i_0]-Trade_Range*Point)      // touch trading ranges
     if(Close[0]>High[1]&&iLowest(NULL,0,MODE_LOW,3,0)>Low[i_0]-(Trade_Range+5)*Point)     //triger trading
     { 
        H_L[1]=i_0;
        HL_Latest[1]=Low[i_0];
        if(Bar_High[1]!=Low[i_0]) Bar_Low[1]=High[i_0]; //a new High bar coming
        break;
     }           
     i--;
   }
   return(0);
  }
Simon Gniadkowski
Moderator
18024
Simon Gniadkowski  
vx0532:


in the fact, I ask this question just because I have to complete a function(), and I am considering which method should I use, by indicator or function().

I heard that indicator occupied much RAM and processor.

whatever I have made the indicator, and when I test it in EA(import by iCumstom()), I find it is very slow; so now I have trying to write function code to complete it.

My indicator code is as below:

Your code makes no sense . . . take this example:

if(  iHighest(NULL,0,MODE_HIGH,i_0,i_0-5) < High[i_0] && High[i_0] - iLowest(NULL,0,MODE_LOW,i_0,3) >= Mini_Swing) // right conditions 

iHighest() returns a bar number, High[] is a price array, how does it make sense to compare a bar number to a price ? and then you subtract a bar number ( iLowest() ) from a price ( High[] ) ?

To add comments, please log in or register