IndicatorCreate Not Set Color

 

Hi i try set color for create indicator but not set color

void OnStart()
  {

   MqlParam params[];
   int      handle;
   ArrayResize(params,5);

   //--- set ma_period
   params[0].type         =TYPE_INT;
   params[0].integer_value=20;
   //--- set ma_shift
   params[1].type         =TYPE_INT;
   params[1].integer_value=0;
   //--- set ma_method
   params[2].type         =TYPE_INT;
   params[2].integer_value=MODE_EMA;
   //--- set applied_price
   params[3].type         =TYPE_INT;
   params[3].integer_value=PRICE_CLOSE;
  
  

   //- I add this index params array for set color to indicator
  
   params[4].type         =TYPE_COLOR;
   params[4].integer_value=DodgerBlue;              

  

   handle = IndicatorCreate( Symbol() , PERIOD_CURRENT , IND_MA , 5 , params );
   ChartIndicatorAdd(0,0,handle);
          
  }

 

 
Ehsan Tavakoli:

Hi i try set color for create indicator but not set color

void OnStart()
  {

   MqlParam params[];
   int      handle;
   ArrayResize(params,5);

   //--- set ma_period
   params[0].type         =TYPE_INT;
   params[0].integer_value=20;
   //--- set ma_shift
   params[1].type         =TYPE_INT;
   params[1].integer_value=0;
   //--- set ma_method
   params[2].type         =TYPE_INT;
   params[2].integer_value=MODE_EMA;
   //--- set applied_price
   params[3].type         =TYPE_INT;
   params[3].integer_value=PRICE_CLOSE;
  
  

   //- I add this index params array for set color to indicator
  
   params[4].type         =TYPE_COLOR;
   params[4].integer_value=DodgerBlue;              

  

   handle = IndicatorCreate( Symbol() , PERIOD_CURRENT , IND_MA , 5 , params );
   ChartIndicatorAdd(0,0,handle);
          
  }

 

Make it as a parameter and then you shall be able to adjust the color too
 
Mladen Rakic:
Make it as a parameter and then you shall be able to adjust the color too

I did not understand what you mean 

how can i ? 

 
Mladen Rakic:
Make it as a parameter and then you shall be able to adjust the color too

i try that but still not work

             struct MqlParams : MqlParam
             {
               color color_value;      
             };


             MqlParams params[];
             ArrayResize(params,5);
             int handel;
            
            
             //--- set ma_period
             params[0].type         =TYPE_INT;
             params[0].integer_value=15;
             //--- set ma_shift
             params[1].type         =TYPE_INT;
             params[1].integer_value=0;
             //--- set ma_method
             params[2].type         =TYPE_INT;
             params[2].integer_value=MODE_EMA;
             //--- set applied_price
             params[3].type         =TYPE_INT;
             params[3].integer_value=PRICE_CLOSE;
             //--- set color  
             params[4].type         =TYPE_COLOR;
             params[4].color_value = RoyalBlue  ;              

          


             handel = IndicatorCreate( Symbol() , PERIOD_CURRENT , IND_MA , 5 , params );
             ChartIndicatorAdd(0,0,handel);
          

 what is my wrong ?

 

The colors are not indicator parameters. You need to change the indicator's code and add colors as parameters to do what you want.

Which is not possible with MA by the way, so you will have to create a custom MA (or modify an existing one with available source code).

 
Alain Verleyen:

The colors are not indicator parameters. You need to change the indicator's code and add colors as parameters to do what you want.

Which is not possible with MA by the way, so you will have to create a custom MA (or modify an existing one with available source code).

Hi Alian

I dont want change source cod .

I maked a button and i want add indicator on chart (with specified color and specified STYLE line) when i press the button

i have 2 way :

1 - use  changed cod

2 - use default indicator

Now i want us default indicator with iCustom or IndicatorCreate or iMA

you say i can not set the color and line style by IndicatorCreate

Can i set line color and line style by  iCustom or iMA ???

If i can ? How set color and line style ?

Please give me a sample if you can  

Tank you 

 
Alain Verleyen:

The colors are not indicator parameters. You need to change the indicator's code and add colors as parameters to do what you want.

Which is not possible with MA by the way, so you will have to create a custom MA (or modify an existing one with available source code).

I try this but not work

AddRem_MA_Handle=iCustom(Symbol(),PERIOD_CURRENT,"Examples\\Custom Moving Average",  15   ,  0  , MODE_EMA , PRICE_CLOSE , RoyalBlue );
ChartIndicatorAdd(0,0,AddRem_MA_Handle);    


 

 
Ehsan Tavakoli:

Hi Alian

My firstname is Alain and not Alian.


I dont want change source cod .

You NEED to change source code if you want change colors from IndicatorCreate or iCustom.
 
Alain Verleyen:
My firstname is Alain and not Alian.
Sorry . you are right
 
You NEED to change source code if you want change colors from IndicatorCreate or iCustom.
And i cant do that with iMA too ?
 
Ehsan Tavakoli:
And i cant do that with iMA ?

No


Reason: