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

 
Maxim Kuznetsov:

just to add, it is NOT GUARANTEED that the terminal has and will give sufficient history.

in the above example there is no reference to history

so it is guaranteed that the result of OrderSelect() is true

UPD: OrderSelect in 4 works very well, tested it once - for market orders the time of access to order properties.... it really is millions of times per second, i don't want to look it up, i think i was arguing with moderator Artem, but it's like they say "all tiptoes differ", if you like it, keep it

 

Hello, there is a need for data on the drawdown of each transaction.

Can anyone meet a script to collect such statistics and output in the form of a report?

Thank you

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

Hello, there is a need for data on the drawdown of each transaction.

Can anyone meet a script to collect such statistics and output in the form of a report?

Thanks

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);

}

it is "handwritten", untested, full of bugs :-) just tweak it to your needs and use it

 
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, full of errors :-) adjust to your needs and use

thanks, I'll try to figure it out!

 
@Igor Makanu, thank you very much for your answers about sorting orders in the terminal. I'll probably save them as an array of structures and sort it myself. My doubts were mainly because I feared that such actions performed on every tick would have a noticeable negative impact on performance.
 
Janis Ozols:
@Igor Makanu, thank you very much for your answers about sorting orders in the terminal. I'll probably save them as an array of structures and sort it myself. Doubts were mainly because I feared that such actions performed on every tick would have a noticeable negative impact on performance.

So why sort on every tick? Enough only when the number of entries changes or the list changes completely...

 
Good afternoon Please help me to understand why the downloaded indicator from the navigator is not dragged to the chart. It is in the catalogue.
Files:
image002.jpg  38 kb
 
Afternoon. If there is no automatic loading of the indicator tool from the marketplace intothe trading terminal, what is the problem?
 
Igor Makanu:

in the above example there is no reference to history

so it is guaranteed that the result of OrderSelect() is true

UPD: OrderSelect in 4 works very well, I was testing it once - for market orders the time of access to order properties.... it really is millions of times per second, i don't want to look it up, i think i was arguing with moderator Artem, but as they say "all tip-toes are different", i like it - keep it

Moderator Artem is not arguing. Moderator Artem is debating :)
 
void OnTick()
  {
    if(isCrossing() == 1)          
      
    ... 

    if(isCrossing() == 2)
      
    ... 
  }

int isCrossing(){  
  double ma = iMA(NULL, g_timeFrame, g_maPeriod, g_maShift, g_maMethod, g_maApplietPrice, 0);
  double low = iLow(Symbol(), g_timeFrame, 0);
  double high = iHigh(Symbol(), g_timeFrame, 0);

  if(g_barTime < iTime(NULL,g_timeFrame,0) && high > ma && Bid <= ma){
    g_barTime = iTime(NULL,g_timeFrame,0);
    return 1;
  } 
  
  if(g_barTime < iTime(NULL,g_timeFrame,0) && low < ma && Bid >= ma){
    g_barTime = iTime(NULL,g_timeFrame,0);
    return 2;
  }
   
  return 0;
}
Why does isCrossing() not return 2??? The isCrossing() itself has a second if entry, but then there is no if entry in OnTick() when isCrossing() == 2. What is this nonsense...
Reason: