[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 314

 
I don't quite get it? When I draw the Kon indicator in the window, it works fine. Explain...
 
kon12 >> :
I don't quite understand? When I draw Kon indicator in window, it works fine. Explain...

when you draw in the window, you have either olive or green histogram bars. with the former corresponding to the up buffer and the latter to the dn. if only dn is drawn on bar 0, and you access the indicator iCustom(0,0, "Kon",10,0,0), i.e. the mode parameter is 0 (look at your 0 is up - SetIndexBuffer(0,up);), then the result of the function call will most probably be EMPTY_VALUE.


Is it clearer?

 

Tried changing the buffer number to both 1 and 2 - no help

 

check if the "Kon" string in the iCast call matches the mq4 file name, including character case

and what value does the function output anyway?

 

The question is quite simple. I am trying to refer to the OsMA indicator, which is in the standard set of custom indicators. I want to simply draw a line of this indicator in the indicators window. The OsMA indicator has parameters 12,26,9 and is drawn on buffer 0. What is wrong in the code? The 0 line is drawn in the indicator window and that's it.

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_level1 0.0
#property indicator_color1 Olive

double z;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   SetIndexBuffer(0, z);
   SetIndexStyle(0,DRAW_HISTOGRAM);
    return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  { z= iCustom(NULL,0,"OsMA",12,26,9,0,0); 
  //----
   return(0);
  }
 
kon12 >> :

The question is quite simple. I'm trying to use the OsMA function which is in the standard set of custom indicators. I want to simply draw a line of this indicator in the indicators window. The OsMA indicator has parameters 12,26,9 and is drawn using buffer 0. What is wrong in the code? The 0 line is drawn in the indicator window and that's it.

No, it does not work that way.

The z is an array and data should be written into it element by element. For example:

for(i=100;i>=0;i--)

{

z[i]= iCustom(NULL,0,"OsMA",12,26,9,0,i);

}

 
Yay, it worked! Thanks for your help, the first steps are the hardest...
 

Another question on my subject. Suppose I draw a curve on the chart, e.g. MA. Then I use a custom indicator that uses this MA through iCustom function. Can we connect them in such a way that MA period in the chart is automatically changed when the МА period in the custom indicator is changed?

 

Can you advise me, I am working on a daily schedule.

And I want to access the minutes data. Is it updated or is it old data?

 

Question - how does this work (Indicator optimisation):


if( MA_Fast[ i+1]> MA_Slow[ i+1]) {
   string RectangleSell = StringConcatenate("RECTANGLE_", StartBoxTime);
   ObjectDelete( RectangleSell);
   ObjectCreate( RectangleSell, OBJ_RECTANGLE, 0,  StartBoxTime, BoxLow,  EndBoxTime, BoxHigh);
   ObjectSet( RectangleSell, OBJPROP_STYLE, STYLE_SOLID);
   ObjectSet( RectangleSell, OBJPROP_RAY, False);
   ObjectSet( RectangleSell, OBJPROP_WIDTH, 1);
   ObjectSet( RectangleSell, OBJPROP_BACK , True);
   ObjectSet( RectangleSell, OBJPROP_COLOR, ColorSell);
}


Do I understand correctly that with every new tick the same rectangle

(the same size with equal number of bars) will be deleted and redrawn?

Is it worth adding a check for the number of bars (if there are more bars, only then redraw)?

to relieve the computer's CPU or will the gain be minimal and not worth bothering with it?

Reason: