A guid for calling the indicator#Color Candles

14 October 2019, 19:07
Ziheng Zhuang
1
252


Indicator#  https://www.mql5.com/en/market/product/10455


The code for your reference.

//+------------------------------------------------------------------+
//|                     test_Color_Candles_Show_the_Trend_Change.mq4 |
//+------------------------------------------------------------------+
//Color Candles Show the Trend Change
//https://www.mql5.com/en/market/product/10455
#property copyright "Copyright 2019,fxMeter"
#property link      "https://www.mql5.com/en/users/fxmeter"
#property version   "1.00"
#property strict

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
      Comment(IsBullCandel(0),"\n",IsBearCandel(0));
     
      //1. bull trend
      bool bull = IsBullCandel(0) && IsBullCandel(1);
      
      //2. bear trend
      bool bear = IsBearCandel(0) && IsBearCandel(1);
      
      //3. buy signal
      bool buySignal = IsBuySignal(1);
      
      //4. sell signal
      bool sellSignal = IsSellSignal(1);
      
  }
//+------------------------------------------------------------------+
//Outer top line,DeepSkyBlue: buffer index = 4
double GetBandOuterTop(int shift)
{   
   double v = iCustom(Symbol(),0,"\\Market\\Color Candles Show the Trend Change",
   "=",true,clrAqua,clrTomato,false,false,"=",true,false,false,4,shift);
   return(v);
}

//Outer btm line,DeepSkyBlue: buffer index = 5
double GetBandOuterBtm(int shift)
{   
   double v = iCustom(Symbol(),0,"\\Market\\Color Candles Show the Trend Change",
   "=",true,clrAqua,clrTomato,false,false,"=",true,false,false,5,shift);
   return(v);
}

//Inner top line,Lavender: buffer index = 6
double GetBandInnerTop(int shift)
{   
   double v = iCustom(Symbol(),0,"\\Market\\Color Candles Show the Trend Change",
   "=",true,clrAqua,clrTomato,false,false,"=",true,false,false,6,shift);
   return(v);
}

//Inner btm line,Lavender: buffer index = 7
double GetBandInnerBtm(int shift)
{   
   double v = iCustom(Symbol(),0,"\\Market\\Color Candles Show the Trend Change",
   "=",true,clrAqua,clrTomato,false,false,"=",true,false,false,7,shift);
   return(v);
}

//buffer2>buffer3 is bull
//buffer2<buffer3 is bear
bool IsBullCandel(int shift)
{
      double v2 = iCustom(Symbol(),0,"\\Market\\Color Candles Show the Trend Change",
   "=",true,clrAqua,clrTomato,false,false,"=",true,false,false,2,shift);
   
      double v3 = iCustom(Symbol(),0,"\\Market\\Color Candles Show the Trend Change",
   "=",true,clrAqua,clrTomato,false,false,"=",true,false,false,3,shift);
   
   return(v2>v3);
}

bool IsBearCandel(int shift)
{
      double v2 = iCustom(Symbol(),0,"\\Market\\Color Candles Show the Trend Change",
   "=",true,clrAqua,clrTomato,false,false,"=",true,false,false,2,shift);
   
      double v3 = iCustom(Symbol(),0,"\\Market\\Color Candles Show the Trend Change",
   "=",true,clrAqua,clrTomato,false,false,"=",true,false,false,3,shift);
   
   return(v2<v3);
}

bool IsBuySignal(int shift)
{
     return( IsBullCandel(shift) && IsBearCandel(shift+1));
}

bool IsSellSignal(int shift)
{
    return (IsBearCandel(shift) && IsBullCandel(shift+1));
}



Share it with friends: