Indicators: Three Colors

 

Three Colors:

Example: Moving Average indicator filling by different colors

Author: MetaQuotes Software Corp.

 

what is the defination of the colour??

 
This code doesnt work anymore as i understand it. You are now required to use Icustom.
 
kervin:
This code doesnt work anymore as i understand it. You are now required to use Icustom.

shakeel353:

what is the defination of the colour??

what is the defination of the colour??
 

if not work edit code below:

 }
//+------------------------------------------------------------------+yle(0,DRAW_LINE,STYLE_SOLID,width);
   //SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,width);
  // SetIndexStyle(2,DRAW_LINE,STYLE_SOLID,width);
  // Comment("Width = ", width);
//----
 //  return(0);
//  }
//+------------------------------------------------------------------+
 

Code that works again :)

// + ----------------------------------------------- ---- ------------------- +

// | three_color.mq4 |
// | Copyright © 2005, MetaQuotes Software Corp. |
// | http://www.metaquotes.net/ |
// + ----------------------------------------------- ------------------- +
#property copyright "Copyright © 2005, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net/"

#property indic_chart_window
#property indic_buffers 3
#property warning_color1 Red
#property warning_color2 Green
#property warning_color3 Blue
// ---- bumpers
double ExtMapBuffer1 [];
double ExtMapBuffer2 [];
double ExtMapBuffer3 [];
// + ----------------------------------------------- ------------------- +
// | Special display start function |
// + ----------------------------------------------- ------------------- +
int init ()
{
SetIndexBuffer (0, ExtMapBuffer1);
SetIndexBuffer (1, ExtMapBuffer2);
SetIndexBuffer (2, ExtMapBuffer3);
// ----
Rotation (0);
}
// + ----------------------------------------------- ------------------- +
// | Custom Indicator Repeat Function |
// + ----------------------------------------------- ------------------- +
int start ()
{
int i, j, shift;
static int width = 2;
// ----
(i = 0; i <Bar-21; i + = 30)
{
(j = 0, shift = i; j <11; j ++, shift ++)
{
ExtMapBuffer1 [scroll] = IMA (NULL, 0.50, MODE_SMA, 0, PRICE_CLOSE, transition);
if (j> 0 && j <10)
{
ExtMapBuffer2 [scroll] = EMPTY_VALUE ;
ExtMapBuffer3 [scroll] = EMPTY_VALUE;
}
}
}
// ----
(i = 10; i <Bar-11; i + = 30)
{
(j = 0, shift = i; j <11; j ++, shift ++)
{
ExtMapBuffer2 [scroll] = IMA (NULL, 0.50, MODE_SMA, 0, PRICE_CLOSE, transition);
if (j> 0 && j <10)
{
ExtMapBuffer1 [scroll] = EMPTY_VALUE;
ExtMapBuffer3 [scroll] = EMPTY_VALUE;
}
}
}
// ----
(i = 20; i <Bar-1; i + = 30)
{
(j = 0, shift = i; j <11; j ++, shift ++)
{
ExtMapBuffer3 [scroll] = IMA (NULL, 0.50, MODE_SMA, 0, PRICE_CLOSE, transition);
if (j> 0 && j <10)
{
ExtMapBuffer1 [scroll] = EMPTY_VALUE;
ExtMapBuffer2 [scroll] = EMPTY_VALUE;
}
}
}
// ----
// if (width> 10) width = 1;
// other width ++;
SetIndexStyle (0, DRAW_LINE, STYLE_SOLID, width);
SetIndexStyle (1, DRAW_LINE, STYLE_SOLID, width);
SetIndexStyle (2, DRAW_LINE, STYLE_SOLID, width);
// ----
Rotation (0);
}

 

This is one of the most useless things I have ever seen in my life.

The colors do not have any meaning. 

If you look into the code you will see that the color switches after 10 candles.

 
Matze2886 :

This is one of the most useless things I have ever seen in my life.

The colors do not have any meaning. 

If you look into the code you will see that the color switches after 10 candles.

This is a tutorial example - an example of how to recolor areas of an indicator. It is on these examples that novice programmers learn.

 

Is it possible to use only single data buffer array and maybe have a parallel color buffer array with which to color indicator ...

Maintaining separate data buffers causes logical and tactical problem since buy/sell conditions are to be generated off comparing adjacent values of data buffer

and signal generation need not be aligned with color. 

No other trading related programming language has syntax that requires programmers to maintain two data arrays just to be able to render different colors on screen. 

 
VERY USEFULL