Off-topic MT4/mql4 questions. - page 41

Nardus Van Staden  
Maurojose1989 #:

hi i have some error, fix please

'iCCI' - wrong parameters count


Hi Maurojose,  The error is because iCCI doesn't have a MODE_MAIN parameter. It only has MODE_SMA , MODE_EMA , and MODE_SMMA for moving average modes. Also, PRICE_TYPICAL is not a valid parameter for applied_price

Use this Function instead 

double cci = iCCI(NULL, 0, 14, PRICE_TYPICAL, 0);

Here is the correct way, it should compile

//+------------------------------------------------------------------+
//|                                                      mmmccc1.mq4 |
//|                        Copyright 2022, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2022, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int start()
{
  int maPeriodFast = 21;
  int maPeriodSlow = 9;
  double maFast = iMA(NULL, 0, maPeriodFast, 0, MODE_EMA, PRICE_CLOSE, 0);
  double maSlow = iMA(NULL, 0, maPeriodSlow, 0, MODE_EMA, PRICE_CLOSE, 0);
  double atrValue = iATR(NULL, 0, 14, 0);
  double macd = iMACD(NULL, 0, 12, 26, 9, PRICE_CLOSE, MODE_MAIN, 0);
  double macdSignal = iMACD(NULL, 0, 12, 26, 9, PRICE_CLOSE, MODE_SIGNAL, 0);
  double cci = iCCI(NULL, 0, 14, PRICE_TYPICAL, 0);

  if (maFast > maSlow && macd > macdSignal && cci > 100) {
    // bullish market, place a buy order
    double stopLoss = Bid - atrValue*2;
    double takeProfit = Bid + atrValue*4;
    int result = OrderSend(Symbol(), OP_BUY, 1, Ask, 3, stopLoss, takeProfit, "My EA Buy Order", 16384, 0, clrGreen);
    if (result > 0) {
      Print("Buy order placed successfully");
    }
  } else if (maFast < maSlow && macd < macdSignal && cci < -100) {
    // bearish market, place a sell order
    double stopLoss = Ask + atrValue*2;
    double takeProfit = Ask - atrValue*4;
    int result = OrderSend(Symbol(), OP_SELL, 1, Bid, 3, stopLoss, takeProfit, "My EA Sell Order", 16384, 0, clrRed);
    if (result > 0) {
      Print("Sell order placed successfully");
    }
  }

  return(0);
}

//+------------------------------------------------------------------+

Always remember to use your reference.

Sumant Singh  

hey! I can't able to download mt4 pc win 10 version

William Roeder  
Sumant Singh #: I can't able to download mt4 pc win 10 version

If you had used this (before posting), you would have found (among 400+) Where to download MT4? - General - MQL5 programming forum (2017)
   How To Ask Questions The Smart Way. (2004)
      How To Interpret Answers.
         RTFM and STFW: How To Tell You've Seriously Screwed Up.

It has been years since you could download MT4 from Metaquotes. You can only get it from a broker's website.
          Where to download the orginal MT4 installer - MQL4 programming forum (2018)

Reason: