Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 411

 
Vinin:

Didn't you say where to send the book?


Right! I forgot because of the holidays! :) thanks for reminding me!

 
Vinin:

Did you say where to send the book?

I wrote to the post office
 
Tell me, how do I know what the minimum TP can be at any given time?
 
Trader7777:
Tell me, how do I know what the minimum TP can be at any given time?

int STOPLEVEL=MarketInfo(NULL,MODE_STOPLEVEL);
 
thanks) knew Market info, didn't know which parameter to set in the function.
 
Trader7777:
thanks) knew Market info, didn't know which parameter to set in the function.
In the editor, hover the cursor over the function name and press F1. The help information for the function opens.
 
Hello. Couldn't find it on the forum, so I'm writing here. I'm trying to get a new EA based on a training EA. The EA that is given as an example trades on MA crossings. There are two pieces with different periods. A slow MA and a fast MA. When the fast one intersects the slow one from the bottom upwards, we buy; if vice versa, we sell. I want to add this function to standard trading conditions in order to additionally track results of a deal. If a position is closed at a Stop Loss or 0, the EA will open an opposite position instead of waiting for the next crossing. In other words, we opened a buy position, incurred a stop loss (the market did not go where we wanted) and immediately at the level of the stop-loss opened a sell position. I know that such an EA will still be losing, but I want to understand what kind of code should be written. I hope to get some help from the professionals. I have no idea what to do with this kind of code and I do not know what to do with it.
 
petya33r:
Hello. Couldn't find it on the forum, so I'm writing here. I'm trying to get a new EA based on a training EA. The EA that is given as an example trades on MA crossings. There are two pieces with different periods. A slow MA and a fast MA. When the fast one intersects the slow one from the bottom upwards, we buy; if vice versa, we sell. I want to add this function to standard trading conditions in order to additionally track results of a deal. If a position is closed by a Stop Loss or 0, the EA will open an opposite position instead of waiting for the next crossing. In other words, we opened a buy position, incurred a stop loss (the market did not go where we wanted) and immediately at the level of the stop-loss opened a sell position. I know that such an EA will still be losing, but I want to understand what kind of code should be written. I hope to get some help from the professionals. I hope to get some help from the professionals. Thank you very much.

I would like to place pending order at the level of stop-loss.
 
evillive:

Place a pending order at the stop loss level in the opposite direction.


I would like to place it without any pending. I have found the following code of the Expert Advisor on the Internet. It opens an opposite position at taking a loss but I cannot combine it with conditions of trading with two MAs.

#property copyright "Copyright © 2013, MoneyInNetwork.ru"
#property link      "http://moneyinnetwork.ru"
extern string s1 = "Объем для первой сделки серии, лот";
extern double Lot = 0.1;
extern string s2 = "Уровень стоп-лосса, пипсов";
extern double stoploss = 100;
extern string s3 = "Уровень тейк-профита, пипсов";
extern double takeprofit = 500;
extern string s4 = "Уникальная метка для ордеров, открываемых только этим советником";
extern double MagicNumber = 600;
extern string s5 = "Максимальное отклонение от запрошенной цены, пипсов";
extern double slip = 15;
 
int init()
{
   return(0);
}
 
int deinit()
{
   return(0);
}
 
int start()
{ 
  //инициализация параметров
  int ticket = 0;
  int old_order_type = OP_SELL;
 
  //ищем среди всех открытых ордеров открытый советником ордер 
  RefreshRates();
  for ( int trade = OrdersTotal() - 1; trade >= 0; trade-- ) 
  {
      //проверяем есть ли среди всех открытых ордеров именно тот ордер, который открыт данным советником.
      if ( OrderSelect(trade, SELECT_BY_POS, MODE_TRADES) && (OrderType() == OP_BUY || OrderType() == OP_SELL) && OrderMagicNumber() == MagicNumber && OrderSymbol() == Symbol() )
      {
          //если есть незакрытый ордер - выходим
          return (0);        
      }
  }
  //нет открытых ордеров - ищем в истории закрытых ордеров последний закрытый именно этим советником ордер 
  for ( trade = OrdersHistoryTotal() - 1; trade >= 0; trade-- ) 
  {
     if ( OrderSelect(trade, SELECT_BY_POS, MODE_HISTORY) && OrderMagicNumber() == MagicNumber && OrderSymbol() == Symbol() )
     {
         old_order_type = OrderType();
         if ( OrderProfit()<0 ) //последний закрытый советником ордер был убыточным, значит, следующий ордер открываем в направлении, противоположном закрытому с убытком
         {
                break; //прекращаем поиск
         }
     }
  }
  //если раньше покупали, то теперь продаем
  if ( old_order_type == OP_BUY )
  {
      ticket = OrderSend(Symbol(), OP_SELL, Lot,  NormalizeDouble(Bid, Digits), slip, NormalizeDouble(Ask+stoploss*Point, Digits), NormalizeDouble(Ask-takeprofit*Point, Digits), "Martingale-Sell", MagicNumber, 0, Red);
      Sleep (2000); //задержка в 2 секунды для обработки запроса торговым сервером брокера
      return (0);  
  }
  //если раньше продавали, то теперь покупаем
  if ( old_order_type == OP_SELL )
  {
      ticket = OrderSend(Symbol(), OP_BUY, Lot, NormalizeDouble(Ask, Digits), slip, NormalizeDouble(Bid-stoploss*Point, Digits), NormalizeDouble(Bid+takeprofit*Point, Digits), "Martingale-Buy", MagicNumber, 0, Green);
      Sleep (2000); //задержка в 2 секунды для обработки запроса торговым сервером брокера
      return (0);  
  }               
}  
 
Ekburg:

Geez... I'm certainly glad that you began to solve the problem, but my message you somehow have not noticed, where I said the same thing, a little different words, and immediately said the shortcomings, except for closing the file, not immediately saw where you have it happens:)

You wrote a three-point response. In the first one you made a mistake (my entry is quite correct), in the second one you also made a mistake (although this message leveled it out :) The third point sounded as if you suggested to move the cursor to the end after the entry, not before it (which was taken as a mistake again). In the face of such a picture, I preferred to make a clarification from a much-experienced moderator who responded.

Nevertheless, thank you indeed for your feedback. And a Happy New Year! :)