configuration include

 

Suppose we have an indicator y with an automated signal "function" built to operate on the output of a custom optimization process.

Like a library.

So if there is no "core" there are no signals on the indicator.

If this product is headed for the market , in what ways can the configuration be included in the indicator so that

it can at least offer some capabilities demonstration to those who want to run the default market demo . (apart from any external demos)

(For normal use the "core" would have manual update+upload intervals and users would download and load the core via the input screen)

I understand you cannot resource custom extensions    

Cores would be ~1MB + in size

Thanks

 
Lorentzos Roussos: Suppose we have an indicator y with an automated signal "function" built to operate on the output of a custom optimization process. Like a library. So if there is no "core" there are no signals on the indicator. If this product is headed for the market , in what ways can the configuration be included in the indicator so that it can at least offer some capabilities demonstration to those who want to run the default market demo . (apart from any external demos) (For normal use the "core" would have manual update+upload intervals and users would download and load the core via the input screen) I understand you cannot resource custom extensions. Cores would be ~1MB + in size
I'm trying to understand your query, but I confess I'm totally lost as to what you are trying to ask. Can you perhaps explain it differently, please?
 
Fernando Carreiro #:
I'm trying to understand your query, but I confess I'm totally lost as to what you are trying to ask. Can you perhaps explain it differently, please?

I apologize .

I will simplify :

Lets assume you have an indicator with neural nets per the signal decision .

These neural nets have an optimal configuration .

These configurations are essentially a list of double values  , a lot of values .

They are stored in files , "cores" , which the user can load , while normally operating the indicator.

How can a default (one of those files) be "embedded" in the indicator so that in the strategy tester demo , from the market (clicking on demo),

the indicator can operate (without the user having loaded anything)

 
Lorentzos Roussos #: I apologize. I will simplify: Lets assume you have an indicator with neural nets per the signal decision. These neural nets have an optimal configuration. These configurations are essentially a list of double values, a lot of values. They are stored in files , "cores" , which the user can load , while normally operating the indicator. How can a default (one of those files) be "embedded" in the indicator so that in the strategy tester demo , from the market (clicking on demo), the indicator can operate (without the user having loaded anything)

Ok, now I understand!

I suppose one way, would be to store a demo set of the data in the code itself, for example as a default declaration like the following very simplistic one:

double data[] = { 0.1, 1.2, 2.3, 3.4, 4.5 };

Obviously, it would be something much more complex than the above example.

In your code, you could then detect when it is running a demo download in the Strategy Tester and automatically load the demo data. You would also have to inform the user under which conditions (symbol, timeframe, etc.) the demo data would be most appropriate.

The disadvantage, would be that the final executable file would always be quite large as it would include the demo data.

EDIT: You can detect when the user is running a valid license or only a demo download using: Documentation on MQL5: Constants, Enumerations and Structures / Environment State / Running MQL5 Program Properties

MQLInfoInteger( MQL_LICENSE_TYPE )
 

Another option, is to store the data in BMP files loaded as a resource using ResourceReadImage() and then mapping them to the real structure or array of structure using the union statement.

But personally, I would prefer using the declaration method mentioned in the previous post, in an #include file.

 
Fernando Carreiro #:

Another option, is to store the data in BMP files loaded as a resource using ResourceReadImage() and then mapping them to the real structure or array of structure using the union statement.

But personally, I would prefer using the declaration method mentioned in the previous post, in an #include file.

Thanks for the ideas . So i would export an include file too so that it could be included in the default config . 

And it seems i would also need to load from a bytestream instead of a file ,because i cannot write files on the tester ?... (im a bit of an amateur coder)

Thank you Mr Carreiro

 
Lorentzos Roussos #: Thanks for the ideas . So i would export an include file too so that it could be included in the default config. And it seems i would also need to load from a bytestream instead of a file ,because i cannot write files on the tester ?... (im a bit of an amateur coder. Thank you Mr Carreiro

Method 1, data declaration, is in my opinion the easiest to apply and use. Method 2, the BMP resource, is more complex.

Method 1:

You would create an "xxx.mqh" file, where you have global variables declared with compile time initialization such as the following example.

double data[] = { 0.1, 1.2, 2.3, 3.4, 4.5 };

You would then use an "#include" statement in the beginning of your indicator code for the above file.

In your indicator code, probably when the first tick arrives in the OnCalculate() handler, you would then detect for it running under the Strategy Tester and having a "Demo License", and then assign or copy your "data[]" to the appropriate variables to be used as the default data for your process.

Method 2:

This may be too complex for an amateur coder, but you would have to export your data structures out into a valid BMP file format, which you would then import as a resource file. Then at runtime, read it back in and remap it to the original data structure.

Personally, I would choose the method 1 solution. It will be more efficient as most of it is taken care of at compile time, instead of at runtime in the case of the BMP resource.

 
Fernando Carreiro #:

Method 1, data declaration, is in my opinion the easiest to apply and use. Method 2, the BMP resource, is more complex.

Method 1:

You would create an "xxx.mqh" file, where you have global variables declared with compile time initialization such as the following example.

You would then use an "#include" statement in the beginning of your indicator code for the above file.

In your indicator code, probably when the first tick arrives in the OnCalculate() handler, you would then detect for it running under the Strategy Tester and having a "Demo License", and then assign or copy your "data[]" to the appropriate variables to be used as the default data for your process.

Method 2:

This may be too complex for an amateur coder, but you would have to export your data structures out into a valid BMP file format, which you would then import as a resource file. Then at runtime, read it back in and remap it to the original data structure.

Personally, I would choose the method 1 solution. It will be more efficient as most of it is taken care of at compile time, instead of at runtime in the case of the BMP resource.

Yeah one (1) sounds better . In (2) i would have to write only in the data section of the bmp ?

But say that these are structured , i would need to turn the "load" and "save" functions to load from an array of bytes right ? 

class node
{
public:
double value;
uchar  type;
int    depth;
       node(void){reset();}
  void reset(){value=0.0;type=0;depth=0;} 
  void save(int file_handle){
       FileWriteInteger(file_handle,type,CHAR_VALUE);
       FileWriteDouble(file_handle,value,DOUBLE_VALUE);
       FileWriteInteger(file_handle,depth,INT_VALUE);
       }
  void load(int file_handle){
       reset();
       type=(uchar)FileReadInteger(file_handle,CHAR_VALUE);
       value=(double)FileReadDouble(file_handle,DOUBLE_VALUE);
       depth=(int)FileReadInteger(file_handle,INT_VALUE);
       }
};

struct rack{
node     nodes[];
datetime compilation_date;       
         //
         rack(void){reset(true);}
        ~rack(void){reset(true);}
    void reset(bool remove_array){
         if(remove_array){for(int i=0;i<ArraySize(nodes);i++){delete(GetPointer(nodes[i]));}ArrayFree(nodes);}
         compilation_date=0;
         for(int i=0;i<ArraySize(nodes);i++){nodes[i].reset();}
         }
    void save(int file_handle){
         FileWriteLong(file_handle,((long)compilation_date));
         //#
         FileWriteInteger(file_handle,ArraySize(nodes),INT_VALUE);
         for(int i=0;i<ArraySize(nodes);i++){nodes[i].save(file_handle);}
         }
    void load(int file_handle){
         reset(true);
         compilation_date=(datetime)FileReadLong(file_handle);
         int total=(int)FileReadInteger(file_handle,INT_VALUE);
         if(total>0){
         ArrayResize(nodes,total,0);
         for(int i=0;i<total;i++){nodes[i].load(file_handle);}
         }
         }
      
};

Thank you for your time

 
Lorentzos Roussos #: Yeah one (1) sounds better . In (2) i would have to write only in the data section of the bmp ? But say that these are structured , i would need to turn the "load" and "save" functions to load from an array of bytes right ? 

Yes, for a BMP you would have to save it to the data section as a array of bytes or uchars.

Regarding your code, you could write a "save" method for exporting the data to a text file in a MQL header ".mqh" format, and a "load" method to read the data from the data declared in the include file.

 
Fernando Carreiro #:

Yes, for a BMP you would have to save it to the data section as a array of bytes or uchars.

Regarding your code, you could write a "save" method for exporting the data to a text file in a MQL header ".mqh" format, and a "load" method to read the data from the data declared in the include file.

Thank you . 

I've swamped into the bytes to double conversion . 

Everyday something new. xD 

Thank you for the ideas.

 
Lorentzos Roussos #: Thank you. I've swamped into the bytes to double conversion. Everyday something new. xD Thank you for the ideas.

You are welcome!

Reason: