[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 933

 
Dimka-novitsek:

Here it is


The advisor works. He opens trades
 
gheka:

I'm still stumped and don't get it, I don't understand where the unique sequence number comes from, everything is different in the examples,

if I'm not mistaken I'm not the one who creates it, for example

Since you deleted the question from the PM, without waiting for an answer - I'll throw it here:

Let's break it down this way:

index -

Order position or order number depending on the second parameter.
(Order position or number, where does it come from????)

"Depending on the second parameter" - does it mean it depends on "select" ???

The order position is its location in the array of orders in your terminal. This is exactly the position we are searching for in the loop:

Order search:

for (int index=0; index<OrdersTotal(); index++) // Цикл по терминалу. В кач-ве переменной цикла будет index для наглядности
    {
       if (OrderSelect(index, SELECT_BY_POS) && OrderMagicNumber()==Magic) // Если выбран ордер и магик равен магику советника
           {
                if (OrderTipe()==OP_BUY)                                   // Если нам нужен ордер Бай
                   {
                       //............... Тут код обработки выбранного орд
                   }
           }
    }

If we are searching for SELECT_BY_POS, the next parameter is by default MODE_TRADES and you can omit it. The Expert Advisor will search for positions which are not yet closed, i.e., in the market.

If we need to search for orders that have already been closed, then we have to add the following parameter after the SELECT_BY_POS: MODE_HISTORY. Then the Expert Advisor will only search the list of closed positions and deleted or triggered orders.

(If I am not mistaken, these are the orders which have already been set, right? "0" is the first one on top,
"1" is the second one in the list, and so on).

Exactly this is the position, the position of the order in the array of the orders of the terminal, so to speak - its index - the very index
... And they are located in the array starting from zero cells of the array, although the order number starts with 1. I.e., the first order is located in zero cell of the array, the second in the first one, the third in the second one, etc. ...

Now for the ticket. The ticket, a unique number of an order, is assigned by your brokerage company. According to this number we can clearly identify this very order or position. However, we do have some reservations. The ticket should be saved somewhere in the EA (a variable or an array) so that you know exactly which order you need to have this ticket. For this purpose, I use my own EA's order book function where I store not only order data which can be obtained using standard functions, but also store in it, for example, Fibo levels, which I calculate right after opening a position and then enter them into my order book. Then I easily choose a position by its open time and takeaway and move the stop level according to the Fibo levels I saved for this position in my orders array ... I can also get the ticket of the order I need from there and use it later with standard functions:

   if (OrderSelect(Ticket, SELECT_BY_TICKET) && OrderCloseTime()==0) // Если выбран ордер по тикету и время его закрытия равно нулю
      {
         if (OrderTipe()==OP_BUY)                                   // Если нам нужен ордер Бай
            {
               //............... Тут код обработки выбранного ордера
            }
      }

Here it is necessary to compare the time of order closing with zero. Because during selection against the ticket, MODE_TRADES and MODE_HISTORY are ignored and are not used and we have to see the time of order closure to determine if it is closed and is selected from the list of open positions. If it is still in the market, its closing time will also be zero.
If you want to see the data of a closed order and you have to choose it by ticket, the closing time should be compared with zero, and if it is, the order has already been closed.

pool -

Source of data for selection. It is used when the select parameter is equal to SELECT_BY_POS. It can be one of the following values:
MODE_TRADES (default) - order is selected among open and pending orders,
these are current orders


MODE_HISTORY - order is selected among closed and deleted orders.

and this is from the list of completed orders, like from the log list, right?

That is correct.

double OrderProfit( )
it returns a net profit, but which? the last order or all orders?

It returns the current profit for the order that has not yet been closed.

If the order has already been closed, it will return the profit or loss of this order. One order, selected.

Without taking into account swaps, commissions etc... To take them into account, we need to create our own function.

=============================================================================

I hope you will figure it out ... :)
 

The advisor works. It's opening trades.

Thanks!!!! Knowing the trading platform is sick, apparently.

 
Renown:
There is a need for an EA to smooth out volatility (here is the value: High[iHighest(NULL, 0, MODE_HIGH, 30, 1)] - Low[iLowest(NULL, 0, MODE_LOW, 30, 1)] ) of the exponential moving average. As far as I understand, it cannot be done by standard iMA and I need to write a function for that? Can someone help me with the code?


iMAOnArray

 

good day to all.... there is a problem...can someone help...?

I'm trading an EA based on the martingale principle... i decided to include a stop loss in it as well... to calculate a loss i used the following formula...

Stopper = AveragePrice - Stoploss * Point; this is not a good fit for me, because the stopper in this case changes for the next bends... and I would like it to be fixed for all bends, for example 100 pips .... i.e., after opening an order stop is set at 100 pips...Let's say the second knee opens after 30 pips so the stop should be 70 pips to get to the same place as the first ... in short, I need a fixed unchanging stop loss for the entire series ... if you don't mind explaining it)))) or send me the function)))) I'd be grateful
 

A question has arisen regarding the detection of a key pressed. It is necessary to track the fact of pressing and if, for example, K is pressed, then we perform some actions. Here ( _http://msdn.microsoft.com/en-us/library/ms646293%28v=VS.85%29.aspx ) found int GetAsyncKeyState(int vKey) function which is in principle what I need... But there is one catch: the fact of pressing should be defined only if a MetaTrader window is active. I am using the following simple code in my Expert Advisor to check:

#define VK_K                            0x4B    // K key 
#import         "user32.dll"
   int GetAsyncKeyState(int vKey);

//-----------------------------------------------------------------------------------------------//
int init()  {

 return(0);
}
//-----------------------------------------------------------------------------------------------//
int deinit()   {

 return(0);
}
int start() {
   if(GetAsyncKeyState(VK_K)==0) Print("K не нажата...");
   else {Alert("НАЖАТА K");}
 return(0);
}
I was listening to alerts while writing this post :). Please help me to overcome this problem =)
 

The horror!!! Friends, I'm lost... :)

There are two nested loops. When I exit the inner one by break where do I drop out - at the beginning or the end of the outer loop?

On the closing bracket of the outer bracket or on the opening bracket?

 
artmedia70:

The horror!!! Friends, I'm lost... :)

There are two nested loops. When exiting from inner loop by break where do I exit - at the beginning or at the end of outer loop?

On the closing bracket of the external or on the opening bracket?

code in the studio.

In fact, right behind the closing parenthesis of the inner loop

 
Necron:

code please.

In fact, just behind the closing parenthesis of the inner loop

Thank you. That's exactly what I did, but some doubts occurred to me about whether I should check the flag in the outer loop before the closing parenthesis or at the beginning after the opening parenthesis...
 

Doesn't anyone know how to make a fixed stop for the series((((

There's a lot of pros here, the job's probably not that hard.

Reason: