[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 419

 
melnikas:

Is my case such a difficult one?

double ExtVolumesBuffer[];

you are right about the location. You should specify the size of the array before using it. Or make it another buffer

 
//+------------------------------------------------------------------+
int deinit()
  {    
  return(0);
  }
//+------------------------------------------------------------------+
int start()
  {
  f1(); //Как сделать, что-бы после вызова функции, программа могла остановиться?
  Alert("Есть сигнал"); // И до этого места работа программы бы не дошла
  return(0);
  }
//+------------------------------------------------------------------+  
  int f1()
    {
    return(f2());
    }
//+------------------------------------------------------------------+    
  int f2()
    {  
    return(deinit()); //Тут, по задумке, нужно остановить работу всей программы
    }
//+------------------------------------------------------------------+  
Or, from a called function, the operation of the program cannot be stopped? (Example code to be used in the indicator)
 
fore-x:
Or, from a called function, the program cannot be stopped? (Example code, to be used in the indicator)
return(deinit());

What do you mean by stop? remove the EA/indicator from the graph?


about deinit():

the call of deinit does not lead to the deactivation of the indicator/indicator, but the deactivation leads to the call of deinit

 
ilunga:

What do you mean by stop? remove the EA/indicator from the graph?


about deinit():

it is not the call to deinit that causes the indicator/expert to be disabled, it is the disabling that causes deinit to be called

Stop means to stop the execution of the start function - from the called function. Like return(0).

About deinit, I'm aware of it, that's why I don't know how to solve this conundrum. Apparently you can't do it that way.

 
fore-x:

Stop means to stop the execution of the start function - from the called function. Like return(0).

About deinit, I know, that's why I don't know how to solve this puzzle. Apparently you can't do it that way.

Then what prevents you from returning (-1) or something else with this function and making a call to this function in start() with a check? for example, like this:

int start()
  {
  if (f1() == -1) return (0);
  Alert("Есть сигнал"); // И до этого места работа программы бы не дошла
  return(0);
  }
//+------------------------------------------------------------------+  
  int f1()
    {
if (все плохо) return (-1); else return(0);
    }
 
ilunga:

Then what prevents you from returning (-1) or something else with this function and making a call to this function in start() with a check? for example like this:

//+------------------------------------------------------------------+
int start()
  {
  if(f1() < 0) return(0);
  Alert("Есть сигнал"); // И до этого места работа программы бы не дошла
  return(0);
  }
//+------------------------------------------------------------------+  
  int f1()
    {
    return(f2());
    }
//+------------------------------------------------------------------+    
  int f2()
    {  
    return(-1); //Тут, по задумке, нужно остановить работу всей программы
    }
//+------------------------------------------------------------------+  
I understand you, just wanted to avoid unnecessary movements in the code, clarified. Thanks for the example!
 
ilunga:

you are right about the location. You should specify the size of the array before using it. Or make it another buffer

Thank you very much!
 


dkfl.zrjdktdbx 09.12.2011 16:56

Good evening, I've encountered that the trading robot doesn't close positions, about once in 50, when it reaches a profit. It then has to close everything, pending orders and all, and set up again. Not closing creates order confusion and drawdown.


So imagine, sometimes it turns out that an order closed at takeprofit, Clowes Price - order closing price - equals zero!!!!!

See the fifth line in the screenshot below, it is the fifth line, the order closed on takeprofit. And in the ninth line from the bottom Closing price of the order is equal to zero!!!!!

It seems there is nothing particularly complicated in the code... I'll show it to you right now.

When I place an order, I save the time in the wremjapomnim window. As soon as any order is closed at currentprofit, I delete all orders and again remember the time in the wremjapomnim pyrimen and set them.

for ( i=OrdersHistoryTotal();i>0;i--){ OrderSelect(i-1,SELECT_BY_POS,MODE_HISTORY  );
Alert( "wremjapomnim " ,wremjapomnim, "  OrderCloseTime(        )   ",  OrderCloseTime( ),  " ",i , " OrderTakeProfit( ) " ,OrderTakeProfit( ),
  " OrderClosePrice(    )  ",OrderClosePrice(   ) );
if ( OrderTakeProfit( )==OrderClosePrice(       )&&wremjapomnim<OrderCloseTime( )|| (NormalizeDouble(OrderClosePrice()-OrderTakeProfit(), Digits)<2*Point)
   &&wremjapomnim<OrderCloseTime(       )|| (NormalizeDouble(OrderClosePrice()-OrderTakeProfit(), Digits)>-2*Point)&&wremjapomnim<OrderCloseTime(       )){C=0;A=1 ;  Alert("C",C,"A",A);
   for ( int ii=OrdersTotal();ii>0;ii--){ OrderSelect(ii-1,SELECT_BY_POS );
   if( OrderMagicNumber( )==2000 &&OrderSymbol()==Symbol()|| OrderMagicNumber( )==1000 &&OrderSymbol()==Symbol()){ 
  OrderDelete(OrderTicket( )) ; Alert ("OrderDelete-vse",  GetLastError( ) ); stsBUY=0;stsSELL=0;
   OrderClose( OrderTicket( ), OrderLots( ), OrderClosePrice( ) , 0, CLR_NONE);Alert ("OrderClose-vse",  GetLastError( ) ); C=0; }     }              }
   
                                                      } 
 
The alert is in the second and third lines of the code and writes everything in the log, including the fact thatOrderClosePrice( ) of order 49 is equal to zero.
 

Tell me how to track the formation of a fractal in the EA. I need to open an order after the formation of a new fractal. I do not know how this indicator works; it has some kind of upper line and some kind of lower line.

If, for example, a fractal is formed and the price breaks that minimum, will the fractal be re-drawn or will I just add another fractal?

 
Hello, could you please tell me how to find the low and high of the last candle for example