Errors, bugs, questions - page 623

 
MetaDriver:
You'll get a rude awakening... :))

Probably,

I have read the essence of the problem, I don't understand why each indicator should have a timer, and why there are so many indicators,

if it's possible to get the Bids of the required instrument directly in the EA timer and store them in the general assembly,

If you want to use an indicator, you'll need a bigger timer, but in this case, there will be an unsynchronized data stream.

it's different with spies - they don't have clocks and events for all instruments may not happen for a long time, or they may start ticking one after another.

For example, in dealing where there is a Last price, the Bid data is not always there, so you can check and write either Bid or Last if there is no Bid.

 

MetaDriver:

I propose a compromise: catch ticks with spies and send them immediately to the head Expert Advisor with a millisecond label (GetTickCount()). Expert Advisor arranges them according to their labels and slices into second blocks.

It is not very simple, but it will be accurate.

It's not a bad variant. In my opinion, it's the only one worth taking as a basis.

Urain:

By the way, in dealing where there is a Last price, the Bid data is not always there, so check and write either Bid or Last.

Good clarification, I did not encounter such. It will have to be taken into account.
 

MetaDriver:

Предлагаю компромисс: ловишь тики шпионами и сразу отправляешь в головной эксперт, снабдив милисекундной меткой(GetTickCount()). Эксперт их упорядочивает в соответствии с метками и нарезает секундные блоки.

Не очень просто, зато с точностью будет порядок.

Interesting:

Not a bad option. In my opinion, the only one worth taking as a basis.

Good clarification, haven't come across this. It will have to be taken into account.

It may not be a bad variant, but the mechanism of sending ticks is absent in the terminal. Try to think of 5-10 ticks/sec on 16 pairs. Once again - it's already gone)).

And you don't need such an accuracy - 1sec is enough.

Thanks to all of you - the subject is finished.

 

The problem is very unpleasant due to substitution of minute bars with bars of higher timeframes in the distant historical past, when the minute-by-minute history was not yet available. The only solution that comes to mind is complex conversion of fake bars into real ones, and it cannot guarantee the accuracy. It is not so much about complexity as about doubts in accuracy of such conversion.

The initial task is to check the relevance of Fibonacci Time Zones being built. If the zone is too distant and the working width of all its subzones (up to 34 base widths by default) is so narrow that the right edge does not reach the present moment, then we don't build it, otherwise we create an object on the chart. Tried to solve this in two similar ways, one of which I cite. The only difference is that in the first way, I was dancing from the beginning of the story using

   datetime firstDate=(datetime)SeriesInfoInteger(_Symbol,_Period,SERIES_FIRSTDATE);
And in the second one - on the contrary (I cite this method), the essence and results are absolutely the same. Tested on NZD/USD.

If you have a fake history ending on a date other than 2009, as I have, rearrange the two Fibo Time Zones so that one of them passes through that tipping date and the second one is already completely on the right side of history, where all the bars are real. In this case, do not forget to change values of startTime1, endTime1 and, if necessary, startTime2, endTime2 in the script; you can not adjust prices - it is not important. Now you can test it... The result will be sad: if the check algorithm remains unchanged for both timezones, it will work correctly only for the zone which has one foot before the tipping date and another foot after it, the algorithm will wrongly filter out and prevent us from building it. Note that both zones are fairly close to each other and have similar widths, and these two widths extend far into the future and will be relevant for a long time, in fact neither of them should be filtered out (comment out the conditions and see that both timezones are built).

void OnStart()
  {
   datetime startTime1=D'2009.07.08 18:00:00';
   datetime endTime1=D'2009.11.03 12:17:00';
   datetime startTime2=D'2009.06.30 08:00:00';
   datetime endTime2=D'2009.10.21 20:16:00';

   double startPrice1=0.61930;
   double endPrice1=0.70948;
   double startPrice2=0.65470;
   double endPrice2=0.76300;

   int FTZ1pos1,FTZ2pos1,bandwidth;
   datetime Arr[],time1;

   CopyTime(_Symbol,PERIOD_M1,0,1,Arr);
   time1=Arr[0];

   FTZ1pos1=CopyTime(_Symbol,PERIOD_M1,time1,startTime1,Arr);
   bandwidth=CopyTime(_Symbol,PERIOD_M1,endTime1,startTime1,Arr)*(34+2); // +2 - небольшой запас общей ширины
                                                                         // зоны на всякий случай

   if(FTZ1pos1<=bandwidth)
      ObjectCreate(0,"FTZ1",OBJ_FIBOTIMES,0,
                   startTime1,startPrice1,
                   endTime1,endPrice1
                  );


// ---
   FTZ2pos1=CopyTime(_Symbol,PERIOD_M1,time1,startTime2,Arr);
   bandwidth=CopyTime(_Symbol,PERIOD_M1,endTime2,startTime2,Arr)*(34+2); // +2 - небольшой запас общей ширины
                                                                         // зоны на всякий случай

   if(FTZ2pos1<=bandwidth)
      ObjectCreate(0,"FTZ2",OBJ_FIBOTIMES,0,
                   startTime2,startPrice2,
                   endTime2,endPrice2
                  );
  }

Desired result:There must be two Fibo Time Zone

Somewhere between the first and second 0-base lines there is a tipping point separating fake minute bars and real ones.

If you reject calculations in the number of bars, and everything is calculated with dates, then it certainly will not give the desired accuracy, because you have to subtract weekends (+/- hour of market closing/opening), holidays, etc., and let alone missing bars in the absence of ticks over a minute and divergence from the timeline.

What do you advise as a reliable solution?

 

Error loading file in Expert Advisor. Find 10 differences. The first code refers to the script, the second to the Expert Advisor, they are identical Ctrl-C Ctrl-V. The code works in the script, it does not work in the Expert Advisor.

#include <\\MyClass\RegulFind-v1-1.mqh>
#include <Trade\Trade.mqh>
int hMa,hRsi ;
double mMa[],mRsi[];                             
Kohonen  koh;
CTrade trade ;
void OnStart()
  {
   koh.LoadMap("KitMaRsi.csv") ;
   hMa=iMA(_Symbol,Period(),10,0,MODE_EMA,PRICE_CLOSE) ;
   if(hMa ==INVALID_HANDLE)
      Print("Ошибка загрузки машки====================== ",GetLastError());
   hRsi=iRSI(_Symbol,Period(),10,PRICE_CLOSE);
   if(hRsi ==INVALID_HANDLE)
      Print(" Ошибка загрузки РСИ ==========");   
   
  }
#include <\\MyClass\RegulFind-v1-1.mqh>
#include <Trade\Trade.mqh>
int hMa,hRsi ;
double mMa[],mRsi[];                             
Kohonen  koh;
CTrade trade ;
int OnInit()
  {
   koh.LoadMap("KitMaRsi.csv") ;
   hMa=iMA(_Symbol,Period(),10,0,MODE_EMA,PRICE_CLOSE) ;
   if(hMa ==INVALID_HANDLE)
      Print("Ошибка загрузки машки====================== ",GetLastError());
   hRsi=iRSI(_Symbol,Period(),10,PRICE_CLOSE);
   if(hRsi ==INVALID_HANDLE)
      Print(" Ошибка загрузки РСИ ==========");   
   return(0);
  }
 
ivandurak:

Error loading file in Expert Advisor. Find 10 differences. The first code refers to the script, the second to the Expert Advisor, they are identical Ctrl-C Ctrl-V. The code works in the script, it does not work in the Expert Advisor.

The tester has a different file sandbox. If you want Expert Advisor in the tester and normal way to work with one *.csv file, put it into common directory and open file with FILE_COMMON modifier


P.S. To put it in the common folder, you must either write a file with the modifier
FILE_COMMON, or find something like this (a variant for XP):

C:\Documents and Settings\All Users\Application Data\MetaQuotes\Terminal\Common\Files\



 
x100intraday:

What do you advise as a reliable solution?

Back to MT4.

I have contacted the developers about the future of this problem, but they have remained silent, so personally I have no idea what the future holds.

 

The switch with character variables doesn't seem to work...

Instead of:

string type = "Buy";

switch(type)
{
case "Buy" : {direction = ORDER_TYPE_BUY;  price = SymbolInfoDouble(zSymbol,SYMBOL_ASK); break;}
case "Sell": {direction = ORDER_TYPE_SELL; price = SymbolInfoDouble(zSymbol,SYMBOL_BID); break;}
default: {return(lot_value);}
}

'type' - illegal switch expression type
'Buy' - constant expression is not integral

I have to draw it like this:

if(zShift == "Buy")  {direction = ORDER_TYPE_BUY;  price = SymbolInfoDouble(zSymbol,SYMBOL_ASK);}
if(zShift == "Sell") {direction = ORDER_TYPE_SELL; price = SymbolInfoDouble(zSymbol,SYMBOL_BID);}
if(zShift != "Buy" || zShift != "Sell") {return(lot_value);}

It's not so clear and it's crooked.

It works well in other languages.

Should I write it in another way?

 
awkozlov:

Switch doesn't seem to work with character variables...


The documentation says (emphasis added) - Switch operator:

Compares the value of an expression to constants in all casevariants and passes control to the operator that matches the value of the expression. Each case variant can be marked with an integer constant , a character constant, or a constant expression. A constant expression may not include variables or function calls. Theswitch operator expression must be of integer type.

 
awkozlov:

It works in other languages...

The fact that it works in other languages is a feature. Switch was originally intended only for integral types. There is no such feature here.
Reason: