Download MetaTrader 5

someting about the arrowSeparation.

To add comments, please log in or register
Ma Yuliang
255
Ma Yuliang 2015.11.07 12:48 

My way to learn code for mql4 is to recreate system default Indicator.

In William's Fractals .The green arrow is my fractals. The distance will change when chart scale changed.

But the System default Fractals always in a fixed position.

Is it possible for us to create a Arrow like the System default Indicator?


double arrowSeparation=MarketInfo(Symbol(),MODE_POINT)*Period()*0.2;

I used the arrowSeparation in my Fractals.It is not work very well. I also try to understand the "BillWilliams.mqh" .The code below is just get data set Symble and period. There is nothing about the arrow position.

The system Indicatro must create in a different way . If any one know something about it please tell me. Thanks.

//+------------------------------------------------------------------+
//| Class CiFractals.                                                |
//| Purpose: Class of the "Fractals" indicator.                      |
//|          Derives from class CIndicator.                          |
//+------------------------------------------------------------------+
class CiFractals : public CIndicator
  {
public:
                     CiFractals(void);
                    ~CiFractals(void);
   //--- method of creating
   bool              Create(const string symbol,const ENUM_TIMEFRAMES period);
   //--- methods of access to indicator data
   virtual double    GetData(const int buffer_num,const int index) const;
   double            Upper(const int index) const;
   double            Lower(const int index) const;
   //--- method of identifying
   virtual int       Type(void) const { return(IND_FRACTALS); }

protected:
   //--- methods of tuning
   virtual bool      Initialize(const string symbol,const ENUM_TIMEFRAMES period,const int num_params,const MqlParam &params[]);
   bool              Initialize(const string symbol,const ENUM_TIMEFRAMES period);
  };
//+------------------------------------------------------------------+
//| Constructor                                                      |
//+------------------------------------------------------------------+
CiFractals::CiFractals(void)
  {
  }
//+------------------------------------------------------------------+
//| Destructor                                                       |
//+------------------------------------------------------------------+
CiFractals::~CiFractals(void)
  {
  }
//+------------------------------------------------------------------+
//| Create the "Fractals" indicator                                  |
//+------------------------------------------------------------------+
bool CiFractals::Create(const string symbol,const ENUM_TIMEFRAMES period)
  {
   SetSymbolPeriod(symbol,period);
//--- result of initialization
   return(Initialize(symbol,period));
  }
//+------------------------------------------------------------------+
//| Initialize the indicator with universal parameters               |
//+------------------------------------------------------------------+
bool CiFractals::Initialize(const string symbol,const ENUM_TIMEFRAMES period,const int num_params,const MqlParam &params[])
  {
   return(Initialize(symbol,period));
  }
//+------------------------------------------------------------------+
//| Initialize the indicator with special parameters                 |
//+------------------------------------------------------------------+
bool CiFractals::Initialize(const string symbol,const ENUM_TIMEFRAMES period)
  {
   m_name="Fractals";
//--- ok
   return(true);
  }
//+------------------------------------------------------------------+
//| Access to buffer of "Fractals"                                   |
//+------------------------------------------------------------------+
double CiFractals::GetData(const int buffer_num,const int index) const
  {
   return(iFractals(m_symbol,m_period,buffer_num,index));
  }
//+------------------------------------------------------------------+
//| Access to Upper buffer of "Fractals"                             |
//+------------------------------------------------------------------+
double CiFractals::Upper(const int index) const
  {
   return(GetData(MODE_UPPER,index));
  }
//+------------------------------------------------------------------+
//| Access to Lower buffer of "Fractals"                             |
//+------------------------------------------------------------------+
double CiFractals::Lower(const int index) const
  {
   return(GetData(MODE_LOWER,index));
  }

ss

To add comments, please log in or register