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

 
VOLDEMAR:
When you run it in real life " step*point will become > current loss, then profit will come to you" you'll see your profit becomes a fixed minus .... Because of the broker's work ... I didn't set the take profit for nothing, it's already checked ..........
You are an odd one. My post is another answer to your question. It's just another way. But it is more visually comprehensible.
 
Could you please tell a novice programmer how to select the last closed trade using the OrderSelect function? I tried the following way: OrderSelect(1,SELECT_BY_POS,MODE_HISTORY), but apparently no order is selected this way...
 
someone please implement this advisor idea:

Idea number 5 TS - Own Pattern ( Sample ). There is a drawing there too. The TS and trading criteria are simple and

It will not take a good programmer much time. Doesn't anyone want to see the results?
 
Please advise if you know how to do a 1:1 leverage test ?
 

Try opening a demo account with 1:1 leverage. And test it.

Will it work?


 
Moslift:
Could you please tell a novice programmer how to select the last closed trade using the OrderSelect function? I tried to do it this way: OrderSelect(1,SELECT_BY_POS,MODE_HISTORY), but apparently no order is selected this way...


Take a look here: https://www.mql5.com/ru/forum/131859

-page #4
GetTypeLastClosePos - Returns the type of the last closed position or -1
GetTypeLastOpenPos - Return the type of the last opened position or -1
isCloseLastPosByStop - Returns the flag of the last position closed by Stop
isCloseLastPosByTake - Returns the flag to close the last position by Take.
isLossLastPos - Returns the flag of loss of the last position.
isTradeToDay - Returns the flag of trading today
NumberOfBarCloseLastPos - Returns the bar close number of the last position or -1.
NumberOfBarOpenLastPos - Returns the bar number of the last position opened or -1.
NumberOfLossPosToday - Returns the number of losing positions closed today.
PriceCloseLastPos - Returns the closing price of the last closed position.

 
Moslift:
Can you advise a novice programmer, how to select the last closed order using OrderSelect function? I tried to do it this way: OrderSelect(1,SELECT_BY_POS,MODE_HISTORY), but apparently no order is selected this way...

Try it this way:

   int      i, j;
   datetime t;
   for (i=0; i<OrdersHistoryTotal(); i++) {           // Цикл по закрытым ордерам терминала
      if (OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)) {// Если выбран ордер...
         if (OrderType()>1)               continue;   // ... если его тип не Buy и не Sell, переходим к следующему...
         if (OrderSymbol()!=Symbol())     continue;   // ... если его символ не соответствует символу графика - к следующему...
         if (OrderMagicNumber()!=Magic)   continue;   // ... если его магик не соответствует магику советника (в переменной Magic) - к следующему
         if (OrderCloseTime()>t) {                    // ... если время его закрытия больше предыдущего
            t=OrderCloseTime();                       // ... сохраним новое наибольшее время закрытия, ...
            j=i;                                      // ... сохраним индекс ордера в массиве закрытых ордеров
            }                   
         }
      }
   if (OrderSelect(j,SELECT_BY_POS,MODE_HISTORY))     // На этом этапе j содержит индекс последнего закрытого ордера
      Print("Выбран последний закрытый ордер с тикетом ",OrderTicket());

Note that only Buy or Sell is checked in the loop. Hopefully you will be able to make a selection of other order types based on this

ZS... I was writing on my hands and might have missed a mistake somewhere...

 

Please tell me why this function does not work and how to make it work?


nomer_sdelki=OrderSend(Symbol(),OP_SELL,1,Bid,3, Bid-10*Point,Ask+10*Point, "My order #"+1,16384,0,Green);

------------------------------------------------------------------------------------------------------------------------

And this is how it works!!!

nomer_sdelki=OrderSend(Symbol(),OP_SELL,koefficent,Bid,3,0,0, "My order #"+1,16384,0,Green);

i.e. when no stops are set it works.

------------------------------------------------------------------------------------------------------------------------------

This function doesn't work either, how can I fix it?

OrderClose(nomer_sdelki,koefficent,Bid,3,Red);


-----------------------------------------------------------------------------------------------------------------------------------



 
leonid553:

Try opening a demo account with 1:1 leverage. And test it.

Will it work?


Senx ( Thank you ) :))
 

It's a miracle...

There was a message and then there wasn't...

I'll answer: Is this what it takes?

// ----------------- SchBuyLs() ---------------------------------------------
//  Функция возвращает суммарный лот Бай-ордеров 
//----------------------------------------------
double SchBuyLs_b() {
   double SchBuyLs=0;
   int i;
   string SMB=Symbol();
   for (i=OrdersTotal()-1; i>=0; i--) {                  //Начало цикла
      if (!OrderSelect(i, SELECT_BY_POS)) WriteError(i);
      else  {                                            //начало работы с выбранным ордером
         if (OrderSymbol()!=SMB)    continue;
         if(OrderType()==OP_BUY)    SchBuyLs+=OrderLots();
         }                                               //конец работы с выбранным ордером
      }                                                  //Конец цикла
   return(SchBuyLs);                                     // При ошибке выбора ордера функция вернёт ноль
}
// ----------------------------------------------------------------------------