CAn some body help me to change a color of one line my indicator

 
#include <stdlib.mqh>

//+------------------------------------------------------------------+
//|                                              Doda-Stochastic.mq4 |
//|                             Copyright © 2010, Gopal Krishan Doda |
//|                                        http://www.DodaCharts.com |
//|                                     http://www.InvestmentKit.com |
//|This is version 1.0 of Doda-Stochastic indicator                  |
//|Last Modified on 08-Mar-2011                                      |
//| I'm not the original coder. Just modified for screen alert.      |
//+------------------------------------------------------------------+


// This was converted using YouSky's MT3 to MT4 translator.  I cannot take credit for the code.//

#property indicator_separate_window
#property indicator_minimum 0.00
#property indicator_maximum 100.00
#property indicator_color1 Lime
#property indicator_buffers 2
#property indicator_color2 Red
#property indicator_width1 2
#property indicator_width2 1
//#property indicator_level1 20
//#property indicator_level2 50
//#property indicator_level3 80

//+------------------------------------------------------------------+
//| Common External variables                                        |
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
//| External variables                                               |
//+------------------------------------------------------------------+
extern double Slw = 2;  //8  5
extern double Pds = 21; //13  21
extern double Slwsignal = 2; //9  5
extern int    Barcount = 2000;
bool Alertx = false;

//+------------------------------------------------------------------+
//| Special Convertion Functions                                     |
//+------------------------------------------------------------------+

int LastTradeTime;
double ExtHistoBuffer[];
double ExtHistoBuffer2[];
bool BuyAlert=false, SellAlert=false;

void SetLoopCount(int loops)
{
}

void SetIndexValue(int shift, double value)
{
  ExtHistoBuffer[shift] = value;
//  Print ("ExtHistoBuffer :" ,value);    // green
}

void SetIndexValue2(int shift, double value)
{
  ExtHistoBuffer2[shift] = value;
//  Print ("ExtHistoBuffer2 :" ,value);    // green
}

double GetIndexValue(int shift)
{
  return(ExtHistoBuffer[shift]);
}

double GetIndexValue2(int shift)
{
  return(ExtHistoBuffer2[shift]);
}

//+------------------------------------------------------------------+
//| End                                                              |
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
//| Initialization                                                   |
//+------------------------------------------------------------------+

int init()
{
   //SetIndexStyle(0, DRAW_LINE, STYLE_SOLID);
   SetIndexBuffer(0, ExtHistoBuffer);

   //SetIndexStyle(1, DRAW_LINE, STYLE_SOLID);
   SetIndexBuffer(1, ExtHistoBuffer2);

   
    
   return(0);
}
int start()
{
//+------------------------------------------------------------------+
//| Local variables                                                  |
//+------------------------------------------------------------------+
double AA = 0;
double bb = 0;
double aa1 = 0;
double cnt1 = 0;
int shift = 0;
double cnt = 0;
double loopbegin = 0;
double loopbegin2 = 0;
double loopbegin3 = 0;
bool first = True;
double prevbars = 0;
double sum = 0;
double smconst = 0;
double smconst1 = 0;
double prev = 0;
double prev1 = 0;
double prev2 = 0;
double prev3 = 0;
double weight = 0;
double linear = 0;
double MAValue = 0;
double MAValue2 = 0;
double mavalue3 = 0;
string MAstring = "";
double MyHigh = 0;
double MyLow = 0;
int counter = 0;
double Price = 0;
double Price1 = 0;
double tmpDevAA = 0;

SetLoopCount(0);
smconst = 2 / (1+Slw);
smconst1 = 2 / (1+Slwsignal);
              
loopbegin = loopbegin+1; 
for(shift =Barcount;shift >=0 ;shift --)
{ 
    prev = GetIndexValue2(shift+1);
    
    // Yousky 15/05/2006 - Change to avoid Zero divide exception.
    AA = 0;
    tmpDevAA = (High[Highest(NULL, 0, MODE_HIGH,shift+Pds,Pds)] - Low[Lowest(NULL, 0, MODE_LOW,shift+Pds,Pds)]);
    
    if (tmpDevAA != 0)
      AA = 100* ((Close[shift] - Low[Lowest(NULL, 0, MODE_LOW,shift+Pds,Pds)]) / tmpDevAA);
    // ---
      
    MAValue2 = smconst * (AA-prev) + prev;
    
    SetIndexValue2(shift,MAValue2);
    
        
        loopbegin = loopbegin-1; 
        

} 




loopbegin2 = loopbegin2+1; 
for(shift =Barcount-Pds;shift >=0 ;shift --){ 
MyHigh = -999999;
MyLow = 99999999;
for(counter =shift;counter <=Pds + shift ;counter ++){ 
Price= GetIndexValue2(counter);
if( Price > MyHigh ) 
SetIndexValue
MyHigh = Price;
if( Pds <= 0 ) 
MyHigh = Price;
if( Price < MyLow ) 
MyLow = Price;
if( Pds <= 0 ) 
MyLow = Price;
} 

prev1 = GetIndexValue(shift+1);
aa1=GetIndexValue2(shift);

// Yousky 15/05/2006 - Change to avoid Zero divide exception.
bb= 0;
if ((MyHigh-MyLow) != 0)
  bb=100*(aa1-MyLow)/(MyHigh-MyLow);
// ---



  
MAValue = smconst * (bb-prev1) + prev1;
        
SetIndexValue(shift,MAValue);

loopbegin2 = loopbegin2-1; 
} 

//Print (MAValue);  // green

loopbegin3 = loopbegin3+1; 
for(shift =Barcount;shift >=0 ;shift --){ 
prev2=GetIndexValue2(shift+1);
prev3=GetIndexValue(shift);
mavalue3= smconst1 * (prev3-prev2) +prev2;


SetIndexValue2(shift,mavalue3);
loopbegin3 = loopbegin3-1;





} 

 
   if(ExtHistoBuffer[0] > ExtHistoBuffer2[0] && ExtHistoBuffer[0]<20.1 && ExtHistoBuffer2[0] < 20.1 && BuyAlert==False && Alertx == true )
   {

      Alert ("Doda-Stochastic says Buy  ",Symbol()," at ",Close[0]); 
      BuyAlert = True;
      SellAlert = False;
  }
   
   if(ExtHistoBuffer2[0] > ExtHistoBuffer[0] && ExtHistoBuffer[0]>80.1 && ExtHistoBuffer2[0] > 80.1 && SellAlert==False && Alertx == true)
   {
   // sell signal
      Alert ("Doda-Stochastic says Sell  ",Symbol()," at ",Close[0]); 
      BuyAlert = false;
      SellAlert = True;  
      
   }
 


}
This my code i need to get the lines as attached as image.what i write to make one line change ???
 
