Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1471

 
ANDREY:

I have found one stable statistical pattern in the tester, which has been steadily producing profits with acceptable drawdowns since 2008. I need to test it on different pairs and frames etc.
But I need to test it using several parameters simultaneously. Optimization takes unreal much time. And I've already written a code that tests what I need much faster. And now I'm improving my code, i.e. I want it to work even faster in the tester, or as fast as possible. The main algorithm in my code is opening orders at 30 points after each local minimum. So I try to do it as quickly as possible.

Your task will be easier if you can explain how you identify the local extremum.

If the Fractals indicator is suitable for that, then you should check on the second bar for the presence of a fractal and from this value you should calculate the necessary 30 points or pips... whatever you like.

 
MakarFX:

The check in your code is not a load, but if you really want to try it, try it.

Tried it. Opens the wrong orders again (in terms of time, price and quantity)

Your code.

double LoU;
int OnInit()
  {
   LoU=Bid;
  }
//+------------------------------------------------------------------+
void OnTick()
  {
   if(Low[1]<LoU) {LoU=Low[1];}
   if ((Bid-30*Point)>=LoU)
     {
      if(OrderSend(Symbol(),OP_SELL,0.1,Bid, 3,0,0,"300",0)) LoU=Bid;
     }
  }


Thanks for the help.

 
Alexey Viktorov:

Your task will be easier if you can explain how you identify the local extremum.

If the Fractals indicator is suitable for that, then you check on the second bar for the presence of a fractal and count the necessary 30 points or pips... whatever you like.

If by an extremum we mean the local minimum after which the order is opened, this minimum is defined by checking the minimum price value on each tick or candlestick. And this is exactly what I am struggling with. I want everything to happen much faster in order to open orders at positions I need.

 
ANDREY:

If an extremum is understood to be a local low after which an order is opened, that low is determined by checking the minimum price value on each tick or candlestick. And this is exactly what I am struggling with. I want everything to happen much faster in order to open orders at positions I need.

The extremum is a local minimum or a local maximum. How do you define it?

 
Alexey Viktorov:

Your task will be easier if you can explain how you identify the local extremum.

If the Fractals indicator is suitable, then you check on the second bar for the presence of a fractal and from this value you calculate the necessary 30 points or pips... whatever you like.

I think the fractal indicator does not suit me. It will miss many orders.

The order opened by my code with the price check at each tick is highlighted in blue. I think, the fractal indicator does not say anything necessary to me in this case.

 
Alexey Viktorov:

An extreme is a local minimum or local maximum. How do you define it?

In my case, it is a minimum.

 
ANDREY

What is it

Pr

how is it initialised?

 
MakarFX:
It depends on where you put it

For example between the opening of two adjacent orders. That is, remember the bar of the last open order and open an order as soon as the price is above the low that this function defines by 30 points. But in this case, this function has to be called on every tick. Change the shill for the soap.......

 
ANDREY:

Changing a shill for a soap.......

Even worse...still need to know the number of bars


I tweaked ...try

 
MakarFX:

What is it

how is it initialised?

double LoU,Pr;
void OnTick()//484
{
Tick++;
if (Bid<LoU)
LoU=Bid;
//**************************************************************||TimeCurrent()==1262568096
if (Bid-LoU>=0.0030&&Pr!=LoU)
{
OrderSend(Symbol(),OP_SELL,0.1,Bid, 3,0,0,"300",0);
Print("---------------------КАЖДЫЙ ТИК ------Tick---------=     "    ,   Tick);
Pr=LoU;
LoU=Bid;
}
}
Pr is a variable so that only 1 order is opened after 30 pips. Without this variable they open on every tick