Bug Report List: build 141

 
Hi,

There still seems to be a problem with the 'extern string' side of things. It appears that if the string is initialized using either:

extern string stuff;
or extern string stuff = "";

the user input screen will allow you to input a string but 'stuff' will not be assigned to the value that is input and a "not initialized string" error is generated. If the string is initialized using:

extern string stuff = "some default stringy thingy";

everything works fine
 
Oh yeah, I forgot to mention with regards to the above - if I do the same using other variable types (e.g. int), everything works fine no matter how I initialize the variable.
 
Hi,

Here's a nice bit of code that makes the platform crash...

int init() {
Print("Starting");
return(0);
}

int deinit() {}
int start() {}



I know you're not supposed to do a return during init() but this can be useful when debugging.... However, any 'return' during an init() appears to make the platform crash.
 
Ahhh - silly me - init(), deinit() and start() all require a 'return'! The above problem seems to happen when start() hasn't got any code, including a return.
 
Hi,

I'm getting constant MT crashes when I attempt to run the following code. Anyone got any ideas as to what could be causing this?

=========================================

//+------------------------------------------------------------------+
//| commonLib.mqh |
//| Coen Willemse |
//| "" |
//+------------------------------------------------------------------+
#import "commonLib.ex4"

void split(string splitString, string splitOn, string& splitArray[]);

===========================================

//+------------------------------------------------------------------+
//| commonLib.mq4 |
//| Coen Willemse |
//| |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, Coen Willemse"
#property library


// Splits the sting 'splitString' into it's various parts, splitting on 'splitOn'
void split(string splitString, string splitOn, string& splitArray[]) {

// Initialise and clear out original 'splitArray'
int i;
int startIndex = 0;
int endIndex = 0;
int elementCount = 0;

for (i=0; i<ArraySize(splitArray); i++) {
splitArray[i] = ;
}

// Resize 'splitArray' to maximum string size (256)
ArrayResize(splitArray, 260);

// Go through 'splitString' and assign each token between 'splitOn' to 'splitArray'
int splitOnLength = StringLen(splitOn);
for (i=0; StringFind(splitString, splitOn, startIndex) > -1; i++) {
endIndex = StringFind(splitString, splitOn, startIndex);
splitArray[i] = StringSubstr(splitString, startIndex, endIndex-startIndex);
startIndex = endIndex + splitOnLength;
elementCount++;
}

// Add on last token if 'splitString' doesn't end with the 'splitOn' char(s)
if (StringSubstr(splitString, (StringLen(splitString) - splitOnLength), StringLen(splitString)) != splitOn) {
splitArray[i] = StringSubstr(splitString, startIndex, StringLen(splitString));
elementCount++;
}

// And resize the array to contain only the actual elements.
ArrayResize(splitArray, elementCount);

return(0);
}

================================================

//+------------------------------------------------------------------+
//| signals.mqh |
//| Copyright © 2004, Coen Willemse. |
//| |
//+------------------------------------------------------------------+
#import "signals.ex4"

void MAPriceCrossOver(string gene, double& results[]);


============================================

//+------------------------------------------------------------------+
//| signals.mq4 |
//| Coen Willemse |
//| |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, Coen Willemse"
#property library

#include <commonLib.mqh>


void MAPriceCrossOver(string gene, double& results[]) {

// Min/max values for the various parameters...
int MAX_PERIODS = 300;
int MAX_MA_METHOD = 7;
int MAX_APPLIED_PRICE = 7;
string splitArray[1];
double MIN_R2SCALE = 0.5;
double MAX_R2SCALE = 0.8;
double indValue; // Used to store current value of an indicator call
double prevIndValue; // Used to store previous value of an indicator call

// Split the gene into it's individual allele...
split(gene, ":", splitArray);

// Assign each variable with it's relevant allele
int periods = StrToInteger(splitArray[1]);
int maMethod = StrToInteger(splitArray[2]);
int appliedPrice = StrToInteger(splitArray[3]);
double r2Scale = StrToDouble(splitArray[4]);

// Check to see if valid input has been provided...
if (periods < 1 || periods > MAX_PERIODS) {
Alert("MAPriceCrossOver: 'periods' range is 1 to " + MAX_PERIODS + "!!");
}

if (maMethod < 1 || maMethod > MAX_MA_METHOD) {
Alert("MAPriceCrossOver: 'maMethod' range is 1 to " + MAX_MA_METHOD + "!!");
}

if (appliedPrice < 1 || appliedPrice > MAX_APPLIED_PRICE) {
Alert("MAPriceCrossOver: 'appliedPrice' range is 1 to " + MAX_APPLIED_PRICE + "!!");
}

if (r2Scale < MIN_R2SCALE || r2Scale > MAX_R2SCALE) {
Alert("MAPriceCrossOver: 'r2Scale' range is " + MIN_R2SCALE + " to " + MAX_R2SCALE + "!!");
}


// Work out which prices to use for the calculation...
int prices = 0;
switch (appliedPrice) {
case 1: prices = PRICE_CLOSE; break;
case 2: prices = PRICE_OPEN; break;
case 3: prices = PRICE_HIGH; break;
case 4: prices = PRICE_LOW; break;
case 5: prices = PRICE_MEDIAN; break;
case 6: prices = PRICE_TYPICAL; break;
case 7: prices = PRICE_WEIGHTED; break;
}
Print("Running");
ArrayResize(results, 2);
results[0] = 0.111;
results[1] = 0.222;
return(0);
}


===================================================


//+------------------------------------------------------------------+
//| Testie1.mq4 |
//| Copyright © 2004, MetaQuotes Software Corp. |
//| https://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, MetaQuotes Software Corp."
#property link "https://www.metaquotes.net/
#include <signals.mqh>

int init() {
Print("Starting");
return(0);
}

int deinit() { return(0);}

int start() {

double indResults[1];

MAPriceCrossOver("1:20:6:1:0.5", indResults);
for (int i=0; i<ArraySize(indResults); i++) {
Print(indResults[i]);
}



return(0);
}

//+------------------------------------------------------------------+
 
Hi MetaQuotes,

I think I may have spotted a documentation fault on your website. Under the section "PreProcessor" the follow is documented:

"Functions are imported from MQL4 compiled modules (*.ex4 files) and from operating system modules (*.dll files). In the latter case, the imported functions are also declared. A new #import command (it can be without parameters) finishes the description of imported functions".

As far as I can work out, BOTH types of import (MQL4 and .dll) files require function declarations in an 'include file'. I tried it without a declaration but the compiler starts making noises about "function not found" etc.
 
declarations in the included *.mqh files are optional and not required strongly.
but declarations are to be present in any case if you call imported functions