4

I have made an EA that simply displays the ZigZag indicator line. Please see the code below. I would like to add a Fibonacci retracement (as seen in the image link below) from the drawn one end to the other of the ZigZag in the opposite direction. How can I draw this Fibonacci retracement programmatically and access the values at 100.0, 61.8 and so on?

enter image description here ZigZagWithFibonacci

#include <Trade\PositionInfo.mqh>
#include <Trade\Trade.mqh>
#include <Trade\SymbolInfo.mqh>
#include <Trade\AccountInfo.mqh>
#include <Trade\OrderInfo.mqh>
#include <Expert\Money\MoneyFixedMargin.mqh>

CPositionInfo  m_position;                   // trade position object
CTrade         m_trade;                      // trading object
CSymbolInfo    m_symbol;                     // symbol info object
CAccountInfo   m_account;                    // account info wrapper
COrderInfo     m_order;                      // pending orders object
CMoneyFixedMargin *m_money;

int            handle_iCustom;               // variable for storing the handle of the iCustom indicator

int OnInit()
  {
//---

//---

   //--- create handle of the indicator iCustom
   handle_iCustom=iCustom(m_symbol.Name(),Period(),"Examples\\ZigZag");
//--- if the handle is not created
   if(handle_iCustom==INVALID_HANDLE)
     {
      //--- tell about the failure and output the error code
      PrintFormat("Failed to create handle of the iCustom indicator for the symbol %s/%s, error code %d",
                  m_symbol.Name(),
                  EnumToString(Period()),
                  GetLastError());
      if(m_money!=NULL)
         delete m_money;
      //--- the indicator is stopped early
      return(INIT_FAILED);
     }
//---
   // --- 
   ChartIndicatorAdd ( 0 , 0 , handle_iCustom); 
// --- 


   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---

  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---

  }
//+------------------------------------------------------------------+


user3666197
  • 1
  • 6
  • 50
  • 92
BBNN
  • 139
  • 1
  • 9

0 Answers0