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

 

Hello all!!!

Help with editing the code...

At the moment it does not open a position when an order is running.

I would like to add a condition that after closing an order, the next order was placed only!

 //Check position
   bool IsTrade = False;

   for (int i = 0; i < Total; i ++) {
      OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
      if(OrderType() <= OP_SELL &&  OrderSymbol() == Symbol()) {
         IsTrade = True;
         if(OrderType() == OP_BUY) {
            //Close
 
Hi-Fi:

Hi all!!!

Help with editing the code...

At the moment it does not open a position when an order is running.

I would like to add a condition that after closing an order, the next order was placed only!

I hope you will figure it out:

//+------------------------------------------------------------------+
//|                    возвращает тип последней закрытой позиции.mq4 |
//|                        Copyright 2015, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2015, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
Alert("",GetNameOP(GetTypeLastClosePos()));
   
  }
//+------------------------------------------------------------------+
//+----------------------------------------------------------------------------+
//|  Автор    : Ким Игорь В. aka KimIV,  http://www.kimiv.ru                   |
//+----------------------------------------------------------------------------+
//|  Версия   : 19.02.2008                                                     |
//|  Описание : Возвращает тип последней закрытой позиции или -1               |
//+----------------------------------------------------------------------------+
//|  Параметры:                                                                |
//|    sy - наименование инструмента   (""   - любой символ,                   |
//|                                     NULL - текущий символ)                 |
//|    mn - MagicNumber                (-1   - любой магик)                    |
//+----------------------------------------------------------------------------+
int GetTypeLastClosePos(string sy="", int mn=-1) {
  datetime t=0;
  int      i, k=OrdersHistoryTotal(), r=-1;

  if (sy=="0") sy=Symbol();
  for (i=0; i<k; i++) {
    if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) {
      if ((OrderSymbol()==sy || sy=="") && (mn<0 || OrderMagicNumber()==mn)) {
        if (OrderType()==OP_BUY || OrderType()==OP_SELL) {
          if (t<OrderCloseTime()) {
            t=OrderCloseTime();
            r=OrderType();
          }
        }
      }
    }
  }
  return(r);
}
//+----------------------------------------------------------------------------+
//|  Автор    : Ким Игорь В. aka KimIV,  http://www.kimiv.ru                   |
//+----------------------------------------------------------------------------+
//|  Версия   : 01.09.2005                                                     |
//|  Описание : Возвращает наименование торговой операции                      |
//+----------------------------------------------------------------------------+
//|  Параметры:                                                                |
//|    op - идентификатор торговой операции                                    |
//+----------------------------------------------------------------------------+
string GetNameOP(int op) {
  switch (op) {
    case OP_BUY      : return("Buy");
    case OP_SELL     : return("Sell");
    case OP_BUYLIMIT : return("Buy Limit");
    case OP_SELLLIMIT: return("Sell Limit");
    case OP_BUYSTOP  : return("Buy Stop");
    case OP_SELLSTOP : return("Sell Stop");
    default          : return("Unknown Operation");
  }
}

From here https://forum.mql4.com/ru/38949/page4#434227

I can't seem to insert the link.

 
r772ra:

I hope you can work it out:

...

When looking for a solution, Kim was the first thing I came across...))), but I couldn't get it to work with that code(((

Maybe there's a way to modify the code I posted?

 
Good afternoon !

Can I change the colour of the indicator in the Expert Advisor ?

iMA( NULL,0, 3, MA_Shift, MA_Method, PRICE_HIGH, 1);

 
abeiks:
Good afternoon !

Can I change the colour of the indicator in the expert ?


The EA receives a number. What difference does it make whether the digit is green or brownish speckled?
 
evillive:
The examiner gets a figure. What difference does it make whether the digit is green or speckled brown?
I was referring to the MA line that appears in the examiner tests.
 
abeiks:
I meant the MA line that appears when testing in EA.

Not really sure, but it seems the MA opens with the colour that was in the last use.

Try putting the MA on any chart, select a colour and then run the EA. What will you get?

 
abeiks:
I meant the MA line that appears during tests in the Expert Advisor.
In visualization mode MA will appear with default colour, and if there is template tester.tpl or <advisor name>.tpl - MA colour will be from template.
 
Thank you!
 

Please tell me what the message is and how to fix it:

2015.06.18 04:04:12.156 Memory handler: cannot allocate 33150 bytes of memory