[ARCHIVE]Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Can't go anywhere without you - 5. - page 48

 
TarasBY:
Are you talking about "consider" and DC?! ;)

It has nothing to do with DC.
 

I've been playing around with a fairly unsophisticated Expert Advisor I wrote. But I decided to add to my expert not one but several signals to enter the market. But I want only one order for each signal to enter the market.

The matter is as follows. I figured out that we can delimit the orders by Magic. The search for orders would look like this:

//+-------------------------------------------------------------------------------------+
//| Поиск своих ордеров                                                                  |
//+-------------------------------------------------------------------------------------+
int FindOrders(int magic)
{
  int t;                                                 // Количество открытых позиции (buy's + sell's)
  int total = OrdersTotal() - 1;
  
  for(int i=total; i>=0; i--)
  {
    if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) continue;
      if(OrderMagicNumber() == magic && OrderSymbol() == Symbol())
      {
        t++;
      }
  }
  
  return(t);
}

Next... we need to open orders for each signal type with its own Magic. For example, for sales I had it like this before:

//+-------------------------------------------------------------------------------------+
//| Открытие коротких позиций                                                           |
//+-------------------------------------------------------------------------------------+
bool OpenSell()
{
  int ticket = -1;
  string myNote = "Сов шортанул";
  
  ticket = OrderSend(Symbol(),OP_SELL,0.1,Bid,i_slippage,0,0,myNote,magic,0,Red);
    return(true);
  
  return(false);
}

At this point, I decided to use the switch operator, is it reasonable to use this operator in this case?

//+-------------------------------------------------------------------------------------+
//| Открытие коротких позиций                                                           |
//+-------------------------------------------------------------------------------------+
bool OpenSell()
{
  int ticket = -1;
  string myNote = "Сов шортанул";
  
    switch(maState)
  {
    case 4:    ticket = OrderSend(Symbol(),OP_SELL,0.1,Bid,i_slippage,0,0,myNote,i_myMagic6,0,Red); break;
    case 5:    ticket = OrderSend(Symbol(),OP_SELL,0.1,Bid,i_slippage,0,0,myNote,i_myMagic25,0,Red); break;
    case 6:    ticket = OrderSend(Symbol(),OP_SELL,0.1,Bid,i_slippage,0,0,myNote,i_myMagic150,0,Red); break;
    case 7:    ticket = OrderSend(Symbol(),OP_SELL,0.1,Bid,i_slippage,0,0,myNote,i_myMagic250,0,Red); break;
    default:   return(false);
  }
    return(true);
}

And this is what the trading function looked like:

//+-------------------------------------------------------------------------------------+
//| Открытие позиций                                                                    |
//+-------------------------------------------------------------------------------------+
bool Trade(int signal)
{
  if(signal == SIGNAL_BUY && FindOrders() == 0)
    if(!OpenBuy())
    return(false);
  
  if(signal == SIGNAL_SELL && FindOrders() == 0)
    if(!OpenSell())
    return(false);
    
  return(true);
}

Should I implement it through the switch operator here too? I was thinking to pass Magic through formal parameters to FindOrders() function too, but I don't know how...

 
Hello. Can you calculate a possible loss for a cross rate, for example GBPCHF, open a 1 lot order and put a 50 pip stop. As far as I know the pip value depends on the base currency, which is unknown what it will show in the future.
 

The value of 1 pip of GBPCHG (if I'm not mistaken) for 1 lot is $8. Thus, if the price goes against you and a stop-loss is triggered, a loss of about $50*8=-$400 will be recorded.

And losses on asc-bid spread (6-8 pips) must be added...
 
So the cost of the item changes every time
 

Question on MT4. I've been testing and optimising the EA for quite a long time (a few days).

Everything was fine. And then suddenly, when I run the EA, it starts to show entry on every bar and exit immediately, in short, not a strategy, but the hell knows what!

Probably somewhere, something went wrong in the settings. Where and what could it be? Help. plz....

 
Caesar34:
Hello.. Can you please tell me how to make a MA or EMA period with a minus value, when the settings do not allow to do so... ? in MT4
Spam?
 
Caesar34:


No!!
Then why post in a couple of threads with one question?
 

The iLow query returns a value with 4 decimal places, although the graph has 5 decimal places.

Because of this, the development of the first mql4 program is stuck. Can you tell me what may be the problem? Or maybe it should be like this?

 
PolarsLynx:

The iLow query returns a value with 4 decimal places, although the graph has 5 decimal places.

Because of this, the development of the first mql4 program is stuck. Can you tell me what may be the problem? Or maybe it should be like this?

Where is the code?