Ea works in DEMO trading , But Strategy tester does not - page 2

 
margiliauskas:

I not deleted these files. Deleted only .hst. I don't know what these files are, so I left them in folder. And now I'am not fully understand: delete these files and disconnect from broker before starting testing?

Sorry, I misread . . .
 
margiliauskas:

Hello,

I have the same problem. EA on Demo works perfectly, but on strategy tester no results or just one.

Firstly, your code will only work correctly on H1 because of this . . .

  double prev_high=High[iHighest(NULL,PERIOD_H1,MODE_HIGH,24,(shifted_cur_hour+1))];          //prev day highest price
  double prev_low=Low[iLowest(NULL,PERIOD_H1,MODE_LOW,24,shifted_cur_hour+1)];                //prev day lowest price
  double prev_close=iClose(NULL,PERIOD_H1,shifted_cur_hour+1);                                //prev day close price

. . . if you need to run on a different timeframe you need to change that code. Either change the High[] and Low[] to iHigh() and iLow() or change the timeframe in the iHighest() and iLowest() to the chart period.


Comparing doubles like this . . .

    if(Ask == L3 && open_crit == true)

. .. isn't going to work. If Ask is one point higher or one point lower it is not equaal and even if it matched the value to the point it could still be not equal, you need to read and understand about comparing double values: Can price != price ?

 
RaptorUK:

Firstly, your code will only work correctly on H1 because of this . . .

. . . if you need to run on a different timeframe you need to change that code. Either change the High[] and Low[] to iHigh() and iLow() or change the timeframe in the iHighest() and iLowest() to the chart period.


Comparing doubles like this . . .

. .. isn't going to work. If Ask is one point higher or one point lower it is not equaal and even if it matched the value to the point it could still be not equal, you need to read and understand about comparing double values: Can price != price ?

I have no problems to run tester or trade on H1. I'll do it on H1. So can we say that this part is ok? In future maybe I will improve my code.

Talking about Ask=L3. In real world it works precisely (L3 is normalized double and I will check about normalizing "äsk"). And question is next: could it be, that in testing mode some levels (in my case-L3) is more difficult to catch than in real trading? Maybe because of very fast calculating or some other reasons?


Question non of topic:

How I heard demo and live charts is a little bit different. I have both types of accounts. So MT4 history folder inside contains two folders, demo and live. So when I launching tester from which folder it taking historical data?

Thank you

 
margiliauskas:

I have no problems to run tester or trade on H1. I'll do it on H1. So can we say that this part is ok? In future maybe I will improve my code.

Talking about Ask=L3. In real world it works precisely (L3 is normalized double and I will check about normalizing "äsk"). And question is next: could it be, that in testing mode some levels (in my case-L3) is more difficult to catch than in real trading? Maybe because of very fast calculating or some other reasons?

If you don't include the volume ( tick count ) value when you import your data you will have fewer ticks than you would in a live/demo scenario and this may be part of the issue. The Strategy Tester uses the tick count information to determine how many ticks to create for each bar when it creates the tick data.


How I heard demo and live charts is a little bit different. I have both types of accounts. So MT4 history folder inside contains two folders, demo and live. So when I launching tester from which folder it taking historical data?

It takes the data from the folder that corresponds to the account you are logged into, if you are not logged in then I am not certain which data it will use . . . do some testing and find out.
 
RaptorUK:
If you don't include the volume ( tick count ) value when you import your data you will have fewer ticks than you would in a live/demo scenario and this may be part of the issue. The Strategy Tester uses the tick count information to determine how many ticks to create for each bar when it creates the tick data.

It takes the data from the folder that corresponds to the account you are logged into, if you are not logged in then I am not certain which data it will use . . . do some testing and find out.




At first glance most unreliable part of code (for non working Strategy Tester) is Ask==L3? Yes? How could I change it to more reliable? What could be professional suggestion or example?

And no suspicious to other lines of code?

thanks

 
margiliauskas:

At first glance most unreliable part of code (for non working Strategy Tester) is Ask==L3? Yes? How could I change it to more reliable? What could be professional suggestion or example?

I already gave you a link, read the thread, there is lots of information there: Can price != price ?
 
Read and understand the links provided The == operand. - MQL4 forum
 

hello again,

I read all your indicated links. Very interesting about this Can price != price ?. Need go deep into this thread.

I greatly appreciate your help.

BUT:

are we talking about same thing?

This expert atached to chart. In LIVE and DEMO modes this expert working, because it is successfully and precisely all the times opening orders when Ask price matching the value L3. So I can make the assumption that operator if(Ask==L3) becoming "true" and comparing these doubles is successful. for example 1.5428 (ask)==1.5428(L3). Otherwise order not be opened. And I don't need to read again Can price != price ? or The == operand. - MQL4 forum for searching answer because everything there are is good. Yes?

Tell me if I'am wrong.

But when this expert launched on strategy tester - no results or they are absolutely wrong. What difference between real trading and strategy tester? Could it possible that there are different prices? For example from broker MT4 receiving 1.5428 and strategy tester somehow calculating and using 1.542800001 (or something like that)? Or testing mode my code see somehow different then real time trading mode?

By the way. Like RaptorUK said, my code works correctly only on H1.

  double prev_high=High[iHighest(NULL,PERIOD_H1,MODE_HIGH,24,(shifted_cur_hour+1))];          //prev day highest price
  double prev_low=Low[iLowest(NULL,PERIOD_H1,MODE_LOW,24,shifted_cur_hour+1)];                //prev day lowest price
  double prev_close=iClose(NULL,PERIOD_H1,shifted_cur_hour+1);                                //prev day close price

So when testing I must choose H1 there, yes?


Thank you

 
margiliauskas:

hello again,

I read all your indicated links. Very interesting about this Can price != price ?. Need go deep into this thread.

I greatly appreciate your help.

BUT:

are we talking about same thing?

This expert atached to chart. In LIVE and DEMO modes this expert working, because it is successfully and precisely all the times opening orders when Ask price matching the value L3. So I can make the assumption that operator if(Ask==L3) becoming "true" and comparing these doubles is successful. for example 1.5428 (ask)==1.5428(L3). Otherwise order not be opened. And I don't need to read again Can price != price ? or The == operand. - MQL4 forum for searching answer because everything there are is good. Yes?

Tell me if I'am wrong.

Yes, you are wrong . . .

RaptorUK:
If you don't include the volume ( tick count ) value when you import your data you will have fewer ticks than you would in a live/demo scenario and this may be part of the issue. The Strategy Tester uses the tick count information to determine how many ticks to create for each bar when it creates the tick data.

. . . in the Strategy Tester how many ticks do your H1 bars have (look at the Volume) ? similar to live or fewer ?



But when this expert launched on strategy tester - no results or they are absolutely wrong. What difference between real trading and strategy tester? Could it possible that there are different prices? For example from broker MT4 receiving 1.5428 and strategy tester somehow calculating and using 1.542800001 (or something like that)? Or testing mode my code see somehow different then real time trading mode?

You need to read and understand what is written in this thread Can price != price ? a price of 1.5428 may actually be 1.5428000000001 or 1.5427999999999 due to the way double value are represented, only 0.0 will actually be 0.0

Fix your code so you compare double values correctly and then test again . . .

So when testing I must choose H1 there, yes?

Yes, you must select H1 in the Period box . . . or fix your code.
 
RaptorUK:

Yes, you are wrong . . .

. . . in the Strategy Tester how many ticks do your H1 bars have (look at the Volume) ? similar to live or fewer ?


You need to read and understand what is written in this thread Can price != price ? a price of 1.5428 may actually be 1.5428000000001 or 1.5427999999999 due to the way double value are represented, only 0.0 will actually be 0.0

Fix your code so you compare double values correctly and then test again . . .

Yes, you must select H1 in the Period box . . . or fix your code.

As a side note (I don't want to disturb the OP), what you said about "only 0.0 will actually be 0.0" isn't true. There are a lot a value with an exact representation in binary format. Of course, it's not that important for the OP.
Reason: