OrdersTotal returns 0
#include <Trade\Trade.mqh>
CTrade trade;
int gi_flag=1;
void OnTick()
{
if(gi_flag==1)
{
trade.PositionOpen(_Symbol,ORDER_TYPE_SELL,1, SymbolInfoDouble(_Symbol,ORDER_TYPE_SELL==ORDER_TYPE_SELL ? SYMBOL_BID:SYMBOL_ASK),0,0);
gi_flag=0;
}
PrintFormat(DoubleToString(OrdersTotal(),1));
}
Although I understand it should return 1, or am I reading it wrong?
Orders are not positions. An order is an unexecuted order to open a position, while a position is the result of an order execution.
Thanks, I see, so we'll use the PositionsTotal function.
What about the first problem?
I wrote this code and something is not clear where the error might be
string Data() { string vr; string den; datetime date=TimeCurrent(); MqlDateTime str; TimeToStruct(date,str); switch(str.day_of_week) { case 0: den = "Воскресенье"; case 1: den = "Понедельник"; case 2: den = "Вторник"; case 3: den = "Среда"; case 4: den = "Четверг"; case 5: den = "Пятница"; case 6: den = "Суббота"; } printf("%02d.%02d.%4d %02d:%02d:%02d %d",str.day,str.mon,str.year,str.hour,str.min,str.sec,str.day_of_week); printf("%02d.%02d.%4d %02d:%02d:%02d %s",str.day,str.mon,str.year,str.hour,str.min,str.sec,den); return(StringFormat("%02d.%02d.%4d %02d:%02d:%02d %s",str.day,str.mon,str.year,str.hour,str.min,str.sec,den)); }
The log prints the following results
MF 0 11:06:34 04.06.2010 09:06:43 5RN 0 11:06:34 04.06.2010 09:06:43 Saturday
as far as I know the 5th day is Friday.
I wrote this code and something is not clear where the error might be
The log prints the following results
MF 0 11:06:34 04.06.2010 09:06:43 5RN 0 11:06:34 04.06.2010 09:06:43 Saturday
as far as I know the 5th day is Friday.
For any value of day_of_week you will get the value "Saturday". Because there are no break operators between cases
2 more obscure points
void OnTick()
{
for(int li=1; li<2; li++)
{
PrintFormat(SymbolName(li,true));
}
}
Returns a blank or a space, but not a character name
void OnTick()
{
PrintFormat(DoubleToString(SymbolsTotal(true),1));
}
Returns 1 even though I have at least 10 open
But if you put false instead of true, everything seems to work fine
Returns a blank or a space, but not the name of the character
for(int li=0; li<SymbolsTotal(false); li++) { PrintFormat(SymbolName(li,false)); }This is probably correct if you want to go through everything in the DC. If only what is in the terminal table, then change false to true.
That's what I'm saying: true doesn't work!
That's what I'm saying, it doesn't work with true!
It works, I checked it on three brokerage companies (I searched all symbols which are traded in brokerage companies).
for(int li=0; li<SymbolsTotal(false); li++) { PrintFormat(SymbolName(li,false)); }
And this code will go through everything that is selected in the "Market Watch" window
for(int li=0; li<SymbolsTotal(true); li++) { PrintFormat(SymbolName(li,true)); }
What I don't understand is this. Why to do such search in OnTick().
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Running the tester on EURUSD, everything works, both orders are sent. If we uncomment the line, GBPUSD order is not opened and there is an error in the log:
2010.06.02 10:34:26 Core 1 failed instant sell 1.00 GBPUSD at 0.00000 [Invalid stops]
2010.06.02 10:34:26 Core 1 No prices for symbol GBPUSD
I tried SymbolInfoTick, same thing.
Do you know the SymbolInfoTick or SymbolInfoDouble?