Ho to apply a Custom indicator over another Custom indicator
Ziobrekka: I'm tryng to apply a moving average to another moving average. But I want to apply the second average (yellow/blue) to the first one average (red);
| No you are not. You are trying to apply it to a custom indicator that has 3 buffers, not one. Can't be done. You'll have to make a new indicator
|
whroeder1:
No you are not. You are trying to apply it to a custom indicator that has 3 buffers, not one. Can't be done. You'll have to make a new indicator
|
thanks whroeder1 , I dit it the wrong way
I try to build a new indicator following your guidelines
Hi everyone,
I'm brand new with MQL4, I'm tryng to apply a moving average to another moving average.
I'm able to call my two custom averages into MT4 e to plot them.
But I want to apply the second average (yellow/blue) to the first one average (red); instead all I can do is to apply them to price (see the image attached below).
How can I accomplish this?
Thanks
//| |
//| Copyright © 2004, MetaQuotes Software Corp. |
//| http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2017, ZioBrekka "
#property link "http://www.metaquotes.net/"
#property strict
#property indicator_chart_window
//
#property indicator_buffers 3
#property indicator_color1 Red
#property indicator_color2 Blue
#property indicator_color3 Yellow
//
string indName="ZioBrekka";
//---- buffers
double val1[];
double val2[];
double val3[];
//--- Zero Divide Fix
int FixZeroD=0;
int init()
{
IndicatorBuffers(3);
//---- drawing settings
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2);
SetIndexBuffer(0,val1);
SetIndexLabel(0,"val1");
SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,2);
SetIndexBuffer(1,val2);
SetIndexLabel(1,"val2");
SetIndexStyle(2,DRAW_LINE,STYLE_SOLID,2);
SetIndexBuffer(2,val3);
SetIndexLabel(2,"val3");
//---- initialization done
return(0);
}
int deinit()
{
//----
Comment("");
//----
return(0);
}
int start()
{
int i,Counted_bars;
//--------------------------------------------------------------------
Counted_bars=IndicatorCounted();
i=Bars-Counted_bars-1;
if(Counted_bars == 0)
i = Bars -1 -FixZeroD;
double sum=0;
while(i>=0)
{
//Main Calculation;
val1[i]=iCustom(NULL,0,"AVERAGE1_RED",9,0,i);
val2[i]=iCustom(NULL,0,"AVERAGE2_BLUE",13,0,i);
val3[i]=iCustom(NULL,0,"AVERAGE3_YELLOW",13,1,i);
i--;
}
//--------------------------------------------------------------------
return(0);
}
//--------------------------------------------------------------------