stevehopwoodforex.com
https://www.stevehopwoodforex.com/phpBB3/
Print view

Empty4 v600 for Coders
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=3439
Page 2 of 5
Author:  milanese [ Tue Feb 18, 2014 12:35 pm ]
Post subject:  Re: Empty4 v600 for Coders

Pedigree » Tue Feb 18, 2014 7:58 am wrote:
SpiderX » Fri Feb 14, 2014 11:16 am wrote:As long as we have that stuff which we have in between our ears running...I guess we can take whatever they throw at us right ? :smile:

Cheers
Thank you so much for starting this. It is sorely needed and will be such great help.

A Question: What redress, if any, is there to help 509 dlls retain their viability in 6xx other than a complete re-write?
The new build uses Unicode strings, not Ansi strings.
Look here for more informations...http://forum.mql4.com/60608#903603

Cheers :)

Tommaso
Author:  Pedigree [ Tue Feb 18, 2014 3:00 pm ]
Post subject:  Re: Empty4 v600 for Coders

milanese » Tue Feb 18, 2014 1:35 pm wrote:
Pedigree » Tue Feb 18, 2014 7:58 am wrote:
SpiderX » Fri Feb 14, 2014 11:16 am wrote:As long as we have that stuff which we have in between our ears running...I guess we can take whatever they throw at us right ? :smile:

Cheers
Thank you so much for starting this. It is sorely needed and will be such great help.

A Question: What redress, if any, is there to help 509 dlls retain their viability in 6xx other than a complete re-write?
The new build uses Unicode strings, not Ansi strings.
Look here for more informations...http://forum.mql4.com/60608#903603

Cheers :)

Tommaso
Will have a look, Tommaso. Thanks a million! :good:
Author:  Pedigree [ Thu Feb 20, 2014 10:08 am ]
Post subject:  Re: Empty4 v600 for Coders

SpiderX » Wed Feb 12, 2014 3:46 pm wrote:Next warning: implicit conversion from 'number' to 'string'

Results from

Code: Select all

SM("Magic number: "+MagicNumber+NL);
Solution:

Code: Select all

SM(StringConcatenate("Magic number: ",MagicNumber,NL));
Cheers

Edit: These turn out to be a lot of trouble to correct....would be great if someone can provide a quicker solution.
Now that's putting it mildly. Just don't mention the monstrous distraction all this is turning out to be.
Author:  fxdaytrader [ Sun Feb 23, 2014 3:10 pm ]
Post subject:  Empty4 v600 for Coders

For those which want to use the old < build 600 compiler version (e.g. to compile code which cannot be compiled with the newest versions) you may have a look to my thread at http://www.forexfactory.com/showthread.php?t=470340 (download the .zip there pls, I am not sure if it is too big to be uploaded here). :yahoo:
[mod=]Ok here is the file attached, thank you fxdaytrader :good:
Cheers :)
Tommaso[/mod]
~~old.mql4editor.zip
Author:  JvW [ Mon Feb 24, 2014 12:58 am ]
Post subject:  Empty4 v600 for Coders

Hi all,

just my 2 cents worth on the build 600:

1) in Empty4 pre v600 you could do naughty things like this:

string S1;
S1 = "some text:";
S1 = S1 + " new text";

resulting in S1 acquiring the value "some text: new text";

Unfortunately - you can no longer do this, and if you have any code that relies on this, it will no longer work.

The solution to resolve the issue is simple (which is cleaner anyway):

string S1, tmp="";
S1 = "some text";
tmp = S1;
S1 = tmp + "new text";

2) I may be wrong in understanding but I have tested the following:

IndicatorCounted():
Returned value - The amount of bars not changed after the indicator had been launched last.

prev_calculated:
'We should noted the connection between the return value of OnCalculate() and the second input parameter prev_calculated. During the function call, the prev_calculated parameter contains a value returned by OnCalculate() during previous call. This allows for economical algorithms for calculating the custom indicator in order to avoid repeated calculations for those bars that haven't changed since the previous run of this function.

For this, it is usually enough to return the value of the rates_total parameter, which contains the number of bars in the current function call. If since the last call of OnCalculate() price data has changed (a deeper history downloaded or history blanks filled), the value of the input parameter prev_calculated will be set to zero by the terminal.'

Both in strategy tester and on live data I see the following values produced by Empty4 v600:
on NewBar: Bars == rates_total, prev_calculated == rates_total-1, IndicatorCounted() == prev_calculated-1
during bar: Bars == rates_total, prev_calculated == rates_total, IndicatorCounted() == prev_calculated-1
and this is regardless of whether OnCalculate() has a return(x) with x=rates_total, x=prev_calculated, x=0, x=1, x=-1. Somehow it appears that the return value from OnCalculate is not used in any way....(but I may be dumb :P )

You can use the following code in an indicator to test this behaviour.

Code: Select all

   int bars=Bars(Symbol(),0);
   int ic = IndicatorCounted();
   int BminIC = bars - ic - 1;
   int BminPC = rates_total - prev_calculated;
   
   if (NewBar())
      Print(" Bars = ",bars,
         ", rates_total = ",rates_total,
         ", prev_calculated = ",prev_calculated, 
         ", IndiCounted() = ",ic,
         ", BminIC - BminPC =",BminIC-BminPC,
         ", newbar() = ",NewBar()
         );
   else
      Print(" Bars = ",bars,
         ", rates_total = ",rates_total,
         ", prev_calculated = ",prev_calculated, 
         ", IndiCounted() = ",ic,
         ", BminIC - BminPC =",BminIC-BminPC
         );
   if (BminIC-BminPC != 0) Print("*******************DIFFERENCE 1 ****************");
bool NewBar() {
   static datetime lastbar;
   datetime curbar = Time[0];
   if(lastbar!=curbar) {
      lastbar=curbar;
      return (true);
      }
   else 
      return(false);
}
If your indicator uses a loop over bars that relies on either of the following:
loopcount = Bars-IndicatorCounted() [shorthand LC=B-IC] or
loopcount = rates_total-prev_calculated [shorthand LC=RT-PC]
you will notice that the behaviour is slightly different:

on Newbar: RT-PC = 1, and B-IC = 2
during bar: RT-PC = 0, and B-IC = 1.

Obviously, and dependent on your indicator code, when porting your code to the new v600 environment this difference in loopcount may have an impact on how and when your indicator gets updated!

Cheerio,

John
Author:  milanese [ Mon Feb 24, 2014 1:48 pm ]
Post subject:  Empty4 v600 for Coders

http://www.stevehopwoodforex.com/phpBB3 ... 774#p86774

I edited the post and uploaded the file , again thank you fxdaytrader

Cheers :)

Tommaso
Author:  jcl [ Sun Mar 02, 2014 6:20 pm ]
Post subject:  Empty4 v600 for Coders

Strings have now a completely different format and use Unicode, not ASCII.

If you pass and receive strings from external DLLs, you must now convert them to ASCII before, with CharArrayToString() and StringToCharArray().

The trick to trigger an EA by posting a message to the chart window does not work anymore as before. You now need a Unicode message.

Previously;

msg = RegisterWindowMessageA("MetaTrader4_Internal_Message");

From 600+ on:

msg = RegisterWindowMessageW("MetaTrader4_Internal_Message");
Author:  renexxxx [ Sat Mar 08, 2014 6:19 am ]
Post subject:  Empty4 v600 for Coders

Further on the subject of concatenating strings with integers, doubles and other strings, there is a new function called:

Code: Select all

string  StringFormat(
   string  format,     // string with format description
   ...     ...         // parameters
   );
that allows to specify placeholders inside the format string, similarly to the C printf() function. The exact syntax can be looked up under the PrintFormat function, as it has the same syntax.

So, you can do things like:

Code: Select all

#define PI 3.14159265358979323846264338327950288419716939937510
void OnStart() {
//---
   int myint = 109;
   float myfloat = -70.9f;
   double mydouble = PI;
   string text = StringFormat( "This is some text with an integer (%d), a float (%5.2f) and a double (%5.9f)", myint, myfloat, mydouble );
   Print(text);
}
Author:  SpiderX [ Sat Mar 29, 2014 4:34 am ]
Post subject:  Empty4 v600 for Coders

Hi all,

Still doing my best to keep this updated.
Please give me a nudge if you feel something could be added to the first post.

Cheers
Author:  SpiderX [ Sat Mar 29, 2014 7:30 am ]
Post subject:  Empty4 v600 for Coders

This is a helpful article for coders:

http://articles.mql4.com/1160?source=me ... r5_article

Cheers
All times are UTC Page 2 of 5