get the color of the indicartor for using in expert

 

hi everybody

i wanna get the color of indicator while writing ea

for ex : the MACD histograms color are not relate to the amount of that same bar

so when the value is higher than zero , the histogram is red :|

how can i extract the color ?

GetObjectColor is not working here

thats nice of u if give me a sample code


tnx...

 
محسن برجی :

hi everybody

i wanna get the color of indicator while writing ea

for ex : the MACD histograms color are not relate to the amount of that same bar

so when the value is higher than zero , the histogram is red :|

how can i extract the color ?

GetObjectColor is not working here

thats nice of u if give me a sample code


tnx...

You cannot get color.

But you can get a number from the indicator buffer that stores the color.

 
Vladimir Karputov:

You cannot get color.

But you can get a number from the indicator buffer that stores the color.

i gtt buffer number with iCustom , but i couldnt findout that for which number of buffer ,bar is red and for what is green 
 
Mohsen Bjp :
i gtt buffer number with iCustom , but i couldnt findout that for which number of buffer ,bar is red and for what is green 

I will repeat once again: "You cannot get a color (red, green ...). You can get a digit from the color buffer (usually 0.0, 1.0 or 2.0).

 

Example: how to get the value and color of the 'iAO' indicator in an advisor


iAO Get Value and Color

Pic. 1. iAO Get Value and Color

As you can see, we cannot get the indicator color in the form "clrRed or clrGreen". We can only access the color buffer and get the color index (in the picture above it is '1' and '0').

 
iVladimir Karputov:

Example: how to get the value and color of the 'iAO' indicator in an advisor


Vladimir Karputov:

I will repeat once again: "You cannot get a color (red, green ...). You can get a digit from the color buffer (usually 0.0, 1.0 or 2.0).

Pic. 1. iAO Get Value and Color

As you can see, we cannot get the indicator color in the form "clrRed or clrGreen". We can only access the color buffer and get the color index (in the picture above it is '1' and '0').

i exactly understand what u say...but

what kind of function u used ? GetObjectInteger ? Plot indicator color ? or... this is my main issue

would you please send me a related code for Commentin (bar#0 : AO=X  COLOR0 &........... COLOR1)
 
Mohsen Bjp :

i exactly understand what u say...but

what kind of function u used ? GetObjectInteger ? Plot indicator color ? or... this is my main issue

would you please send me a related code for Commentin (bar#0 : AO=X  COLOR0 &........... COLOR1)

I gave you an example - see it before asking questions.

 
#resource "\\Indicators\\MACD Color.ex5"
//--- input parameters
input int      FastEMA=12;
input int      SlowEMA=26;
input int      SignSMA=9;
input ENUM_APPLIED_PRICE Price=PRICE_CLOSE;
//---
#define GREEN 0
#define RED 1
//---
int handle=INVALID_HANDLE;
double MACD[];
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   if((handle=iCustom(_Symbol,_Period,"::Indicators\\MACD Color.ex5",FastEMA,SlowEMA,SignSMA,Price))==INVALID_HANDLE)
      return(INIT_PARAMETERS_INCORRECT);
//---
   ArraySetAsSeries(MACD,true);
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   IndicatorRelease(handle);
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   static datetime preTime=0,curTime;
   if(preTime==(curTime=iTime(_Symbol,_Period,0)))
      return;
//---
   if(CopyBuffer(handle,1,0,2,MACD)!=2)
      return;
//---
   if(MACD[0]==GREEN && MACD[1]==RED)
     { 
      Print("Buy!");
      preTime=curTime;
     }     
   if(MACD[0]==RED && MACD[1]==GREEN)
     { 
      Print("Sell!");
      preTime=curTime;
     }   
  }
//+------------------------------------------------------------------+
Files:
Reason: