Help with EA

 

I get unexpected end of program and unbalanced parentheses on the below code

void OnTick(void)
  {
   double macdLine;
   double signalLine;
   double macdHist;
0
int start()
{
   macdLine = iMACD("EURUSD", PERIOD_M1, 12, 26, 9, PRICE_CLOSE, MODE_MAIN, 0);
   signalLine = iMACD("EURUSD", PERIOD_M1, 12, 26, 9, PRICE_CLOSE, MODE_SIGNAL, 0);
   macdHist = iMACD("EURUSD", PERIOD_M1, 12, 26, 9, PRICE_CLOSE, MODE_HIST, 0);

   if(macdLine > signalLine + 0.0008)
   {
      OrderSend(Symbol(), OP_BUY, 1.0, Ask, 3, Bid - (40 * Point), Bid + (macdLine - signalLine), NULL);
   }
   else if(macdLine < signalLine - 0.0008)
   {
      OrderSend(Symbol(), OP_SELL, 1.0, Bid, 3, Ask + (40 * Point), Ask - (signalLine - macdLine), NULL);
   }

   return(0);
}

Can someone help with this?

 

Please EDIT your post and use the CODE button (Alt-S) when you insert code in your post.

Code button in editor

Thank you.
 
  1.    double macdLine = iMACD("EURUSD", PERIOD_M1, 12, 26, 9, PRICE_CLOSE, MODE_MAIN, 0);

    Why did you post your MT4 question in the MT5 General section instead of the MQL4 section, (bottom of the Root page)?
              General rules and best pratices of the Forum. - General - MQL5 programming forum? (2017)
    Next time, post in the correct place. The moderators will likely move this thread there soon.

  2. Do not post code that will not even compile.

    void OnTick(void)
      {
       double macdLine;
       double signalLine;
       double macdHist;
    0     <<<<<<<<<<<<<<<<<<<< OnTick not closed.
    int start()
    {
  3. Use the modern event calls. Do not mix them.
              Event Handling Functions - MQL4 Reference
              How to do your lookbacks correctly - MQL4 programming forum #9-14 & #19 (2016)

 
William Roeder #:
  1. Why did you post your MT4 question in the MT5 General section instead of the MQL4 section, (bottom of the Root page)?
              General rules and best pratices of the Forum. - General - MQL5 programming forum? (2017)
    Next time, post in the correct place. The moderators will likely move this thread there soon.

  2. Do not post code that will not even compile.

  3. Use the modern event calls. Do not mix them.
              Event Handling Functions - MQL4 Reference
              How to do your lookbacks correctly - MQL4 programming forum #9-14 & #19 (2016)

Hi William, 

Thanks for the reply.

I am new to all this and don't know the reason it is not compiling. 

Just wanted help to fix the code I posted above. 

Thanks 

 
S Avraam:

I get unexpected end of program and unbalanced parentheses on the below code

Can someone help with this?

void OnTick(void)
  {
   double macdLine;
   double signalLine;
   double macdHist;
}
int start()
{
   macdLine = iMACD("EURUSD", PERIOD_M1, 12, 26, 9, PRICE_CLOSE, MODE_MAIN, 0);
   signalLine = iMACD("EURUSD", PERIOD_M1, 12, 26, 9, PRICE_CLOSE, MODE_SIGNAL, 0);
   macdHist = iMACD("EURUSD", PERIOD_M1, 12, 26, 9, PRICE_CLOSE, MODE_HIST, 0);

   if(macdLine > signalLine + 0.0008)
   {
      OrderSend(Symbol(), OP_BUY, 1.0, Ask, 3, Bid - (40 * Point), Bid + (macdLine - signalLine), NULL);
   }
   else if(macdLine < signalLine - 0.0008)
   {
      OrderSend(Symbol(), OP_SELL, 1.0, Bid, 3, Ask + (40 * Point), Ask - (signalLine - macdLine), NULL);
   }

   return(0);
}
 
Arpit T #:

Can this be compiled at all?

Variables are declared in OnTick function and then used in start() function?

Original "code" very much looks like another ChatGPT pearl.