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

 

Good present!

int ret_code=0;
int somefunc()
  {  
   ...
   return(ret_code);
  }

is ret_code a local variable or aglobal variable ?isret_code reset after a terminal restart?

 
evillive:
There can be as many magicians as you like, each condition is different.
I guess I haven't gotten to the bottom of it yet somewhere. All the magician examples I have found do not fit my strategy.
 
abeiks:

Good present!

is ret_code a local variable or aglobal variable ?isret_code reset after a terminal restart?

They are all reset after a restart, only the terminal's GPs (those that are GlobalVariable) retain their values. And ret_code is global only within code, i.e. visibility from any line and initialization only on startup.
 
evillive:
They are all reset after restart, only terminal GPs (those GlobalVariable) retain their values. And ret_code is global only within code, i.e. visibility from any line and initialization only on startup.
I see, thank you.
 
rapid_minus:
I probably haven't got to the bottom of it somewhere else. All the examples I've found with the magician do not fit my strategy.
It can't be. What prevents you from putting a magik in the open position command that matches the condition in which you send the open command?
 
artmedia70:
... ...a magik that matches the condition...

i.e. I can enter any number of magik (including 1, 2 and 3) in the open command and then the same number in the close command?

So I don't understand the magician at all... Why is it then called a magician? I thought it was an order number assigned automatically on opening.

Can you explain the magician to me? Is it really clear to all beginners if I am the only one who is such an idiot?

And what is worse than identifying the order with a ticket?

 
rapid_minus:

i.e. I can enter any number of magik (including 1, 2 and 3) in the open command and then the same number in the close command?

So I don't understand the magician at all... Why is it then called a magician? I thought it was an order number assigned automatically on opening.

Can you explain the magician to me? Is it really clear to all beginners but only to me?

And what is worse than identifying the order with a ticket?

Magic is the magic number of an order. It can be used as a user-defined order identifier. In some cases this is the only information which can be used to determine whether or not the order belongs to the program which opened it. This is a user-defined parameter that may or may not coincide with the value of the same parameter for other orders.
 
rapid_minus:

i.e. I can enter any number of magik (including 1, 2 and 3) in the open command and then the same number in the close command?

So I don't understand the magician at all... Why is it then called a magician? I thought it was an order number assigned automatically on opening.

Can you explain the magician to me? Is it really clear to all beginners if I am the only one who is such an idiot?

And what is worse than identifying an order with a ticket?

What you are thinking of is a ticket - an order identification number. It is unique for each order and is not repeated. A magik is a user identifier that can be used to "flag" any order. These magics can be the same for every order of a certain program or can be different in one program. For example: You have an EA that is displaying a flat and a trend. For a flat we will use a strategy with magic number 123 and for a trend we will use a strategy with magic number 124. By these magicians the EA will be able to find out which strategy the selected order belongs to and make a decision to do something with it at this very moment (that is exactly what I told you about). But the other advisors working at your account must have any magicians except 123 and 124 in order not to allow the other advisor to touch orders "alien" to it and work only with its own orders, for example, with magic number 125.

And yes, you may use any integer number - 1, 2, 3 or 100500 ... as long as the wizard does not duplicate the wizard of another EA working on the same account. The wizard can be zero in the EA, but in this case the EA will consider as its own those orders that you opened manually.

 

r772ra andartmedia70, thanks for the clarification.

My understanding is that magic is needed mainly when a trader uses several EAs, with several open orders, on several currency pairs, accounts, etc. (right?)

I do not think so, and if I think that my Expert Advisor will work in profit, it will be enough for me. I am still developing it for one pair, one account at one brokerage company and only one order should be open and a magician (or any other identifier for an open position) is needed so that it would be closed only upon the occurence of certain conditions for this very order and other conditions which are valid for closing other orders (which may be open only after the closure of this order) would not be valid for this order.

For example, an order may be open when conditions (a+b+c+d+d) or (a+d+e) or (f+c+i+c) appear and, depending on the conditions on which the BAY is open, it should close according to its own conditions:(a+b+c+d) by (f+j+l),(a+d+e) by (h+l+m+n),(g+z+i+k) by (p+r+c+t) .

It seems to me that the order loop is not needed here either. There has to be some simple solution that does not take much space. I stated my vision above, but haven't got to analysis yet, and besides logical errors I must have syntax errors (there may be brackets missing or wrong variable set, etc.).

Don't consider it a problem, please help. I'm stuck without it. Thanks

Below is the finalized version.

 
//-------Пример(мой) приказа на открытие позиции с привязкой закрытия ----------------------------------------------------- 
                                                      
                                                      //Локальная переменная, открывающая ордер БАЙ
   int OrdBuy_1() = (OrderSend(Symbol(),OP_BUY,Lots,Ask,0,Bid-1500*Point,Bid+1500*Point));
   
        //-------Тогда закрытие именно для этого приказа может быть таким:-----------------------------------------------------
    
    if (OrdBuy_1()==true)                              //Если был открыт ордер №1, то...
     {                                                 //...выполнить следующее:...
                                                       //...при условии, что Желтая выше красной, с сужением(условие1)...
                                                       //...и есть верхний перелом Средней (условие2)...
                                                       //...ИЛИ при условии, что Желтая выше красной, с расширением(условие1а)...
                                                       //...и есть верхний перелом Боллинджера (условие2а)... 
     if ((Yellow_0>Red_0) && (Yellow_0-Red_0)<(Yellow_1-Red_1) && (MA_2 < MA_1 && MA_1 > MA_0) || (Yellow_0>Red_0) && (Yellow_0-Red_0)>(Yellow_1-Red_1) && (MB_2 < MB_1 && MB_1 > MB_0))
        {                              
       bool Ans=OrderClose(OrdBuy_1,Lots,Bid,0);       //...закрыть ордер №1 по цене Bid (лок.переменная)и выдать сообщение                                                      
         Alert("Попытка закрыть ордер БАЙ лотом("Lots"), с ценой открытия("Ask"). Ожидание ответа..");
        }
      }
   if (Ans==true)                                     // Если получилось,... 
        {                                             //... выдать сообщение
         Alert ("Закрыт ордер БАЙ лотом("Lots"),с ценой открытия("Ask"), цена закрытия("Bid"));
        }