Questions from a "dummy" - page 244

 
paladin800:
I'm writing a multi-currency Expert Advisor where in the input parameters I set the instrument name, such as string Symbol0="EURUSD". If I write the wrong name, the trade does not go. My question is: Does such a function exist, that would compare instrument names with instruments offered by the broker?
No. You should check it yourself.
 
paladin800: Question: is there a function that would compare the names of the instruments with the instruments provided by the broker.
The question is what you want to see in the output. Basically, any standard function using a symbolic name of an instrument as one of its parameters, "compares" the name specified by the user with names of the broker's instruments. And there is even an ERR_MARKET_UNKNOWN_SYMBOL (4301) error for such functions.
 
Yedelkin:
The question is what you want to see in the output. Basically, any standard function that uses a symbolic instrument name as one of its parameters, "compares" the user-specified name with the broker's instrument names. And there is even an ERR_MARKET_UNKNOWN_SYMBOL (4301) error for such functions.
Basically, yes, when the indicator handle is then searched for a symbol that doesn't exist, an error is generated. Generally, at this point I can output an error message in the input parameters to the alert.
Документация по MQL5: Стандартные константы, перечисления и структуры / Коды ошибок и предупреждений / Ошибки компиляции
Документация по MQL5: Стандартные константы, перечисления и структуры / Коды ошибок и предупреждений / Ошибки компиляции
  • www.mql5.com
Стандартные константы, перечисления и структуры / Коды ошибок и предупреждений / Ошибки компиляции - Документация по MQL5
 
paladin800 Basically yes, when the indicator handle is then searched for a symbol that does not exist, an error is generated. In general, at this point I can output an error message in the input parameters to the alert.
You can write your own mini-function, that will check the string-parameters correctness. Use something like SymbolSelect(...,true) or SymbolInfoString(...,SYMBOL_DESCRIPTION, ...) with error checking. That is, implement "independent" checking, as Carlson said.
 
Good afternoon, everyone.

I am trying to make a tick collection indicator for further processing and visualisation. MT5 AlpariUK Version 5.0 Build 756
The test indicator prints current BID, ASK, LAST, VOLUME, tick_volume values when processing onCalculate.

//+------------------------------------------------------------------+
//|                                                TickCollector.mq5 |
//|                                             Copyright 2013, MZen |
//|                                             http://www.almex.net |
//+------------------------------------------------------------------+
#property copyright "Copyright 2013, MZen"
#property link      "http://www.almex.net"
#property version   "1.00"
#property indicator_chart_window


string   time_toprint, tick_bid, tick_ask, tick_last, tick_vol;
string   par1, par2, par3;


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//---

            time_toprint = TimeToString(SymbolInfoInteger(_Symbol,SYMBOL_TIME),TIME_DATE|TIME_SECONDS);
            tick_bid = DoubleToString(SymbolInfoDouble(_Symbol,SYMBOL_BID),_Digits);
            tick_ask = DoubleToString(SymbolInfoDouble(_Symbol,SYMBOL_ASK),_Digits);            
            tick_last = DoubleToString(SymbolInfoDouble(_Symbol, SYMBOL_LAST)); 
            tick_vol = IntegerToString(SymbolInfoInteger(_Symbol,SYMBOL_VOLUME));
            
            par1 = IntegerToString(tick_volume[(rates_total-1)]);
            
            Print("Server Time=",time_toprint,"   ","Bid=",tick_bid,"   ","Ask=",tick_ask,"   Price=",tick_last,"  Volume=",tick_vol,"  Tick volume=",par1);
           
//--- return value of prev_calculated for next call
   return(rates_total);
  }

//+------------------------------------------------------------------+

Result:

2013.03.03 19:45:59 TestTickCollector (USDJPY,M1) Server Time=2013.03.04 02:46:03 Bid=93.680 Ask=93.689 Price=93.680000 Volume=1000000 Tick volume=5
2013.03.03 19:45:59 TestTickCollector (USDJPY,M1) Server Time=2013.03.04 02:46:03 Bid=93.680 Ask=93.689 Price=93.680000 Volume=1000000 Tick volume=4
2013.03.03 03 19:45:59 TestTickCollector (USDJPY,M1) Server Time=2013.03.04 02:46:03 Bid=93.681 Ask=93.691 Price=93.68100000 Volume=3000000 Tick volume=4
2013.03.03.03 19:45:59 TestTickCollector (USDJPY,M1) Server Time=2013.03.04 02:46:03 Bid=93.681 Ask=93.691 Price=93.68100000 Volume=3000000 Tick volume=4
2013.03.03 19:45:58 TestTickCollector (USDJPY,M1) Server Time=2013.03.04 02:46:02 Bid=93.682 Ask=93.691 Price=93.68200000 Volume=2000000 Tick volume=3
2013.03.03 19:45:58 TestTickCollector (USDJPY,M1) Server Time=2013.03.04 02:46:02 Bid=93.682 Ask=93.691 Price=93.68200000 Volume=2000000 Tick volume=3
201303.03.03 19:45:57 TestTickCollector (USDJPY,M1) Server Time=2013.03.04 02:46:01 Bid=93.683 Ask=93.693 Price=93.68300000 Volume=1000000 Tick volume=2
2013.03.03 19:45:57 TestTickCollector (USDJPY,M1) Server Time=2013.03.04 02:46:01 Bid=93.683 Ask=93.693 Price=93.68300000 Volume=1000000 Tick volume=1
2013.03.03 03 19:45:56 PM TestTickCollector (USDJPY,M1) Server Time=2013.03.04 02:46:00 Bid=93.689 Ask=93.696 Price=93.68900000 Volume=570000 Tick volume=1
2013.03.03.03 19:45:56 TestTickCollector (USDJPY,M1) Server Time=2013.03.04 02:46:00 Bid=93.689 Ask=93.696 Price=93.68900000 Volume=570000 Tick volume=1
2013.03.03 19:45:55 TestTickCollector (USDJPY,M1) Server Time=2013.03.04 02:45:59 Bid=93.685 Ask=93.695 Price=93.68500000 Volume=1800000 Tick volume=53
2013.03.03 19:45:54 TestTickCollector (USDJPY,M1) Server Time=2013.03.04 02:45:58 Bid=93.685 Ask=93.695 Price=93.68500000 Volume=1700000 Tick volume=52
201303.03.03 19:45:54 TestTickCollector (USDJPY,M1) Server Time=2013.03.04 02:45:58 Bid=93.685 Ask=93.695 Price=93.68500000 Volume=1500000 Tick volume=51
2013.03.03 19:45:54 TestTickCollector (USDJPY,M1) Server Time=2013.03.04 02:45:58 Bid=93.685 Ask=93.695 Price=93.68500000 Volume=1500000 Tick volume=51
2013.03.03 19:45:53 TestTickCollector (USDJPY,M1) Server Time=2013.03.04 02:45:57 Bid=93.685 Ask=93.693 Price=93.68500000 Volume=500000 Tick volume=50
201303.03.03 19:45:52 TestTickCollector (USDJPY,M1) Server Time=2013.03.04 02:45:56 Bid=93.685 Ask=93.693 Price=93.68500000 Volume=400000 Tick volume=49
2013.03.03 19:45:52 TestTickCollector (USDJPY,M1) Server Time=2013.03.04 02:45:56 Bid=93.685 Ask=93.693 Price=93.68500000 Volume=200000 Tick volume=48
2013.03.03 19:45:52 TestTickCollector (USDJPY,M1) Server Time=2013.03.04 02:45:56 Bid=93.685 Ask=93.693 Price=93.68500000 Volume=200000 Tick volume=48
201303.03.03 19:45:51 TestTickCollector (USDJPY,M1) Server Time=2013.03.04 02:45:55 Bid=93.685 Ask=93.691 Price=93.68500000 Volume=200000 Tick volume=47
2013.03.03 19:45:51 TestTickCollector (USDJPY,M1) Server Time=2013.03.04 02:45:55 Bid=93.685 Ask=93.691 Price=93.68500000 Volume=1000000 Tick volume=46
2013.03.03 19:45:51 TestTickCollector (USDJPY,M1) Server Time=2013.03.04 02:45:55 Bid=93.685 Ask=93.691 Price=93.68500000 Volume=1000000 Tick volume=46
201303.03.03 19:45:50 TestTickCollector (USDJPY,M1) Server Time=2013.03.04 02:45:54 Bid=93.680 Ask=93.691 Price=93.68000000 Volume=1000000 Tick volume=45
2013.03.03 19:45:50 TestTickCollector (USDJPY,M1) Server Time=2013.03.04 02:45:54 Bid=93.680 Ask=93.691 Price=93.680000 Volume=1000000 Tick volume=45
2013.0303 19:45:48 TestTickCollector (USDJPY,M1) Server Time=2013.03.04 02:45:52 Bid=93.682 Ask=93.691 Price=93.68200000 Volume=1000000 Tick volume=44

It looks like onCalculate is triggered twice per tick most of the time, and tick_volume has nothing to do with tick volume. It is reset to 1 when you switch to a new period. The same value can be repeated 1, 2, 3 times.

To check, ran EA which prints ticks and its own indicator at the same time.

Result:

2013.03.03 19:51:56 Ticks (USDJPY,M1) 2013.03.03 19:51:56 93.684 93.677
2013.03.03.03 19:51:56 TestTickCollector (USDJPY,M1) Server Time=2013.03.04 02:52:00 Bid=93.677 Ask=93.684 Price=93.67700000 Volume=1000000 Tick volume=2
2013.0303 19:51:56 PM TestTickCollector (USDJPY,M1) Server Time=2013.03.04 02:52:00 Bid=93.677 Ask=93.684 Price=93.67700000 Volume=1000000 Tick volume=2
2013.03.03 19:51:56 Ticks (USDJPY,M1) 2013.03.03.03 19:51:56 93.683 93.674
2013.03.03 19:51:56 TestTickCollector (USDJPY,M1) Server Time=2013.03.04 02:52:00 Bid=93.674 Ask=93.683 Price=93.67400000 Volume=3000000 Tick volume=1
2013.03.03 19:51:56 TestTickCollector (USDJPY,M1) Server Time=201303.04 02:52:00 Bid=93.674 Ask=93.683 Price=93.67400000 Volume=3000000 Tick volume=1
201303.03.03 19:51:55 Ticks (USDJPY,M1) 2013.03.03 19:51:55 93. 682 93.674
2013.03.03 19:51:55 TestTickCollector (USDJPY,M1) Server Time=2013.03.04 02:51:59 Bid=93.674 Ask=93.682 Price=93.67400000 Volume=3000000 Tick volume=37
2013.03.03 19:51:55 TestTickCollector (USDJPY,M1) Server Time=2013.03.04 02:51:59 Bid=93.674 Ask=93.682 Price=93.67400000 Volume=3000000 Tick volume=37
2013.03.03 19:51:51:51 Ticks (USDJPY,M1) 2013.03.03.03 19:51:51 93.680 93.670
2013.03.03 19:51:51 TestTickCollector (USDJPY,M1) Server Time=2013.03.04 02:51:55 Bid=93.670 Ask=93.680 Price=93.67000000 Volume=1000000 Tick volume=36
2013.03.03 19:51:51 TestTickCollector (USDJPY,M1) Server Time=2013.03.04 02:51:55 Bid=93.670 Ask=93.680 Price=93.67000000 Volume=1000000 Tick volume=36
2013.03.03 19:51:50 Ticks (USDJPY,M1) 2013.03.03 2013 19:51:50 93.678 93.669
2013.03.03 19:51:50 TestTickCollector (USDJPY,M1) Server Time=2013.03.04 02:51:54 Bid=93.669 Ask=93.678 Price=93.66900000 Volume=3500000 Tick volume=35
201303.03.03 19:51:49 Ticks (USDJPY,M1) 2013.03.03 19:51:49 93. 678 93.669
2013.03.03 19:51:49 TestTickCollector (USDJPY,M1) Server Time=2013.03.04 02:51:53 Bid=93.669 Ask=93.678 Price=93.66900000 Volume=3000000 Tick volume=34
2013.03.03 19:51:49 PM TestTickCollector (USDJPY,M1) Server Time=2013.03.04 02:51:53 Bid=93.669 Ask=93.678 Price=93.66900000 Volume=3000000 Tick volume=34
2013.03.03 19:51:46 Ticks (USDJPY,M1) 2013.03.03.03 19:51:46 93.680 93.672
2013.03.03 19:51:46 TestTickCollector (USDJPY,M1) Server Time=2013.03.04 02:51:50 Bid=93.672 Ask=93.680 Price=93.67200000 Volume=1000000 Tick volume=33
2013.03.03 19:51:46 TestTickCollector (USDJPY,M1) Server Time=2013.03.04 02:51:50 Bid=93.672 Ask=93.680 Price=93.67200000 Volume=1000000 Tick volume=33
201303.03.03 19:51:44 Ticks (USDJPY,M1) 2013.03.03 19:51:44 93.681 93.672
2013.03.03 19:51:44 19:51:44 TestTickCollector (USDJPY,M1) Server Time=2013.03.04 02:51:48 Bid=93.672 Ask=93.681 Price=93.67200000 Volume=1000000 Tick volume=32
2013.03 03.03 19:51:44 TestTickCollector (USDJPY,M1) Server Time=2013.03.04 02:51:48 Bid=93.672 Ask=93.681 Price=93.67200000 Volume=1000000 Tick volume=32
2013.03.03 19:51:44 Ticks (USDJPY,M1) 2013.03.03 2013 19:51:44 93.683 93.673
2013.03.03 19:51:44 TestTickCollector (USDJPY,M1) Server Time=2013.03.03.04 02:51:48 Bid=93.673 Ask=93.683 Price=93.67300000 Volume=1000000 Tick volume=31
2013.03.03 19:51:44 TestTickCollector (USDJPY,M1) Server Time=2013.03.04 02:51:48 Bid=93.673 Ask=93.683 Price=93.67300000 Volume=1000000 Tick volume=30
2013.03.03.03 19:51:42 Ticks (USDJPY,M1) 2013.03.03 19:51:42 93.683 93.674
2013.03.0303 19:51:42 TestTickCollector (USDJPY,M1) Server Time=2013.03.04 02:51:46 Bid=93.674 Ask=93.683 Price=93.67400000 Volume=3000000 Tick volume=30
2013.03.03 19:51:42 TestTickCollector (USDJPY,M1) Server Time=2013.03.04 02:51:46 Bid=93.674 Ask=93.683 Price=93.67400000 Volume=3000000 Tick volume=30
2013.03.03 19:51:41 Ticks (USDJPY,M1) 2013.03.03.03 19:51:41 93.683 93.673
2013.03.03 19:51:41 TestTickCollector (USDJPY,M1) Server Time=2013.03.04 02:51:45 Bid=93.673 Ask=93.683 Price=93.67300000 Volume=1000000 Tick volume=29
201303.03.03 19:51:41 GMT TestTickCollector (USDJPY,M1) Server Time=2013.03.04 02:51:45 Bid=93.673 Ask=93.683 Price=93.67300000 Volume=1000000 Tick volume=29
2013.03.0303 03 19:51:40 Ticks (USDJPY,M1) 2013.03.03 19:51:40 93.682 93.673
2013.03.03 19:51:40 TestTickCollector (USDJPY,M1) Server Time=2013.03.04 02:51:44 Bid=93.673 Ask=93.682 Price=93.67300000 Volume=1000000 Tick volume=28
2013.03.03 19:51:40 TestTickCollector (USDJPY,M1) Server Time=2013.03.04 02:51:44 Bid=93.673 Ask=93.682 Price=93.67300000 Volume=1000000 Tick volume=28
2013.03.03 19:51:39 Ticks (USDJPY,M1) 2013.03.03 2013 19:51:39 93.681 93.671
2013.03.03 19:51:39 TestTickCollector (USDJPY,M1) Server Time=2013.03.04 02:51:43 Bid=93.671 Ask=93.681 Price=93.67100000 Volume=40000 Tick volume=27
201303.03.03 19:51:38 Ticks (USDJPY,M1) 2013.03.03 19:51:38 93. 681 93.671
2013.03.03 19:51:38 TestTickCollector (USDJPY,M1) Server Time=2013.03.04 02:51:42 Bid=93.671 Ask=93.681 Price=93.67100000 Volume=6000000 Tick volume=26
2013.03.03 19:51:38 TestTickCollector (USDJPY,M1) Server Time=2013.03.04 02:51:42 Bid=93.671 Ask=93.681 Price=93.67100000 Volume=60000 Tick volume=26
2013.03.03 19:51:37 Ticks (USDJPY,M1) 2013.03.03.03 19:51:37 93.682 93.674
2013.03.03 19:51:37 TestTickCollector (USDJPY,M1) Server Time=2013.03.04 02:51:41 Bid=93.674 Ask=93.682 Price=93.67400000 Volume=1000000 Tick volume=25
2013.03.03 19:51:37 TestTickCollector (USDJPY,M1) Server Time=2013.03.04 02:51:41 Bid=93.674 Ask=93.682 Price=93.67400000 Volume=1000000 Tick volume=24

Question: why is the tick duplicated and how do I get rid of it?

If onCalculate is triggered not only by a price change, but also for some other reasons, then how can we determine the reason for the switch to opCalculate ? And where are all the reasons for onCalculate triggering?

What am I doing wrong with the Tick volume ?

Am I missing something?

One more question - the time on my computer is lagging quite a bit. The difference in two days was 4 seconds. In what direction to look for a solution?

Thank you all.

 

Another question for the esteemed public:


In the documentation on https://www.mql5.com/ru/docs/constants/environment_state/marketinfoconstants#enum_symbol_info_integer

states:

SYMBOL_BID Bid - best offer to sell

SYMBOL_ASK Ask - best buy offer


The way I see it, Bid is the bestbuy offer and Ask is the best sell offer.

Here is what ServiceDesk replied
Support Team 2013.03.04 07:39


That means


SYMBOL_BID Bid - the best offer to sell (the best price you can sell at)

SYMBOL_ASK Ask - best buy offer (the best price you can get right now)




Here's a discussion: who's right?

Документация по MQL5: Стандартные константы, перечисления и структуры / Состояние окружения / Информация об инструменте
Документация по MQL5: Стандартные константы, перечисления и структуры / Состояние окружения / Информация об инструменте
  • www.mql5.com
Стандартные константы, перечисления и структуры / Состояние окружения / Информация об инструменте - Документация по MQL5
 
MZen:

Another question for the esteemed public:


In the documentation on https://www.mql5.com/ru/docs/constants/environment_state/marketinfoconstants#enum_symbol_info_integer

states:

SYMBOL_BID Bid - best offer to sell

SYMBOL_ASK Ask - best buy offer


The way I see it, Bid is the bestbuy offer and Ask is the best sell offer.

Here is what ServiceDesk has answered
Support Team 2013.03.04 07:39
It means

MZen

SYMBOL_BID Bid - the best offer to sell (the best price which you can sell at)

SYMBOL_ASK Ask - the best buy offer (the best price you can get right now)




I'm debating: who's right?

Play on words - in both situations there is a buyer, in both situations there is a seller, depending on which position to look at
 
lazarev-d-m:
Play on words - both situations have a buyer, both situations have a seller, depending on which position to look at

Ahhhh, got it!

When I ask "Buy from me" it's an offer to buy!

And when I say 'Sell to me', it's an offer to sell!

LOL!

 

I am beginning to learn OOP. Question for experts - is it possible to put the class at the end of the Expert Advisor code (as well as functions),

int OnInit()
  {
   return(0);
  }
//---
void OnTick()
  {
   ...
  }
//---
void OnDeinit(const int reason)
  {
   ...
  }
//---
   class CName 
     {
      ...
     };

and not to connect the class to the code as:

#include <Trade\Trade.mqh>
 
paladin800:

I am beginning to learn OOP. Question for experts - is it possible to put the class at the end of the Expert Advisor code (as well as functions),

and not connect the class to the code as:

It will be not a class but just a function, moved outside of program code (by the way, I use it instead of OOP, I find it more convenient).
Reason: