newbie needing help to compile

 

I am a newbie to MT5.  I have a couple of Indicators that I am trying to create and for which I receive just 2 errors when i try to compile them.  Would someone be kind enough to point out to me what I am not getting.

//+------------------------------------------------------------------+
//|                                                        RsiEA.mq5 |
//|                                                   Geoffray Dyson |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Geoffray Dyson"
#property link      "https://www.mql5.com"
#property version   "1.00"

//+------------------------------------------------------------------+
//| Include                                  |
//+------------------------------------------------------------------+
#include <Trade\Trade.mqh>

//+------------------------------------------------------------------+
//| Inputs                                  |
//+------------------------------------------------------------------+


static input long       InpMagicnumber =   546812;   // magic number
static input double     InpLotSize     =   0.01;     // lot size
input int               InpRSIPeriod   =   21;       // rsi period
input int               InpRSILevel    =   70;       // rsi level (upper)
input int               InpStopLoss    =   200;      // stop loss in points (0=off)
input int               InpTakeProfit  =   100;      // take profit in points (0=off)
input bool              InpCloseSignal =   false;    // close trades by opposite signal


//+------------------------------------------------------------------+
//| Globa1 variables                                  |
//+------------------------------------------------------------------+


int handle;
double buffer[];        
MqlTick currentTick;
CTrade trade;
datetime openTimeBuy = 0;
datetime openTimeSell = 0;

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {

// check useir inputs
   if(InpMagicnumber<=0)
     {
      Alert("Magicnumber <= O");
      return INIT_PARAMETERS_INCORRECT;
     }
   if(InpLotSize<=0 || InpLotSize>10)
     {
      Alert("Lot size <= 0 or > 10");
      return INIT_PARAMETERS_INCORRECT;
     }
   if(InpRSIPeriod<=1)
     {
      Alert("RSI period <= 1");
      return INIT_PARAMETERS_INCORRECT;
     }
   if(InpRSILevel>=100 || InpRSILevel<=50)
     {
      Alert("RSI level >= 100 or <= 50");
      return INIT_PARAMETERS_INCORRECT;
     }
   if(InpStopLoss<0)
     {
      Alert("Stop loss < O") ;
      return INIT_PARAMETERS_INCORRECT;
     }
   if(InpTakeProfit<0)
     {
      Alert("Take profit < 0");
      return INIT_PARAMETERS_INCORRECT;
     }

// set magic number to trade object
   trade.SetExpertMagicNumber(InpMagicnumber);

// create rsi handle
   handle = iRSI(_Symbol,PERIOD_CURRENT,InpRSIPeriod,PRICE_CLOSE);

   if(handle == INVALID_HANDLE)
     {
      Alert("Failed to create indicator handle");
      return INIT_FAILED;
     }

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

  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick(){
// get current tick
  {
   if(!SymbolInfoTick(_Symbol,currentTick))
     {
      Print("Failed to get current tick");
      return;
     }

// get rsi values
   int values = CopyBuffer(handle,0,0,2,buffer);
   if(values!=2)
     {
      Print("Failed to get indicator values");
      return;
     }

   Comment("buffer[0]:",buffer[0],
           "\nbuffer[1]:",buffer[1]);

// count Open poisitions
   int cntBuy, cntSell;
   if(!CountOpenPositions(cntBuy,cntSell)

//check for buy position
                          if(cntBuy=0 && buffer[1]>=(100-InpRSILevel) && buffer[0]<(100-InpRSILevel) && openTimeBuy!=iTime(Symbol/PERIODCURRENTI0))
     {

      openTimeBuy=iTime(Symbol/PERIOD CURRENTIC);
         if(InpStopLoss)
            if(!ClosePosiiions(2))
              {
               return;
              } 
         double sl = InpStopLoss==0 ? 0 : currentTick.bid - InpStopLoss * _Point;
         double tp = InpTakeProfit==0 ? 0 : currentTick.bid + InpTakeProfit * _Point;
         if(!NormalizePrice(s1))
           {
            return;
           }
         if(!NormalizePrice(tp))
           {
            return;
           }

         trade. PositionOpen(Symnboi3ORDER TYPE BUY, InpLotSize,currentTick. ask,si,tp,"RSIEA") ;

         // check for sell position
         if(cntSell==0 && buffer[1]<=InpRSILevel && buffer[0]>InpRSILevel && openTimeSell!=iTime(Symbol/PERIODCURRENT/0))
           {
            openTimeSell=iTime(Symbol/PERIOD CURRENT/0);
            if(InpCloseSignal)
               if(!ClosePositions(1))
                 {
                  return;
                 }
           }
         double sl = InpStopLoss==0 ? : currentTick.ask + InpStopLoss * _Point;
         double tp = InpTakeProfit==0 ? : currentTick.ask - InpTakeProfit * Point;
         if(!NormalizePrice(s1))
           {
            return;
           } 
         if(!NormalizePrice(tp))
           {
            return;
           }

         trade.PositionOpen(Symbol/ORDERTYPESELL/InpLotSize/currentTick.bid,sl,tp,"RSIEA");
        }

//+------------------------------------------------------------------+
//| Custom functions                                           |
//+------------------------------------------------------------------+


// count open positions
   bool CountOpenPositions(int &cntBuy, int &cntSell)
     {

      cntBuy  = 0;
      cntSell = 0;
      int total = PositionsTotal();
      for(int i=total-1; i>=0; i--)
        {
         ulong ticket = PositionGetTicket(i);
         if(ticket<=0)
           {
            Print("Failed to get position ticket");
            return false;
           }
         if(!PositionSelectByTicket(ticket))
           {
            Print("Failed to select position");
            return false;
           }
         long magic;
         if(!PositionGetlnteger(POSITION_MAGIC,magic))
           {
            Print("Failed to get position magicnumber");
            return false;
           }
         if(magic==InpMagicnumber)
           {
            long type;
            if(!PositionGetlnteger(POSITION_TYPE,type))
              {
               Print("Failed to get position type");
               if(type==POSITION_TYPE_BUY)
                 {
                  cntiuy++;
                 }
               if(type==POSITION_TYPE_SELL)
                  (cntSell++;)
                 }
              }
         return true;
        }

      // normalize price
      bool NormalizePrice(double &price)
        {

         double tickSize=0;
         if(!SymbolInfoDouble(Symbol,SYMBOL TRADE TICK SIZE,tickSize))
           {
            Print(‘Failed to get tick size‘);
            return false;
           }
         price = NormalizeDouble(MathRound(price/tickSize)*tickSize_Digits);
         return true;


         // close positions
         bool ClosePositions(int all buy sell)
           {

            int total = PositionsTotal();
            for(int i=total-1; i>=0; i--)
              {
               ulong ticket = PositionGetTicket(i);
               if(ticket<=3)
                 {
                  Print("Failed to get position ticket");
                  return false;
                 }
               if(!PositionSelectByTicket(ticket))
                 {
                  Print("Failed to select position");
                  return false;
                 }
               long magic;
               if(!PositionGetInteger(POSITION MAGIC,magic))
                 {
                  Print("Failed to get position magicnumber");
                  return false;
                 }
               if(magic==InpMagicnumber)
                 {
                  long type;
                  if(!PositionGetInteger(POSITION TYPE,type))
                    {
                     Print("Failed to get position type");
                     return false;
                    }
                  if(all buy sell==1 && type==POSITION TYPE SELL)
                    {
                     continue;
                    }
                  if(all—buy—sell==2 && type==POSITION-TYPE-BUY)
                    {
                     continue;
                    }
                  trade.osiionClose(ticket);
                  if(trade.ResultRetcode()!=TRADE RETCODE DONE)
                    {
                     l
                     Print("Failed to close position. ticket:",
                           (string) ticket," result:",(string)trade.ResultRetcode(),":",trade.CheckResultRetcodeDescription());
                    }
                 }
              }
            return true;
           }
        }
     }
}
 

Is that really "your" code ?

It's not even an indicator, it's an EA.

 
dysong3:

As Alain Verleyen said "your codes" designed to trade (buy or sell) it is not INDICATOR. 

And if you want to code it as Auto Trading Application (shortly EA) please check the following link by Vladimir Karputov  : 

An attempt at developing an EA constructor - MQL5 Articles

An attempt at developing an EA constructor
An attempt at developing an EA constructor
  • www.mql5.com
In this article, I offer my set of trading functions in the form of a ready-made EA. This method allows getting multiple trading strategies by simply adding indicators and changing inputs.
 
         if(!NormalizePrice(s1))
  1. Do not post code that will not even compile.
  2. Perhaps you should read the manual. NormalizeDouble - Conversion Functions - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
       How To Ask Questions The Smart Way. (2004)
          How To Interpret Answers.
             RTFM and STFW: How To Tell You've Seriously Screwed Up.

    NormalizeDouble does not return a boolean.