[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 311

 
splxgf >> :

the pending order is placed in one line, the question is at what distance?

sell limit 30 pips upwards from the current price

buy limit 30 pips down from the current price

 

LIM. ORDER

extern int     Magic = 20011;
extern double  Lot=0.1;
extern int     sl    =50;     // Размер фиксированного стопа
extern int     tp  =40;    // Размер фиксированного тэйка
extern int     Шаг =30;   //расстояние от текущ. цены
double ld_Stop=0, ld_Take=0;
//-- Подключаемые модули --
#include <stderror.mqh>
#include <stdlib.mqh>
//-----------------------------
int start()
{
//-------------------------------------------------
if( NumberOfOrders(NULL,OP_SELLLIMIT, Magic)<1 )  {//ЕСЛИ НЕТ СЕЛЛЛИМИТА
    if ( sl!=0) ld_Stop=Ask+ sl*Point;
    if ( tp!=0) ld_Take=Ask- tp*Point;    
    OrderSend(Symbol(),OP_SELLLIMIT, Lot,Bid+ Шаг*Point,3, ld_Stop,
                                              ld_Take_"", Magic,0,Red);  
    if( ticket<0){Print("Ошибка установки ордера SELLLIMIT ",
                                          GetLastError());return(0);} 
                                                }
//----------------------------------------------------
if( NumberOfOrders(NULL,OP_BUYLIMIT, Magic)<1 )  {//ЕСЛИ НЕТ БАЙЛИМИТА 
    if ( sl!=0) ld_Stop=Bid- sl*Point;
    if ( tp!=0) ld_Take=Ask+ tp*Point;
    OrderSend(Symbol(),OP_BUYLIMIT, Lot,Ask- Шаг*Point,3, ld_Stop,
                                                ld_Take,"", Magic,0,Blue);
    if( ticket<0){Print("Ошибка установки ордера BUYLIMIT ",
                                              GetLastError());return(0);} 
                                                }
  return(0);//конец ф-и СТАРТ
}
//========================================================
//------- ф-я Возвращает количество ордеров---
int NumberOfOrders(string sy="", int op=-1, int mn=-1) {
  int i, k=OrdersTotal(), ko=0, ot; if ( sy=="0") sy=Symbol();
  for ( i=0; i< k; i++) {
    if (OrderSelect( i, SELECT_BY_POS, MODE_TRADES)) {
      ot=OrderType();
      if ( ot>1 && ot<6) {
        if ((OrderSymbol()== sy || sy=="") && ( op<0 || ot== op)) {
          if ( mn<0 || OrderMagicNumber()== mn) ko++;
        }}}}  return( ko);}                        
 
 
rid писал(а) >>

God forbid you should use this trick to open positions! It only works correctly in the tester!

And online, more than half of the entry signals will be ignored...

Thanks, I will take it into account.

By the way, a question to a pro. I wanted to check something, and while sampling from the history (at 1 o'clock) I noticed that the values above a thousand bars do not give: up to 1000 I get values, and from 1001 - 0. The quotes archive is filled with a lot of data. What can it be related to?

 
Odin_Takoy писал(а) >>

Thanks, I'll keep that in mind.

By the way, a question for the pros. I wanted to check something and while sampling from the history (on the hour hand) I noticed that the value is not higher than 1 000 bars: I get values up to 1000, while from 1001 it returns 0. The quotes archive is heavily loaded. What may be the reason?

When working with the tester or the optimizer, only 1000 bars are available. This is a restriction imposed by the developers.

 
Vinin писал(а) >>

Only 1000 bars are available when working with the tester or optimiser. This is a restriction imposed by the developers.

How can I bypass this restriction, if I don't want to be online for weeks?

 
Odin_Takoy писал(а) >>

To avoid being online for weeks, is there any way around this restriction?

Actually, the idea is to put the quotes into a file and retrieve them from there.

 
Odin_Takoy писал(а) >>

To avoid being online for weeks, is there any way around this restriction?

The restriction applies only to the tester and optimizer. When working in the terminal settings, you specify the number of bars to be displayed.

To circumvent the restrictions in the Strategy Tester, you should provide a flag in the Expert Advisor allowing to trade when the specified depth of history is reached. In this case it will be necessary to start the Expert Advisor from an earlier date.

 
Vinin писал(а) >>

The restriction applies only to the tester and optimiser. When working in the terminal settings, you specify the number of bars to be displayed.

To bypass the limitation in the tester, we need to provide in the Expert Advisor the flag allowing to trade when the specified depth of history is reached. Then you will need to run the Expert Advisor from an earlier date.

My understanding is as follows. We launch the Expert Advisor with a great depth of history. The quotes are saved in arrays. And at the right moment we address the formed arrays for the analysis.

Thank you, Victor.

I look at your time - you are a real owl (just kidding).

 
Odin_Takoy писал(а) >>

I see by the time, you're quite the owl (just kidding).

I'm a lark. I'm a +2 from Moscow.

 

Hello how to implement: need at a certain time on the closing price to draw two lines from the price, one higher and one lower, let's say the price of 1.4784 line was drawn to 1.4800, and the second 1.4750 to end at 50 and 00 and at the breakdown of the line, set a pending order with a profit ????????????????

Reason: