Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1300

 
ANDREY:

It is possible to close the spread, i.e. to add some value to the bid price. But how can the size of this spread be fixed? In real ticks the spread is floating, i.e. the value of the spread is unknown. And therefore it cannot be closed on real ticks ..... in my professional opinion, but purely logically. It is probably only possible to sew what is EXACTLY known FOREVER.

Does metatrader surprise you? I'm not... not anymore... Please....

<DATE> <TIME> <OPEN> <HIGH> <LOW><CLOSE> <TICKVOL> <VOL> <SPREAD>
1999.01.28 00:03:00 1.14450 1.14450 1.14450 1.14450 1.14450 1 0 50
1999.01.28 00:13:00 1.14440 1.14440 1.14420 1.14420 3 0 50

 
Александр:

Does metatrader surprise you? I'm not... not anymore... Please....

<DATE> <TIME> <OPEN> <HIGH> <LOW><CLOSE> <TICKVOL> <VOL> <SPREAD>
1999.01.28 00:03:00 1.14450 1.14450 1.14450 1.14450 1.14450 1 0 50
1999.01.28 00:13:00 1.14440 1.14440 1.14420 1.14420 3 0 50

That is, the spread is either O , or simply the value of the spread is not displayed. And this data by MT4 , or by MT5. And from which menu item is this data?

If there is a spread value but for some reason it is not displayed, then this MT glitch is very similar to my MT5 glitch. Alpari says that the depth of history has no effect on the quality of tick quotes and thinks that my problem is hidden in the terminal itself and advises to contact the developers. So, like in your example, I have the same value of quality history for 2010, but for some reason it is not displayed in MT5. If there were no ticks at all, or their number was too small (say 1000), then the history quality would not be displayed.
 

Hello.
Please pay attention to a newbie.
No errors or warnings when compiling, but EA does not open orders in tester... And there are no errors in the log...

What may be the reason? Already tried different things...

extern double Lot=0.1;            
extern int Slippage = 30;
extern int TakeProfit = 30;
extern int StopLoss   = 30;
extern int MA_Smoth_S = 60;
extern int MA_Smoth_B = 12;
extern int MA_Simpl_S = 3;
extern int MA_Simpl_B = 1;

int start()
         {
          int MA_Simpl_S_Op,      
              MA_Simpl_B_Op;      
                 
          MA_Smoth_S = iMA(NULL,0,MA_Smoth_S,0,MODE_SMMA,PRICE_CLOSE,1);
          MA_Smoth_B = iMA(NULL,0,MA_Smoth_B,0,MODE_SMMA,PRICE_CLOSE,1);
          MA_Simpl_S = iMA(NULL,0,MA_Simpl_S,0,MODE_SMA,PRICE_CLOSE,1);
          MA_Simpl_B = iMA(NULL,0,MA_Simpl_B,0,MODE_SMA,PRICE_CLOSE,1);
          MA_Simpl_S_Op = iMA(NULL,0,MA_Simpl_S,0,MODE_SMA,PRICE_CLOSE,2);
          MA_Simpl_B_Op = iMA(NULL,0,MA_Simpl_B,0,MODE_SMA,PRICE_CLOSE,2);
          
          //Условие для Buy______________________
          while(MA_Smoth_B > MA_Smoth_S)
               {
                if(MA_Simpl_B_Op < MA_Simpl_S_Op && MA_Simpl_B > MA_Simpl_S)
                  {
                   bool check = OrderSend(Symbol(),OP_BUY,Lot,NormalizeDouble(Ask, Digits),Slippage,Bid-StopLoss*Point,Ask+TakeProfit*Point,"Buy",0,0,clrGreen);
                   return(0);
                  }
               }
               
          //Условия для Sell_____________________
          while(MA_Smoth_S > MA_Smoth_B)
               {
                if(MA_Simpl_B_Op > MA_Simpl_S_Op && MA_Simpl_B < MA_Simpl_S)
                  {
                   check = OrderSend(Symbol(),OP_SELL,Lot,NormalizeDouble(Bid, Digits),Slippage,Ask+StopLoss*Point,Bid-TakeProfit*Point,"Sell",0,0,clrRed);
                   return(0);
                  }   
               }     
          return(0);
         }
 
IndependentMK:

Hello.
Please pay attention to a newbie.
No errors or warnings when compiling, but EA does not open orders in tester... And there are no errors in the log...

What may be the reason? I already tried different things...

int X = 5;
if(X > 10 && X < 3)  int ticket = OrderSend(Symbol(), OP_SELL, Доп_Лот, NormalizeDouble(Bid, Digits), 3,  NormalizeDouble(Ask + StopLoss_S * Point, Digits),  NormalizeDouble(Bid - TakeProfit_S * Point, Digits), "", MAGIC_S, 0, CLR_NONE);
 

What do you think? Will the tester open the position? No. Because X is not in the test range. That's why. Insert the Prints into the code and analyze the tester's log.

int start()
  {
   int MA_Simpl_S_Op,
       MA_Simpl_B_Op;
   MA_Smoth_S = iMA(NULL, 0, MA_Smoth_S, 0, MODE_SMMA, PRICE_CLOSE, 1);
   MA_Smoth_B = iMA(NULL, 0, MA_Smoth_B, 0, MODE_SMMA, PRICE_CLOSE, 1);
   MA_Simpl_S = iMA(NULL, 0, MA_Simpl_S, 0, MODE_SMA, PRICE_CLOSE, 1);
   MA_Simpl_B = iMA(NULL, 0, MA_Simpl_B, 0, MODE_SMA, PRICE_CLOSE, 1);
   MA_Simpl_S_Op = iMA(NULL, 0, MA_Simpl_S, 0, MODE_SMA, PRICE_CLOSE, 2);
   MA_Simpl_B_Op = iMA(NULL, 0, MA_Simpl_B, 0, MODE_SMA, PRICE_CLOSE, 2);
//Условие для Buy______________________
   Print(" MA_Smoth_B = ", MA_Smoth_B, " MA_Smoth_B = ", MA_Smoth_B);
   while(MA_Smoth_B > MA_Smoth_S)
     {
      Print(" MA_Simpl_B_Op = ", MA_Simpl_B_Op, " MA_Simpl_S_Op = ", MA_Simpl_S_Op);
      if(MA_Simpl_B_Op < MA_Simpl_S_Op)
        {
         Print(" MA_Simpl_B = ", MA_Simpl_B, " MA_Simpl_S = ", MA_Simpl_S);
         if(MA_Simpl_B > MA_Simpl_S)
           {
            bool check = OrderSend(Symbol(), OP_BUY, Lot, NormalizeDouble(Ask, Digits), Slippage, Bid - StopLoss * Point, Ask + TakeProfit * Point, "Buy", 0, 0, clrGreen);
            return(0);
           }
        }
     }
//Условия для Sell_____________________
   while(MA_Smoth_S > MA_Smoth_B)
     {
      if(MA_Simpl_B_Op > MA_Simpl_S_Op && MA_Simpl_B < MA_Simpl_S)
        {
         bool check = OrderSend(Symbol(), OP_SELL, Lot, NormalizeDouble(Bid, Digits), Slippage, Ask + StopLoss * Point, Bid - TakeProfit * Point, "Sell", 0, 0, clrRed);
         return(0);
        }
     }
   return(0);
  }
//+------------------------------------------------------------------+
Совершение сделок - Торговые операции - Справка по MetaTrader 5
Совершение сделок - Торговые операции - Справка по MetaTrader 5
  • www.metatrader5.com
Торговая деятельность в платформе связана с формированием и отсылкой рыночных и отложенных ордеров для исполнения брокером, а также с управлением текущими позициями путем их модификации или закрытия. Платформа позволяет удобно просматривать торговую историю на счете, настраивать оповещения о событиях на рынке и многое другое. Открытие позиций...
 
ANDREY:

That is, the spread is either O , or simply the spread value is not displayed. Is this data from MT4 or MT5? And what menu item is this data from?

If the spread value is there, but it is not displayed for some reason, then this MT glitch is very similar to my MT5 glitch. Alpari says that the depth of history has no effect on the quality of tick quotes and believes that my problem is hidden in the terminal itself, and advises to contact the developers. So, like in your example, I have the same value of quality history for 2010, but for some reason it is not displayed in MT5. If there were no ticks at all, or their number was too small (say 1000), then the history quality would not be displayed.

Here is MT4 quote

2007.02.12, 00:00, 0.9051, 0.9087, 0.9047, 0.907, 3739

Here is MT5
1999.01.28 00:03:00 1.14450 1.14450 1.14450 1.14450 1 0 50
1999.01.28 00:13:00 1.14440 1.14440 1.14420 1.14420 3 0 50

Feel the difference... I stopped working with ticks long ago. And as it is, I don't have enough energy to fight the various "handy/funnies".

Put the same Expert Advisor in another brokerage company. What a problem with ticks there. Even on Open, even opening and closing at the same time. The difference is BOTH. Maybe someone has solved this problem (ticks, etc.), and I don't know how to deal with it. And in MT5 there is also a spread...

 
Александр:

Here are the MT4 quotes

2007.02.12, 00:00, 0.9051, 0.9087, 0.9047, 0.907, 3739

Here is MT5
1999.01.28 00:03:00 1.14450 1.14450 1.14450 1.14450 1 0 50
1999.01.28 00:13:00 1.14440 1.14440 1.14420 1.14420 3 0 50

Feel the difference... I stopped working with ticks long ago. And as it is, I don't have enough energy to fight the various "handy/funnies".

Put the same Expert Advisor in another brokerage company. What a ticks problem there. Even on Open, even opening and closing at the same time. The difference is BOTH. Maybe someone has solved this problem (ticks, etc.), and I don't know how to deal with it. And in MT5 there is also a spread...

Of course you are more advanced in all these questions than I am ...... thats why I don't understand your thought process in some places...
When I tried to use Mt4 for example my codes were showing very good results with Tiki codes ... Then I learned that my very good result is not completely accurate, because MT4 doesn't take into account the real spread and that the real spread in MT4 in Alpari is impossible to take into account because it floats (especially at night).

On this forum I was told that during testing the real spread (that is exactly floating) is taken into account only on MT5. This led me to study MT5 and run my code on it on the model - every tick based on REAL ticks. After that I was sobered up, because my code didn't show as good results as on MT4. On the other hand some positive points of the code, that were on MT4, were confirmed on MT5 as well. And I was glad to be able to improve my code, being sure that the test results were close to real trading.

Because of this, I do not quite understand (perhaps due to lack of knowledge and experience) your negative attitude to testing on tick history. After all, if you open transactions not by Сlose (as you have), but at any price that is specified in the request to open an order (like I do), what is then the disadvantage of testing on ticks?
The possible disadvantage may be, as it seems to me, only an incomplete set of ticks and their omission in the loaded quotes. But the number of ticks, compared to the number of one-minute candles, is enormous. And I have not yet investigated whether missing ticks (like candlesticks) may be detected at all and added to the ticks file. That's why I have to trust Alpari's promise so far, that they have a FULL tick history since 2001.
And I still don't understand the difference, which I should feel looking at the candlesticks you brought to demonstrate some idea of yours
.

I don't want to test my EA with another broker, because if I ever dare to trade live, it will be with Alpari. Besides, you've said yourself that this broker has the most complete and reliable tick data.

I'm sure you have some valuable information for me, which, unfortunately, I am not able to take it from your words.

Тестирование торговых стратегий на реальных тиках
Тестирование торговых стратегий на реальных тиках
  • www.mql5.com
В данной статье мы покажем результаты тестирования простой торговой стратегии в 3-х режимах: " OHLC на M1 " с использованием только цен Open,High, Low и Close минутных баров; затем детальное моделирование в режиме " Все тики ", и самое достоверное тестирование в режиме " Каждый тик на основе реальных тиков " с использованием записанных тиков из...
 
ANDREY:


Your negative attitude to testing on tick history. After all, if you open deals not by Сlose (as you have) but by any price that is specified in the request to open an order (as I have), then what is the disadvantage of testing on ticks?

And I still do not understand what is the difference, that I should feel when looking at the parameters of the candlesticks, that you have brought to demonstrate your idea.

I do not want to test my EA with another broker, because if I ever dare to trade in real account, I will do it only with Alpari. Besides, you've said yourself that this broker has the most complete and reliable tick data.

I am sure you have some valuable information for me, which, unfortunately, I have not been able to grasp from your words so far.

1. Negative attitude... No, it's not negative. It's just that you try and wait for weeks for the tests to be completed and then it turns out that the quotes are not good enough and it strongly affects the results. All brokerage companies FILTER the quotes. Filters distort them. I went down the route of writing an EA that is not critical about the quality of quotes.

2. The difference in quotes between MT4 and MT5 is that I started with that MT5 has a spread FOR EVERY RATE. Why is that? I don't know. Offline this spread is maxed out. Offline is walking around. I.e. we should make a system which is not critical. See point 1 G).

That's all there is to it. No subtext.

 
Александр:

1. A negative attitude... No it's not negative. It's just that you push, you wait for weeks for the tests to finish, and then it turns out that the quotes are not good enough and it has a HUGE impact on the results. All DCs FILTER the quotes. Filters distort them. I went down the route of writing an EA that is not critical about the quality of quotes.

2. The difference in quotes between MT4 and MT5 is that I started with that MT5 has a spread FOR EVERY RATE. Why is that? I don't know. Offline this spread is maxed out. Offline is walking around. I.e. we should make a system which is not critical. See point 1 G).

That's all there is to it. No subtext.

"....... and then it turns out that the quotes are not good enough and it strongly affects the results. Filters distort them. ...."


Suppose there is a tick real quotes from 2008 for a pair automatically downloaded from the Alpari server to MT5 for testing. How do you determine that these quotes are not good enough? In general, by what criteria do you assess the quality of quotes? What are the parameters that should have tick quotes of optimal quality?
As Alpari says, tick quotes are not modelled or generated, but they are taken from recorded history. As I understand it .... brought another tick any quote - Alpari tick with this quote recorded and recorded. And so on with every tick. As a result, they have a huge database of ticks with prices, which they download to MT5 for testing. And only if a necessary quote or its sequence is missing for some reason, only then Alpari, instead of missing real ticks with prices, these ticks are simulated according to an algorithm close to the appearance of real ticks.

That's why I don't quite understand what complaints may be made about the quality of quotes. As an alternative, I can imagine that a tick has come and brought the price, for example, 1.00061. But Alpari has assigned a different price to this tick, for example, 1.00077. Or they can attach a different spread to this tick than the one that was in reality. But if it is really so, an unauthorized person cannot detect this alteration, especially on a deep history. So it is of course possible to claim that Alpari has filtered out this tick with the quote. But it seems to me practically impossible to prove it. Because no one except the relevant Alpari specialist knows what the primary price or spread of the filtered tick was. The only possible variant is if this specialist will reveal this secret to someone, and maybe even confirm the fact in writing. But, as it seems to me, this information with documentary evidence would immediately appear on this forum.


"... All DCs are FILTERING quotes. Filters distort them....."


I have read about this many times. But this filtering was about real trading. And it seems to me that such filtration is reasonable for brokerage companies. With its help they can avoid large losses, if a great amount of positions with very large volume can close at Take Profit, if brokerage company didn't enter the market. And what is the use of filtration when a brokerage company provides quotes for testing?

Основы тестирования в MetaTrader 5
Основы тестирования в MetaTrader 5
  • www.mql5.com
Идея автоматической торговли привлекательна тем, что торговый робот может без устали работать 24 часа в сутки и семь дней в неделю. Робот не знает усталости, сомнений и страха,  ему не ведомы психологические проблемы. Достаточно четко формализовать торговые правила и реализовать их в виде алгоритмов, и робот готов неустанно трудиться. Но прежде...
 

Can you tell me how to get a ratio of x2 when closing a position with a loss?

Now I get 1,4,9,16 - and I need 2,4,8,16.

What to fix in the code?

 int cn=0,c=0;
  datetime dt=0;
   for(int i=OrdersHistoryTotal()-1; i>=0; i--){
    if(OrderSelect(i, SELECT_BY_POS, MODE_HISTORY) && OrderType()<=1) {
     if((OrderSymbol()==mSymbol)&&(OrderMagicNumber()==Magic)) {
       double Profit=OrderProfit()+OrderCommission()+OrderSwap();
        if(Profit<0) {  
        c++;   
        cn=(int)MathPow(c,2); // что здесь исправить?
        } else break;     
 }}}
   Comment(cn);
 
Denis Pershin:

Can you tell me how to get a ratio of x2 when closing a position with a loss?

Now I get 1,4,9,16 - and I need 2,4,8,16.

What to fix in the code?

Everything needs to be fixed.

Your code searches for the first order from the order history with the specified symbol and magic number

Then the number of unprofitable orders is calculated and multiplied by 2.

search the forum for"useful functions from CMM" and do something like this

- find the ticket of the last order for our symbol and our magik

- obtain OrderProfit() and OrderLots() from the found ticket and multiply by your martingale coefficient, if necessary

ZS: there may be a ready solution

Только "Полезные функции от KimIV".
Только "Полезные функции от KimIV".
  • 2011.02.18
  • www.mql5.com
Все функции взяты из этой ветки - http://forum.mql4...