ankityadav:
This my code i need to get the lines as attached as image.what i write to make one line change ???

What image ?

You haven't attached an image . . .

 

Does this help . . .

#property indicator_color1      Lime
#property indicator_buffers 2
#property indicator_color2      Red
 
Hi thanks for your reply i have attached the image can you let me know how i change the image??
#include <stdlib.mqh>

//+------------------------------------------------------------------+
//|                                              Doda-Stochastic.mq4 |
//|                             Copyright © 2010, Gopal Krishan Doda |
//|                                        http://www.DodaCharts.com |
//|                                     http://www.InvestmentKit.com |
//|This is version 1.0 of Doda-Stochastic indicator                  |
//|Last Modified on 08-Mar-2011                                      |
//| I'm not the original coder. Just modified for screen alert.      |
//+------------------------------------------------------------------+


// This was converted using YouSky's MT3 to MT4 translator.  I cannot take credit for the code.//

#property indicator_separate_window
#property indicator_minimum 0.00
#property indicator_maximum 100.00
#property indicator_color1 Lime
#property indicator_buffers 2
#property indicator_color2 Red
#property indicator_width1 2
#property indicator_width2 1
//#property indicator_level1 20
//#property indicator_level2 50
//#property indicator_level3 80

//+------------------------------------------------------------------+
//| Common External variables                                        |
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
//| External variables                                               |
//+------------------------------------------------------------------+
extern double Slw = 2;  //8  5
extern double Pds = 21; //13  21
extern double Slwsignal = 2; //9  5
extern int    Barcount = 2000;
bool Alertx = false;

//+------------------------------------------------------------------+
//| Special Convertion Functions                                     |
//+------------------------------------------------------------------+

int LastTradeTime;
double ExtHistoBuffer[];
double ExtHistoBuffer2[];
bool BuyAlert=false, SellAlert=false;

void SetLoopCount(int loops)
{
}

void SetIndexValue(int shift, double value)
{
  ExtHistoBuffer[shift] = value;
//  Print ("ExtHistoBuffer :" ,value);    // green
}

void SetIndexValue2(int shift, double value)
{
  ExtHistoBuffer2[shift] = value;
//  Print ("ExtHistoBuffer2 :" ,value);    // green
}

double GetIndexValue(int shift)
{
  return(ExtHistoBuffer[shift]);
}

double GetIndexValue2(int shift)
{
  return(ExtHistoBuffer2[shift]);
}

//+------------------------------------------------------------------+
//| End                                                              |
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
//| Initialization                                                   |
//+------------------------------------------------------------------+

int init()
{
   //SetIndexStyle(0, DRAW_LINE, STYLE_SOLID);
   SetIndexBuffer(0, ExtHistoBuffer);

   //SetIndexStyle(1, DRAW_LINE, STYLE_SOLID);
   SetIndexBuffer(1, ExtHistoBuffer2);

   
    
   return(0);
}
int start()
{
//+------------------------------------------------------------------+
//| Local variables                                                  |
//+------------------------------------------------------------------+
double AA = 0;
double bb = 0;
double aa1 = 0;
double cnt1 = 0;
int shift = 0;
double cnt = 0;
double loopbegin = 0;
double loopbegin2 = 0;
double loopbegin3 = 0;
bool first = True;
double prevbars = 0;
double sum = 0;
double smconst = 0;
double smconst1 = 0;
double prev = 0;
double prev1 = 0;
double prev2 = 0;
double prev3 = 0;
double weight = 0;
double linear = 0;
double MAValue = 0;
double MAValue2 = 0;
double mavalue3 = 0;
string MAstring = "";
double MyHigh = 0;
double MyLow = 0;
int counter = 0;
double Price = 0;
double Price1 = 0;
double tmpDevAA = 0;

SetLoopCount(0);
smconst = 2 / (1+Slw);
smconst1 = 2 / (1+Slwsignal);
              
loopbegin = loopbegin+1; 
for(shift =Barcount;shift >=0 ;shift --)
{ 
    prev = GetIndexValue2(shift+1);
    
    // Yousky 15/05/2006 - Change to avoid Zero divide exception.
    AA = 0;
    tmpDevAA = (High[Highest(NULL, 0, MODE_HIGH,shift+Pds,Pds)] - Low[Lowest(NULL, 0, MODE_LOW,shift+Pds,Pds)]);
    
    if (tmpDevAA != 0)
      AA = 100* ((Close[shift] - Low[Lowest(NULL, 0, MODE_LOW,shift+Pds,Pds)]) / tmpDevAA);
    // ---
      
    MAValue2 = smconst * (AA-prev) + prev;
    
    SetIndexValue2(shift,MAValue2);
    
        
        loopbegin = loopbegin-1; 
        

} 




loopbegin2 = loopbegin2+1; 
for(shift =Barcount-Pds;shift >=0 ;shift --){ 
MyHigh = -999999;
MyLow = 99999999;
for(counter =shift;counter <=Pds + shift ;counter ++){ 
Price= GetIndexValue2(counter);
if( Price > MyHigh ) 
MyHigh = Price;
if( Pds <= 0 ) 
MyHigh = Price;
if( Price < MyLow ) 
MyLow = Price;
if( Pds <= 0 ) 
MyLow = Price;
} 

prev1 = GetIndexValue(shift+1);
aa1=GetIndexValue2(shift);

// Yousky 15/05/2006 - Change to avoid Zero divide exception.
bb= 0;
if ((MyHigh-MyLow) != 0)
  bb=100*(aa1-MyLow)/(MyHigh-MyLow);
// ---



  
MAValue = smconst * (bb-prev1) + prev1;
        
SetIndexValue(shift,MAValue);

loopbegin2 = loopbegin2-1; 
} 

//Print (MAValue);  // green

loopbegin3 = loopbegin3+1; 
for(shift =Barcount;shift >=0 ;shift --){ 
prev2=GetIndexValue2(shift+1);
prev3=GetIndexValue(shift);
mavalue3= smconst1 * (prev3-prev2) +prev2;


SetIndexValue2(shift,mavalue3);
loopbegin3 = loopbegin3-1;





} 

 
   if(ExtHistoBuffer[0] > ExtHistoBuffer2[0] && ExtHistoBuffer[0]<20.1 && ExtHistoBuffer2[0] < 20.1 && BuyAlert==False && Alertx == true )
   {

      Alert ("Doda-Stochastic says Buy  ",Symbol()," at ",Close[0]); 
      BuyAlert = True;
      SellAlert = False;
  }
   
   if(ExtHistoBuffer2[0] > ExtHistoBuffer[0] && ExtHistoBuffer[0]>80.1 && ExtHistoBuffer2[0] > 80.1 && SellAlert==False && Alertx == true)
   {
   // sell signal
      Alert ("Doda-Stochastic says Sell  ",Symbol()," at ",Close[0]); 
      BuyAlert = false;
      SellAlert = True;  
      
   }
 


}
 
  1. Why did you post the code a second time after you edited the original post?
  2. Your image implies you want to change the color of a SINGLE line depending on the slope. That can't be done.
  3. MAValue = smconst * (bb-prev1) + prev1;
            
    SetIndexValue(shift,MAValue);
    
    You are not asking about a single line change. You must create another buffer and set either the original or the new with the MAValue. You'll have to look at some colored indicators in the code base or post a job.
 
hi thanks for your reply can you let me know what i code to make this perfect ???
 
WHRoeder:
  1. Why did you post the code a second time after you edited the original post?
  2. Your image implies you want to change the color of a SINGLE line depending on the slope. That can't be done.
  3. You are not asking about a single line change. You must create another buffer and set either the original or the new with the MAValue. You'll have to look at some colored indicators in the code base or post a job.

Thanks for your reply I dont have much moneyto post the job can you let me know what i code to make this perfect ??? If you can ???
 
ankityadav:

Thanks for your reply I dont have much moneyto post the job can you let me know what i code to make this perfect ??? If you can ???


Hi ankityadav

Here is something that may help you out :

In addition to the 2 buffers you need another one

#property indicator_buffers 3

#property indicator_color1 clrWhite
#property indicator_color2 clrLime
#property indicator_color3 clrRed

#property indicator_width1 1
#property indicator_width2 2
#property indicator_width3 2

double   ExtHistoBuffer2[];
double   ExtHistoBufferA[];
double   ExtHistoBuffer[];
#property indicator_level1 20
#property indicator_level2 50
#property indicator_level3 80

You can see the colors there, the buffers and all. Then you need to change the Init() function like this :

int init()
  {
   
   SetIndexBuffer(0,ExtHistoBuffer2);
   SetIndexBuffer(1,ExtHistoBuffer);
   SetIndexBuffer(2,ExtHistoBufferA);

   SetIndexStyle (0,DRAW_LINE,STYLE_SOLID,1);
   SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,2);
   SetIndexStyle(2,DRAW_LINE,STYLE_SOLID,2);

   return(0);

And finally insert this code in the appropriate location. Don't worry, if you cant figure it out and make it work I will post for you the entire code but I'd be glad to hear that you've done it yourself.

Here is the code :

      SetIndexValue2(shift,mavalue3);//--------------------------------------------- Set index value2
      loopbegin3=loopbegin3-1;
     }
//--- New code here
   for(shift=Barcount-Pds;shift>=0;shift --)
     {
      if(ExtHistoBuffer[shift]>=ExtHistoBuffer2[shift])
        {
         ExtHistoBufferA[shift]=EMPTY_VALUE;
        }
      else
        {
         ExtHistoBufferA[shift]=ExtHistoBuffer[shift];
        }
     }

//--- Alerts
   if(ExtHistoBuffer[0]>ExtHistoBuffer2[0] && ExtHistoBuffer[0]<20.1 && ExtHistoBuffer2[0]<20.1 && BuyAlert==False && Alertx==true)
     {

      Alert("Doda-Stochastic says Buy  ",Symbol()," at ",Close[0]);
      BuyAlert=True;
      SellAlert=False;

Now, what the code does is to place another red color line over the lime one and it looks like this :

I hope you can follow this hints and do it yourself . If you can't do it let me know and I'll post the whole code for you.

All the best

PS One more thing, the settings in the picture you posted are not the same as in the code, are they ?

 
thrdel:


Hi ankityadav

Here is something that may help you out :

In addition to the 2 buffers you need another one

You can see the colors there, the buffers and all. Then you need to change the Init() function like this :

And finally insert this code in the appropriate location. Don't worry, if you cant figure it out and make it work I will post for you the entire code but I'd be glad to hear that you've done it yourself.

Here is the code :

Now, what the code does is to place another red color line over the lime one and it looks like this :

I hope you can follow this hints and do it yourself . If you can't do it let me know and I'll post the whole code for you.

All the best

PS One more thing, the settings in the picture you posted are not the same as in the code, are they ?


ohh really thankfull for you to make this post and it works and thanks again i have another problem coming if you can help me .I am working on the indicator i have made it but the problem is it is not working on m1,m5,and m15 chart can you help me to sort out ???
 
ankityadav:

ohh really thankfull for you to make this post and it works and thanks again i have another problem coming if you can help me .I am working on the indicator i have made it but the problem is it is not working on m1,m5,and m15 chart can you help me to sort out ???


I can try if you post the code.

Let us see what you've got.

 
thrdel:


I can try if you post the code.

Let us see what you've got.


Thanks for your reply
Reason: