[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 403

 
ruslanchik:
Please tell me how to calculate stacksize

Be more specific with your question.
 

Is it possible to skip an unnecessary step in optimization and go to the next one?

Example: there are input parameters(type double) which need to be optimized: x1, x2, x3, x4. Their values are from 1 to 5. Step 0.1

It is clear that in this case there will be 41*41*41*41=2,825,761

But we need to search in the following constraint: 10.5 < x1+x2+x3+x4 < 11.5. It is already clear here that there will be many fewer search variants. (this is the very restriction on the sum needed)

So if this restriction is added to the Expert Advisor's code like this

extern double    x1=1, x2=1, x3=1, x4=1;

int start()

{

  if (10.5<x1+x2+x3+x4 && x1+x2+x3+x4<11.5)

    {
      // основной код эксперта 

    }
  return; 

} 

then during optimization (when each new tick arrives), the unsuitable variants will also be taken, for example x1=4, x2=4, x3=4, x4=4; what exactly will not happen -- is the execution of the main code.

That is, as long as this optimization step does not "run through" the historical interval, there will be no transition to the next step. There will be a "conviction" that the condition 10.5 < x1+x2+x3+x4 < 11.5 is not fulfilled and it will only stop the execution of the main code

The time will be greatly wasted on such obviously unsuitable variants

How can we exclude such steps in optimization with obviously unsuitable parameters?

That is, when another set of parameters becomes unsuitable, this step should not be optimized but passed to a new one immediately?

 
fmql:

Is it possible to skip an unnecessary step in the optimisation and move on to the next one?


it is possible to optimise 3 parameters and adjust the fourth for the desired amount.

or use the third tab "Optimisation" to generate the required event spontaneously.

 
sergeev:

it is possible to optimise 3 parameters and adjust the fourth for the required amount.

or use the third tab "Optimisation" to generate the desired event spontaneously.

The point is that it is impossible to optimise 3 parameters without the 4th parameter in my case.

Here it is their joint selection that is important and their sum is limited in the interval.

(it is approximately like searching for shares of all components in a mixture and the total mass of this mixture is limited to a strict interval)

Can you tell me more about the third tab, what is this spontaneous generation of the desired event ?

 

Good afternoon.

Can you tell me how to extract candle values (High, Low, Open, Close) of the last extremum of the ZigZag indicator ?

 
Same as for any other candle. The same functions. ( Think diameter of your planet.(c) )
 
If you want to get the bar number of the last extremum itself, use the object name of the last ray to get the time of the first coordinate, which will correspond to the time of the bar. Using the bar time, determine the bar number. Determine the characteristics of the bar from the bar number.
 
fmql:

Could you elaborate on the third tab, what is the spontaneous generation of the desired event?


More in detail in the help

In brief, you can create your own conditions for the point on the third tab (for example, open 10 losing orders in a row) and the tester will automatically skip this run and move on to the next one.

 
Stells:

Good afternoon.

Can you tell me how to extract candle values (High, Low, Open, Close) of the last extremum of the ZigZag indicator ?


Such an operation requires some calculations.

I used to do it this way:

int start()
  {
 double // экстремумы Зиг-Зага
  y3=0, 
   y2=0,
    y1=0,
     y0,
     zz;   
 int    x3, x2, x1, sh=ShiftBars;// номера баров  

  y0=iCustom(NULL, 0, "ZigZag", ExtDepth, ExtDeviation, ExtBackstep, 0, 1);

//=============================================================================
  // Берём три экстремума Зиг-Зага
   while (y3==0) 
      {
      zz=iCustom(NULL, 0, "ZigZag", ExtDepth, ExtDeviation, ExtBackstep, 0, sh);
      if (zz!=0 && zz!=EMPTY_VALUE) 
         {
         if      (y1==0) { x1=sh; y1=zz; }
         else if (y2==0) { x2=sh; y2=zz; }
         else if (y3==0) { x3=sh; y3=zz; }
         }
      sh++;

//----- Вывод информации на экран -----------------------------------------------
string info="";
string on_off="---------------------------------------------------"+  "\r\n";

on_off=StringConcatenate (on_off,"Экстремум= ",y1," на ",x1," баре","\r\n");
on_off=StringConcatenate (on_off,"Экстремум= ",y2," на ",x2," баре","\r\n");
info=StringConcatenate(info,on_off,"\r\n");
info=StringConcatenate(info,"\r\n");
Comment(info);    

Now you know the bar numbers on the last 2 extrema (min and max) and then their highs, lows.... easy to find !

- Close[x1], Open[x2], .... etc.

Perhaps someone will suggest a simpler option.

 
Can't organise a loop, X and Y are always 0.
//+------------------------------------------------------------------+
//|                                                    для лавин.mq4 |
//|                      Copyright © 2011, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2011, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"
extern double stoploss=0; extern double takeprofit=20;extern int otstup=20; extern datetime expiration=0;

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
 int tiket,tikett;double volume=0.1;int i=0,R1=0,R2=0,A=1 ;double price=PRICE_OPEN;
   //  R1=((PRICE_OPEN- stoploss*Point)*stoploss)/stoploss;R2=((PRICE_OPEN+ stoploss*Point)*stoploss)/stoploss;
     
     
int start()
  {       int X,Y; double price=(Ask+Bid)/2;            
//----
       Alert ("OrdersTotal()",OrdersTotal());

if(OrderSymbol()==Symbol()&&OrderMagicNumber( )==1000){
 for(int i=OrdersTotal();i==0;i--){
OrderSelect(i,SELECT_BY_POS );if(OrderType( )==OP_BUYSTOP){X++;}}}Alert ("X", X);
if (X==0){


   tiket= OrderSend( Symbol(), OP_BUYSTOP,  volume*A, price +otstup*Point, Point* 3, R1, price+takeprofit*Point+otstup*Point, "OP_BUYSTOP", 1000,  expiration, Red); 
   Alert ("OP_BUYSTOP", GetLastError( )); }
   
if( OrderMagicNumber( )==2000 &&OrderSymbol()==Symbol()) { 
  for( i=OrdersTotal();i==0;i--){OrderSelect(i,SELECT_BY_POS );
if(OrderType( ) ==OP_SELLSTOP) { Y++;}}}Alert ("Y", Y);
 if (Y==0){ 
   tikett= OrderSend( Symbol(), OP_SELLSTOP,  volume*A, price -otstup*Point, Point* 3,R2, price-takeprofit*Point-otstup*Point, "OP_SELLSTOP" , 2000,  expiration,C'0,128,255' );
    Alert ("OP_SELLSTOP", GetLastError( )); 
    }       
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
Reason: