HELP "unexpected end of program " on Customizable MACD

 
//+------------------------------------------------------------------+
//|                                                      ProjectName |
//|                                      Copyright 2020, CompanyName |
//|                                       http://www.companyname.net |
//+------------------------------------------------------------------+
#property copyright   "2009-2017, MetaQuotes Software Corp."
#property link        "http://www.mql5.com"
#property description "1.00"

#include <Trade\Trade.mqh>

CTrade trade;

int handle;

double linha_macd[];
double linha_signal[];

MqlRates rates [];

input double _volume = 2.0; //Quantidade de Lotes:
input double meuStop = 150.0; //Stop Loss (pontos):
input double meuTake = 50.0; //Take Profit (pontos):

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int OnInit()
  {

   ArraySetAsSeries(rates, true);
   ArraySetAsSeries(linha_macd, true);
   ArraySetAsSeries(linha_signal, true);


   handle = iMACD(Symbol(), PERIOD_CURRENT, 12,26,9, PRICE_CLOSE);

   return (INIT_SUCCEEDED);
  }

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnTick()
  {

   CopyRates(Symbol(), PERIOD_CURRENT, 0, 3, rates);
   CopyBuffer(handle, 0, 0, 3, linha_macd);
   CopyBuffer(handle, 1, 0, 3, linha_signal);



   if(linha_macd[2] < linha_signal[2] && linha_macd[1] > linha_signal[1] && linha_macd[0] < 0 && linha_signal[0] < 0)
     {

      //ObjectCreate(0, rates[1].time, OBJ_ARROW_BUY, 0, rates[1].time, rates[1].low);
      if(PositionsTotal() == 0)
        {
         if(trade.Buy(_volume, Symbol(),0,0,0, "Compra")
           {
            addTakeStop(meuStop, meuTake);
           }
        }


      if(linha_macd[2] > linha_signal[2] && linha_macd[1] < linha_signal[1] && linha_macd[0] > 0 && linha_signal[0] > 0)
        {

         //ObjectCreate(0, rates[1].time, OBJ_ARROW_SELL, 0, rates[1].time, rates[1].high);
         if(PositionsTotal() == 0)
           {
            if(trade.Sell(_volume, Symbol(),0,0,0, "Venda")
              {
               addTakeStop(meuStop, meuTake);
              }
           }
        }
     }


   void addTakeStop(double p_sl, double p_tp)
     {

      for(int i = PositionsTotal() -1; i>=0; i--)
        {
         string symbol = PositionGetSymbol(i);


         if(symbol == Symbol()
           {

            ulong ticket =    PositionGetInteger(POSITION_TICKET);
            double precoEntrada =  PositionGetDouble(POSITION_PRICE_OPEN);

            double novoSL;
            double novoTP;


            if(PositionsGetInteger(POSITION_TYPE) == POSITION_TYPE_BUY)
              {

               novoSL = NormalizeDouble(precoEntrada - (p_sl *_Point), _Digits);
               novoTP = NormalizeDouble(precoEntrada + (p_tp *_Point), _Digits);

               trade.PositionModify(ticket, novoSL, novoTP);

              }
            else
               if(PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_SELL)
                 {

                  novoSL = NormalizeDouble(precoEntrada + (p_sl *_Point), _Digits);
                  novoTP = NormalizeDouble(precoEntrada - (p_tp *_Point), _Digits);

                  trade.PositionModify(ticket, novoSL, novoTP);

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



After compiling I get the 2 erros: "Unexpected end of program" and "Unbalanced parentheses"

Can someone help ?

Domain Registration Services
  • www.registryrocket.com
Get a unique domain name plus our FREE value-added services to help you get the most from it. Call it a "dot-com name," a URL, or a domain. Whatever you call it, it's the cornerstone of your online presence, and we make getting one easy. Simply enter the name you want in the search field above, and we'll tell you instantly whether the name is...
 
You are very sloppy in writing programs. You have lost a LOT of characters ')'
 
You have put one function (void addTakeStop) INSIDE ANOTHER (OnTick)
 
Read the help: there are NO 'PositionsGetInteger' functions, there is a 'PositionGetInteger' function
 
Vladimir Karputov:
You are very sloppy in writing programs. You have lost a LOT of characters ')'
Do you need to offend me ? I just want to know where is the error.
 
Vladimir Karputov:
Read the help: there are NO 'PositionsGetInteger' functions, there is a 'PositionGetInteger' function
Already corrected that. But still doesn't works.
 
Valter Zuccoli :
Already corrected that. But still doesn't works.

Unfortunately, I cannot get into your brain and I cannot see your new code - so I ask you: show the code that you worked on and in which you fixed the errors.

 
//+------------------------------------------------------------------+
//|                                                      ProjectName |
//|                                      Copyright 2020, CompanyName |
//|                                       http://www.companyname.net |
//+------------------------------------------------------------------+
#property copyright   "2009-2017, MetaQuotes Software Corp."
#property link        "http://www.mql5.com"
#property description "1.00"

#include <Trade\Trade.mqh>

CTrade trade;

int handle;

double linha_macd[];
double linha_signal[];

MqlRates rates [];

input double _volume = 2.0; //Quantidade de Lotes:
input double meuStop = 150.0; //Stop Loss (pontos):
input double meuTake = 50.0; //Take Profit (pontos):

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int OnInit()
  {

   ArraySetAsSeries(rates, true);
   ArraySetAsSeries(linha_macd, true);
   ArraySetAsSeries(linha_signal, true);


   handle = iMACD(Symbol(), PERIOD_CURRENT, 12,26,9, PRICE_CLOSE);

   return (INIT_SUCCEEDED);
  }

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnTick()
  {

   CopyRates(Symbol(), PERIOD_CURRENT, 0, 3, rates);
   CopyBuffer(handle, 0, 0, 3, linha_macd);
   CopyBuffer(handle, 1, 0, 3, linha_signal);



   if(linha_macd[2] < linha_signal[2] && linha_macd[1] > linha_signal[1] && linha_macd[0] < 0 && linha_signal[0] < 0)
     {

      //ObjectCreate(0, rates[1].time, OBJ_ARROW_BUY, 0, rates[1].time, rates[1].low);
      if(PositionsTotal() == 0)
        {
         if(trade.Buy(_volume, Symbol(),0,0,0, "Compra")
           {
            addTakeStop(meuStop, meuTake);
           }
        }


      if(linha_macd[2] > linha_signal[2] && linha_macd[1] < linha_signal[1] && linha_macd[0] > 0 && linha_signal[0] > 0)
        {

         //ObjectCreate(0, rates[1].time, OBJ_ARROW_SELL, 0, rates[1].time, rates[1].high);
         if(PositionsTotal() == 0)
           {
            if(trade.Sell(_volume, Symbol(),0,0,0, "Venda")
              {
               addTakeStop(meuStop, meuTake);
              }
           }
        }
     }


   void addTakeStop(double p_sl, double p_tp)
     {

      for(int i = PositionsTotal() -1; i>=0; i--)
        {
         string symbol = PositionGetSymbol(i);


         if(symbol == Symbol()
           {

            ulong ticket =    PositionGetInteger(POSITION_TICKET);
            double precoEntrada =  PositionGetDouble(POSITION_PRICE_OPEN);

            double novoSL;
            double novoTP;


            if(PositionsGetInteger(POSITION_TYPE) == POSITION_TYPE_BUY)
              {

               novoSL = NormalizeDouble(precoEntrada - (p_sl *_Point), _Digits);
               novoTP = NormalizeDouble(precoEntrada + (p_tp *_Point), _Digits);

               trade.PositionModify(ticket, novoSL, novoTP);

              }
            else
               if(PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_SELL)
                 {

                  novoSL = NormalizeDouble(precoEntrada + (p_sl *_Point), _Digits);
                  novoTP = NormalizeDouble(precoEntrada - (p_tp *_Point), _Digits);

                  trade.PositionModify(ticket, novoSL, novoTP);

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

You haven't done anything.

Please follow all signs ')' - You have lost a few characters ')'

 
You are using 'PositionsGetInteger' again - I told you above: the 'PositionsGetInteger' function does not exist, but there is a 'PositionsGetInteger' function !!!
 
Vladimir Karputov:

You haven't done anything.

Please follow all signs ')' - You have lost a few characters ')'

I don't know how to do it. Can't you correct and post back here ?
Reason: