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

 
PapaYozh:

This one goes from index zero, i.e. from the beginning.

I'm confused...you're absolutely right!
 
PapaYozh:

This one searches from zero index, i.e. from the beginning.

PapaYozh:

This one goes from zero index, i.e. from the beginning.

Ahh... Now it all makes sense, thank you.

 
Maxim Kuznetsov:

for(int i=OrdersTotal()-1;i>=0;i--) {

   if (! OrderSelect(i,SELECT_BY_POSITON,MODE_TRADES)) continue;

   double prosad=DBL_MIN;

   if (OrderType()!=OP_BUY && OrderType!=OP_SELL) continue;

   for(int j=iBarShift(OrderSymbol(),OrderOpenTime(),PERIOD_M1); j>=0;j--) {

      double delta=( OrderType()==OP_BUY? OrderOpenPrice()-iLow(OrderSymbol(),PERIOD_M1,j) : iHigh(OrderSymbol(),PERIOD_M1,j)-OrderOpenPrice() );

      delta /= MarketInfo(OrderSymbol(),MODE_POINT);

      if (delta>prosad) prosad=delta;

   }

  PrintFormat("Максимальная просадка по ордеру %d = %d пунктов , %f денег",OrderTicket(),(int)(prosad),prosad*OrderLots()*MarketInfo(OrderSymbol(),MODE_TICKVALUE);

}

written "by hand", untested, full of errors :-) adjust it to your needs and use it

please tell me what -"!" means in your code ?

i don't understand it too well yet

or maybe someone else can explain it to me, besides the author?

 
законопослушный гражданин:

please tell me, what does -"!" mean in your code?

I don't really understand it yet.

or can someone else explain it to me besides the author?

! - this is a boolean negation, NOT

if { !OrderSelect() } translates to "if OrderSelect is NOT successful"

!= respectively "NOT equal"

 
Maxim Kuznetsov:

! - is a Boolean negation, NOT

if { !OrderSelect() } translates as "if NOT successful OrderSelect"

!

thanks

 
Maxim Kuznetsov:

for(int i=OrdersTotal()-1;i>=0;i--) {

   if (!OrderSelect(i,SELECT_BY_POSITON,MODE_TRADES)) continue;

   double prosad=DBL_MIN;

   if (OrderType()!=OP_BUY && OrderType!=OP_SELL) continue;

   for(int j=iBarShift(OrderSymbol(),OrderOpenTime(),PERIOD_M1); j>=0;j--) {

      double delta=( OrderType()==OP_BUY? OrderOpenPrice()-iLow(OrderSymbol(),PERIOD_M1,j) : iHigh(OrderSymbol(),PERIOD_M1,j)-OrderOpenPrice() );

      delta /= MarketInfo(OrderSymbol(),MODE_POINT);

      if (delta>prosad) prosad=delta;

   }

  PrintFormat("Максимальная просадка по ордеру %d = %d пунктов , %f денег",OrderTicket(),(int)(prosad),prosad*OrderLots()*MarketInfo(OrderSymbol(),MODE_TICKVALUE);

}

written "by hand", not checked, has a lot of errors :-) adjust it to your needs and use it

I may have "cleaned up" the code, but this line shows a warning for(int j=iBarShift(OrderSymbol(),OrderOpenTime(),PERIOD_M1); j>=0;j--)

possible loss of data due to type conversion

Can't figure out what's wrong?

 
законопослушный гражданин:

I seem to have "cleaned up" the code, but on this line for(int j=iBarShift(OrderSymbol(),OrderOpenTime(),PERIOD_M1); j>=0;j--) the warning appears:

possible loss of data due to type conversion

I can't figure out what's wrong?

I mixed up the parameters...it's a common mess when it's written "on the fly" right into the forum bypassing the terminal

iBarShift(OrderSymbol(),PERIOD_M1,OrderOpenTime()) should be

 
Maxim Kuznetsov:

Parameters mixed up...common confusion when writing "on the fly" directly into the forum bypassing the terminal

iBarShift(OrderSymbol(),PERIOD_M1,OrderOpenTime()) should be

thanks

 
законопослушный гражданин:

I seem to have cleaned up the code, but on this line for(int j=iBarShift(OrderSymbol(),OrderOpenTime(),PERIOD_M1); j>=0;j--) the warning appears:

possible loss of data due to type conversion

I can't figure out what's wrong?

I can't really understand what's wrong? Can I attach this whole "thing" to my Expert Advisor and run it through the strategy tester with output of the information in the test report?

will it work?

 

Any tips on how to deal with this?

In the tester on the history a simple order opening sometimes causes an error...

OrderSend(_Symbol,OP_SELL,0.5,Bid,0,0,0,NULL,0)
2021.08.26 14:56:33.375 2017.08.07 08:00:00  Trader EURUSD,H1: OrderSend error 3

ERR_INVALID_TRADE_PARAMETERS - what the hell is this and what does it mean?

Reason: