[ARCHIVE!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Can't go anywhere without you - 4. - page 477

 
Thank you! I'll look for it!
 
Can't cope with this Pause-Break emulation, it's not working!
//+------------------------------------------------------------------+
//|                                                     советник.mq4 |
//|                        Copyright 2012, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright 2012, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#include <WinUser32.mqh>
  extern double  lot=1;                          
  extern int taymfreym=0 ;                           
  extern double  stoplos=20 ;                          
  extern double  takeprofit=50 ; 
  extern double  magicnumber=350 ;                          


void BreakPoint(){if (!IsVisualMode()) return(0);keybd_event(19,0,0,0);
Sleep(10);
keybd_event(19,0,2,0);}

//+------------------------------------------------------------------+
//| expert initialization function                                   |
----------------------------------+
int start()
  {
//----

            
            double strela1 = iCustom(NULL, taymfreym, "индикатор", 2, 1);
            double strela2 = iCustom(NULL, taymfreym, "индикатор", 3, 1);
            
            int BUY=0,SELL=0;int ticket; 
            Print (  " strela1 " , strela1 , "   strela2  " , strela2 );BreakPoint();
            
    
            
            for(int i=1; i<=OrdersTotal(); i++) {  
            if (OrderSelect(i-1,SELECT_BY_POS)==true) // Если есть следующий
        {                                       // Анализ ордеров:
         if (OrderSymbol()!=Symbol( ) )continue;      // Не наш фин. инструм
         if (OrderMagicNumber( ) !=magicnumber)continue;
         if (OrderType()==0){ BUY++; ticket=OrderTicket( );}
         if (OrderType()==1) {SELL++;ticket=OrderTicket( );}    } }
         
   if (strela1>strela2&&BUY==0&&SELL==0){    
            
           OrderSend( NULL, OP_BUY, lot, Ask, 3, NormalizeDouble( Bid- (stoplos*Point),Digits),  
 NormalizeDouble( Ask+( takeprofit*Point),Digits), NULL, magicnumber, 0, CLR_NONE);  
            Print( "strela1>strela2&&BUY==0&&SELL==0   " , GetLastError());BreakPoint(); }
           
   if (strela1<strela2&&BUY==0&&SELL==0){  
   
            OrderSend( NULL, OP_SELL, lot, Bid, 3, NormalizeDouble( Ask- (stoplos*Point),Digits),  
 NormalizeDouble( Bid+( takeprofit*Point),Digits), NULL, magicnumber, 0, CLR_NONE) ; 
            Print( "strela1<strela2&&BUY==0&&SELL==   " , GetLastError());BreakPoint(); }
 
AA! 2012.10.30 14:07:08 2012.06.05 05:30 EA EURUSD,M30: dll calls are not allowed; 'user32.dll'-'keybd_event' I think I figured it out. How do I unlock the dll?
 
Nah, it seems fine!!!
 
Buffers are always 0 in the test !!! To hell with it, I'll test it on the real - I'll write a forwards cycle 200 bars backwards, and look for entry points!
 
Excuse me, I've been looking for half an hour to find out where my brackets are out of balance, or what's the meaning of this? I put in the prints and here goes... It doesn't compile, but it swears '\end_of_program' - unbalanced left parenthesis C:\Alpari\experts\customer.mq4 (94, 1)
 
Here, I'm sorry... I re-checked the brackets eight times -- well, they're balanced! Balanced! Or are they?
//+------------------------------------------------------------------+
//|                                                     советник.mq4 |
//|                        Copyright 2012, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright 2012, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#include <WinUser32.mqh>
  extern double  lot=1;                          
  extern int taymfreym=0 ;                           
  extern double  stoplos=20 ;                          
  extern double  takeprofit=50 ; 
  extern double  magicnumber=350 ;                          


void BreakPoint(){if (!IsVisualMode()) return(0);keybd_event(19,0,0,0);
Sleep(10);
keybd_event(19,0,2,0);}

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   Print (   "  init " ); 
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {Print (   "  Начало " ); 
//----
for( int A=0; A<100 ; A++){
            
            double strela1 = iCustom(NULL, taymfreym, "индикатор", 2, A);
            double strela2 = iCustom(NULL, taymfreym, "индикатор", 3, A);
            
            int BUY=0,SELL=0;int ticket; 
            Print ( A,  "  strela1 " , strela1 , "    strela2  " , strela2 ); 
            
    
            
            for(int i=1; i<=OrdersTotal(); i++) {  
            if (OrderSelect(i-1,SELECT_BY_POS)==true) // Если есть следующий
        {                                       // Анализ ордеров:
         if (OrderSymbol()!=Symbol( ) )continue;      // Не наш фин. инструм
         if (OrderMagicNumber( ) !=magicnumber)continue;
         if (OrderType()==0){ BUY++; ticket=OrderTicket( );}
         if (OrderType()==1) {SELL++;ticket=OrderTicket( );}    } }
         
   if (strela1>strela2&&BUY==0&&SELL==0)    {    
            
           OrderSend( Symbol( ), OP_BUY, lot, Ask, 3, NormalizeDouble( Bid- (stoplos*Point),Digits),  
          NormalizeDouble( Ask+( takeprofit*Point),Digits), NULL, magicnumber, 0, CLR_NONE); 

 
            Print(
          "strela1>strela2&&BUY==0&&SELL==0   " , GetLastError()  ,"  Ask ",Ask,
     "   NormalizeDouble( Bid- (stoplos*Point),Digits)  ", NormalizeDouble( Bid- (stoplos*Point),Digits),"  
         NormalizeDouble( Ask+( takeprofit*Point),Digits) ", NormalizeDouble( Ask+( takeprofit*Point),Digits)); }
           
   if (strela1<strela2&&BUY==0&&SELL==0){  
   
            OrderSend( Symbol( ), OP_SELL, lot, Bid, 3, NormalizeDouble( Ask- (stoplos*Point),Digits),  
           NormalizeDouble( Bid+( takeprofit*Point),Digits), NULL, magicnumber, 0, CLR_NONE) ; 
            Print( "strela1<strela2&&BUY==0&&SELL==   " , GetLastError()  ,"  Bid ",Bid,
   "   NormalizeDouble( Ask- (stoplos*Point),Digits)  ", NormalizeDouble( Ask- (stoplos*Point),Digits),
  "    NormalizeDouble( Bid+( takeprofit*Point),Digits) ", NormalizeDouble( Bid+( takeprofit*Point),Digits); }
            
 
   if (strela1>strela2&&BUY==0&&SELL!=0){ 

         OrderSelect(ticket, SELECT_BY_TICKET);
       OrderClose(  ticket , OrderLots( ) , OrderOpenPrice( ) , 3, CLR_NONE);                 
       OrderSend(Symbol( ), OP_BUY, lot, Ask, 3, NormalizeDouble( Bid- (stoplos*Point),Digits), 
       NormalizeDouble( Ask+( takeprofit*Point),Digits), NULL, magicnumber, 0, CLR_NONE);           
       Print( "strela1>strela2&&BUY==0&&SELL!=0 " , GetLastError());BreakPoint(); }
            

  if (strela1<strela2&&SELL==0&&BUY!=0){ 
   OrderSelect(ticket, SELECT_BY_TICKET);
   OrderClose(  ticket , OrderLots( ) , OrderOpenPrice( ) , 3, CLR_NONE);                 
   OrderSend(Symbol( ), OP_SELL, lot, Bid, 3, NormalizeDouble( Ask- (stoplos*Point),Digits),  
 NormalizeDouble( Bid+( takeprofit*Point),Digits), NULL, magicnumber, 0, CLR_NONE) ; 
        Print( "strela1<strela2&&SELL==0&&BUY!=0 " , GetLastError());BreakPoint(); }
      
      
            
     } Print (   "  Конец " );      
//----
   return(0);
  }
//+------------------------------------------------------------------+
 
Dimka-novitsek:
I'm sorry, I've been looking for half an hour for brackets which are out of balance. I just put in the prints and there you go... It doesn't compile, but it swears '\end_of_program' - unbalanced left parenthesis C:\Alpari\experts\customer.mq4 (94, 1)

at first glance, the very last curly bracket (for main()) is missing

Your code ends with a branching

  if (strela1<strela2&&BUY==0&&SELL==0){  
   
            OrderSend( NULL, OP_SELL, lot, Bid, 3, NormalizeDouble( Ask- (stoplos*Point),Digits),  
 NormalizeDouble( Bid+( takeprofit*Point),Digits), NULL, magicnumber, 0, CLR_NONE) ; 
            Print( "strela1<strela2&&BUY==0&&SELL==   " , GetLastError());BreakPoint(); }

ps this is for the code above

 
Thank you!!! I'd better take a look at the code... I also counted the brackets one by one on a piece of paper - balanced!!!
 
Where's the branching? Or am I stupid... I mean, we just open an order under the conditions!
Reason: