[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 115

 
Good morning!!! Can you tell me how to memorise a variable so that when the computer is switched on, its value is saved?
 
Thank you!!!
 

Have you ever considered that All indicators adjust to the Price - and not the other way round.

What conclusion can be drawn from this? I don't know yet.)

Price Is Not Dependent on Indices.

Indices depend on price.

 
alex12:

Have you ever considered that All indicators adjust to the Price - not the other way round.

What conclusion can be drawn from this? I don't know yet.)

Price Is Not Dependent on Indices.

Indices depend on price.


profound conclusion.

indicators are not adjusted to price, they are constructed based on price.
feel the difference?

 

Please help a newbie!

The robot does not place stop losses, I can not understand why, in the magazine writes an error "invalid ticket for OrderClose function"

The code at the point of making a trade and placing a stop loss:

//+------------------------------------------------------------------+
//+----------------------CONTROLLING A TRADE---------------------+
//+------------------------------------------------------------------+
if (POINT_BUY >= 5)
{
if (OrdersTotal() == 0)
{
int ticket = OrderSend(Symbol(), OP_BUY, 0.1, Ask, 5, kijun_sen-100*Point, Ask+1000*Point, "My order #", 16384, 0, Green);
}
if(ticket < 0)
{
Print("Order not set. Error - #",GetLastError());
return(0);
}
}
//+------------------------------------------------------------------+
//+-------------------------СТАВИМ СПОП ЛОСС-------------------------+
//+------------------------------------------------------------------+
OrderSelect(0, SELECT_BY_POS, MODE_TRADES);

if (POINT_BUY < 5)
{
if (OrdersTotal() == 1)
{
OrderClose(ticket, 0.1, Bid, 5, Red);
}
}
}
return(0);
//+------------------------------------------------------------------+

 
abolk:


profound conclusion.

Indicators don't adjust for price, they build based on price.
feel the difference?

Of course there is a difference:

The price is in first place, and

Indians on Second = and never the other way round.

That's the difference. The latter are always dependent on the former.

No Price, no turkeys. Price feeds the turkeys :)

 
Xaoss1990:

Please help a newbie!

The robot does not place stop losses, I can not understand why, in the magazine writes an error "invalid ticket for OrderClose function"

The code is in the place where I place a trade and place a stop loss:

//+------------------------------------------------------------------+
//+---------------------ЗАКЛЮЧАЕМ СДЕЛКУ ПОКУПКИ---------------------+
//+------------------------------------------------------------------+
if (POINT_BUY >= 5)
{
if (OrdersTotal() == 0)
{
int ticket = OrderSend(Symbol(), OP_BUY, 0.1, Ask, 5, kijun_sen-100*Point, Ask+1000*Point, "My order #", 16384, 0, Green);
}
if(ticket < 0)
{
Print("Order not set. Error #",GetLastError();
return(0);
}
}
//+------------------------------------------------------------------+
//+-------------------------СТАВИМ СПОП ЛОСС-------------------------+
//+------------------------------------------------------------------+
OrderSelect(0, SELECT_BY_POS, MODE_TRADES);

if (POINT_BUY < 5)
{
if (OrdersTotal() == 1)
{
OrderClose(ticket, 0.1, Bid, 5, Red);
}

}
}
return(0);
//+------------------------------------------------------------------+

first you need to select an order https://docs.mql4.com/ru/trading/OrderSelect.

If you want to close an open order, define its type,

and depending on its type, close it at Bid or Ask price.


noticed - there is a select, then instead of ticket one should write OrderTicket()


In general, the code is kind of ugly: select an order, then check the number of orders, then delete the order which is open.

open orders: search through the orders from the first to the last - find the right one in the search - then delete it


Also, why use the close order function if the task is to modify
 
abolk:

first you have to select the order https://docs.mql4.com/ru/trading/OrderSelect.

If an open order is to be closed, define its type,

and depending on its type, close it at the Bid or Ask price.


i noticed that there is a select, then instead of ticket one should write OrderTicket()


In general, the code is kind of ugly: select an order, then check the number of orders, then delete the order which is open.

Usually: go through the orders from the first to the last one - find the right one in the search - then delete it


Also, why use the close order function if the task is to modify

I am a newbie, just learning)))) Thanks for the tips!
 


Guys, can you tell me why there might be an error about not being able to open an indicator in an EA?

This condition is met:

-List of parameters (if necessary). Transmitted parameters must match the order of declaration and type of external (extern) variables of the custom indicator.

int Criterion()                        // Пользовательская функция
  {
   int P= Price ;                   // 
   int L= Length;            // 
      int D=  Displace;                 //
   int F= Filter;              // 
   int C= Color ;                 // 
   int CB= ColorBarBack;              // 
   double Dev = Deviation;   
   
   double
   Cycle=4,
   M_0, M_1,                           // Значение MAIN на 0 и 1 барах
   S_0, S_1,                           // Значение SIGNAL на 0 и 1 бар
   St_M_0, St_M_1,                     // Значение MAIN на 0 и 1 барах
   St_S_0, St_S_1;                     // Значение SIGNAL на 0 и 1 бар
   
//--------------------------------------------------------------- 4 --
   // Параметры технич. индикат:
   //--------------------------------------------------------------
   double MA=iCustom(NULL,0,"NonLagMA_v5",P,L,D,F,C,CB,Dev,0,1);
   double Up=iCustom(NULL,0,"NonLagMA_v5",P,L,D,F,C,CB,Dev,1,1);
   double Dw=iCustom(NULL,0,"NonLagMA_v5",P,L,D,F,C,CB,Dev,2,1);
...
Reason: