You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Will Pushkin initialise the string?
Hmmm... I'm not very good at programming, but wouldn't the string be reset every time?
I am interested in its base value, for example, value of double is zero, bool is 1, but what?
Dabble example:
double Statys;
void OnTick()
{
if(Statys == 0)
{OpenBuy();}
}
And it seems to work))
(Exactly, it's not zeroed.)) I never initialized them there.)
Hmm... I'm not good at programming, but wouldn't the string be reset every time?
I am interested in its base value, e.g. value of double is zero, bool is 1, but what is it?
Exactly, it's not zeroed.) And I never initialized them there)
In MQL5 help it is clearly stated in section Initialization of variables:
Any variable can be initialised when defined. If a variable is not explicitly initialized, the value stored in this variable can be whatever you want. Implicit initialization is not performed.
The Initialisation of Variables section of the MQL5 help explicitly states:
You are just lucky for the time being, but one day you will be unlucky and you will be agonisingly long searching for a bug in your code, unaware that the devil is hiding in the minutiae. You don't have to rely on "I'll get lucky".I'm writing a simple function to check the direction of indexing in an array. The arrays themselves are taken from OnCalculate(), i.e. have different types (double, datetime, etc.). There are examples of terminal functions in the reference that use header type f(void &array[]) when processing arrays of different types. But compiler swears on using void type in user function. Is there some universal way to tell the compiler that the type of array-parameter is not important for a user function?
I would like to clarify Structure of trade request result (MqlTradeResult)
double price; // Price in trade, confirmed by broker
It does not return the price of a pending order? The Expert Advisor has written the following code:
double Statys = 0;
void OnTick()
{
if (Statys == 0)
{OpenBuy();}
}
void OpenBuy()
{
MqlTradeRequest o; MqlTradeResult p;
double Ask = SymbolInfoDouble(_Symbol,SYMBOL_ASK);
o.action = TRADE_ACTION_PENDING;
o.symbol = _Symbol;
o.volume = 1;
o.price = 82,000;
o.sl = 81,800;
o.tp = 82.200;
o.type = ORDER_TYPE_BUY_STOP;
o.type_filling = ORDER_FILLING_AON;
o.type_time = ORDER_TIME_GTC;
OrderSend(o,p);
Statys = p.price;
}
Judging by the fact that we have a lot of open trades, I venture to guess that the answer is price = 0. It's kind of weird though.
Is there any universal way to tell the compiler that the type of the array parameter is not important for a user function?
I would like to clarify Structure of trade request result (MqlTradeResult)
double price; // Price in trade, confirmed by broker
It does not return the price of a pending order? The Expert Advisor has written such a code:
Judging by the fact that there are a lot of open trades, I venture to guess that the answer is price = 0. This is kind of weird though.
A pending order does not imply making a deal. Take a look at MqlTradeResult structure help :
Field description
Field
Description
retcode
Return code of the trade server
deal
Deal ticket, if a deal has been performed. Reported in the TRADE_ACTION_DEAL trade operation
order
Order ticket, if a ticket has been placed. Notified during a TRADE_ACTION_PENDING trade operation
volume
Volume of the trade confirmed by the broker. It depends on the order filling type
price
Deal price, confirmed by broker. Depends on the deviationfield in the trade request and/or the type of trade
bid
Current market bid price (requote price)
ask
Current market bid price (requote prices)
comment
Broker's comment to the transaction (by default, filled with a decryption)
A pending order does not constitute a trade. Look at the help for the MqlTradeResult structure:
Also, please insert the code correctly.OK, stop. Do we have to initialize strings too? It's not an atomic type.