3

Can't run simple expert advisor. Wnd.dll - file from "bin" folder, created with VS2015.

Wnd.dll file is inside a correct "MQL4\Libraries\" folder.
So I tried to run this Advisor on a Live mode but nothing happened. Please help what I am doing wrong.

#property copyright "(c) 2012-2015 Brainroom Ltd."
#property link "http://www.nquotes.net"

#import     "nquotes/nquoteslib.ex4"
    int      nquotes_setup(                   string className, string assemblyName );
    int      nquotes_init();
    int      nquotes_start();
    int      nquotes_deinit();
    double   nquotes_on_tester();
    int      nquotes_on_timer();
    int      nquotes_on_chart_event(          int id, long lparam, double dparam, string sparam );

    int      nquotes_set_property_bool(       string name, bool     value );
    int      nquotes_set_property_int(        string name, int      value );
    int      nquotes_set_property_double(     string name, double   value );
    int      nquotes_set_property_datetime(   string name, datetime value );
    int      nquotes_set_property_color(      string name, color    value );
    int      nquotes_set_property_string(     string name, string   value );
    int      nquotes_set_property_adouble(    string name, double  &value[], int count = WHOLE_ARRAY, int start = 0 );

    bool     nquotes_get_property_bool(       string name );
    int      nquotes_get_property_int(        string name );
    double   nquotes_get_property_double(     string name );
    datetime nquotes_get_property_datetime(   string name );
    color    nquotes_get_property_color(      string name );
    string   nquotes_get_property_string(     string name );
    int      nquotes_get_property_array_size( string name );
    int      nquotes_get_property_adouble(    string name, double &value[] );
#import

int init()
{
    nquotes_setup( "Wnd.Wnd", "Wnd" );  // !!!!changed only this line (NULL, NULL) ->("Wnd.Wnd", "Wnd") 
    return ( nquotes_init() );
}

int start()
{
    return ( nquotes_start() );
}

int deinit()
{
    return ( nquotes_deinit() );
}

double OnTester()
{
    return ( nquotes_on_tester() );
}

void OnTimer()
{
    nquotes_on_timer();
}

void OnChartEvent( const int id, const long& lparam, const double& dparam, const string& sparam )
{
    nquotes_on_chart_event( id, lparam, dparam, sparam );
}

and C# code looks like this:

using NQuotes;
namespace Wnd
{
    public class Wnd : MqlApi
    {

        public bool formCreated = false;
        public override int start()
        {
           if (formCreated == false)
           {
              Form form = new Form();
              form.Show();
              formCreated = true;

              Alert("Hello!");
            }
            return 0;
        }
    }
}

[ UPDATE ]

Expert Wnd EURUSD,M15: removed EURUSD,M15: 50 tick events (3503 bars, 89656 bar states) processed (total time 0:00:05.390)
       Wnd EURUSD,M15: EA.deinit() nquotes_deinit()-> [0]
       Wnd OnTester returns 0.00000000000000
       Wnd EURUSD,M15: EA.OnTester() nquotes_on_tester()-> [ 0.0000000000]
Tester: stop button pressed
       Wnd EURUSD,M15: EA.start() nquotes_start()-> [0]
       Wnd EURUSD,M15: Alert: Hello!
       Wnd EURUSD,M15: EA.init() nquotes_init()-> [0]
       Wnd EURUSD,M15: EA.init() nquotes_setup()-> [0]
       Wnd test started 
user3666197
  • 1
  • 6
  • 50
  • 92
Alexey Gapon
  • 73
  • 2
  • 11
  • You might want to know, that somebody has already proposed to close your question because *(cit.:)* "Questions seeking debugging help (*"why isn't this code working?"*) **must include** the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. **See:** How to create a Minimal, Complete, and Verifiable example." You may take an advantage of this advice & read about some of the best practices advice hints. **Anyway, welcome to the StackOverflow Community** – user3666197 Nov 08 '16 at 10:07

2 Answers2

1

Welcome to the Wild Worlds of MQL4!

Q: What am I doing wrong?
A: Zero debugging effort was shown so far.


If in troubles, first check and publish the version of the libraries/components, all responses from the support personnel received from the commercial vendor of the .EX4 and squeeze to the limits the published API interface-protocols in your own debugging efforts, to isolate the place "Gdě Sabáka Zarýta":

/*
- MISSING .MQ4 VERSION NUMBER ( Build 982+ New-MQL4 )
- MISSING .EX4 VERSION NUMBER ( "nquotes/nquoteslib.ex4" )
- MISSING .DLL VERSION NUMBER
+ ALWAYS PUBLISH ALL THE COMPILER-MODE DIRECTIVES
  #property strict                                               // ?!
  AND ALL OTHER IMPORTANT DEFINITIONS OF THE .MQ4-FILE
====================================================================================
THESE ARE MORE IMPORTANT FOR DEBUGGING, THAN THE COMMERCIAL/COPY-{LEFT|RIGHT} REMARX
*/
int init(){
    int          aRetCODE = nquotes_setup( "Wnd.Wnd", "Wnd" );  // !!!!changed only this line (NULL, NULL) ->("Wnd.Wnd", "Wnd")
    PrintFormat( "EA.init() nquotes_setup()-> [%d]",
                 aRetCODE
                 );
                 aRetCODE = nquotes_init();
    PrintFormat( "EA.init() nquotes_init()-> [%d]",
                 aRetCODE
                 );
    return (     aRetCODE );                                   // return( nquotes_init() )
}

int start(){
    int          aRetCODE =  nquotes_start();
    PrintFormat( "EA.start() nquotes_start()-> [%d]",
                 aRetCODE
                 );
    return (     aRetCODE );                                   // return ( nquotes_start() );
}

int deinit(){
    int          aRetCODE =   nquotes_deinit();
    PrintFormat( "EA.deinit() nquotes_deinit()-> [%d]",
                 aRetCODE
                 );
    return (     aRetCODE );                                   // return ( nquotes_deinit() );
}

double OnTester(){
    int          aRetCODE =     nquotes_on_tester();
    PrintFormat( "EA.OnTester() nquotes_on_tester()-> [%23.10f]",
                 aRetCODE
                 );
    return (     aRetCODE );                                   // return ( nquotes_on_tester() );
}

void OnTimer(){
    int          aRetCODE =    nquotes_on_timer();
    PrintFormat( "EA.OnTimer() nquotes_on_timer()-> [%d]",
                 aRetCODE
                 );
//  nquotes_on_timer();
}

void OnChartEvent(          int     id,
                            long   &lparam,
                            double &dparam,
                            string &sparam
                            ){
    int          aRetCODE =         nquotes_on_chart_event();
    PrintFormat( "EA.OnChartEvent() nquotes_on_chart_event()-> [%d]",
                 aRetCODE
                 );
//  nquotes_on_chart_event( id, lparam, dparam, sparam );
}

Relying on the published API/#import from .EX4 file:

#import     "nquotes/nquoteslib.ex4"
    int      nquotes_setup(                   string className, string assemblyName );
    int      nquotes_init();
    int      nquotes_start();
    int      nquotes_deinit();
    double   nquotes_on_tester();
    int      nquotes_on_timer();
    int      nquotes_on_chart_event(          int id, long lparam, double dparam, string sparam );

    int      nquotes_set_property_bool(       string name, bool     value );
    int      nquotes_set_property_int(        string name, int      value );
    int      nquotes_set_property_double(     string name, double   value );
    int      nquotes_set_property_datetime(   string name, datetime value );
    int      nquotes_set_property_color(      string name, color    value );
    int      nquotes_set_property_string(     string name, string   value );
    int      nquotes_set_property_adouble(    string name, double  &value[], int count = WHOLE_ARRAY, int start = 0 );

    bool     nquotes_get_property_bool(       string name );
    int      nquotes_get_property_int(        string name );
    double   nquotes_get_property_double(     string name );
    datetime nquotes_get_property_datetime(   string name );
    color    nquotes_get_property_color(      string name );
    string   nquotes_get_property_string(     string name );
    int      nquotes_get_property_array_size( string name );
    int      nquotes_get_property_adouble(    string name, double &value[] );
#import
user3666197
  • 1
  • 6
  • 50
  • 92
  • Thank you for your help. But this file is from the example from the author, of the nquotes. – Alexey Gapon Nov 08 '16 at 10:40
  • This piece of information neither helps nor explains your debugging steps. **Have you tried to run it?** + **What results** have been produced during compiler-phase and during run-time ( attach the log ) **?** – user3666197 Nov 08 '16 at 11:16
  • Expert Wnd EURUSD,M15: removed EURUSD,M15: 50 tick events (3503 bars, 89656 bar states) processed (total time 0:00:05.390) Wnd EURUSD,M15: EA.deinit() nquotes_deinit()-> [0] Wnd OnTester returns 0.00000000000000 Wnd EURUSD,M15: EA.OnTester() nquotes_on_tester()-> [ 0.0000000000] Tester: stop button pressed Wnd EURUSD,M15: EA.start() nquotes_start()-> [0] Wnd EURUSD,M15: Alert: Hello! Wnd EURUSD,M15: EA.init() nquotes_init()-> [0] Wnd EURUSD,M15: EA.init() nquotes_setup()-> [0] Wnd test started – Alexey Gapon Nov 08 '16 at 11:24
  • No errors. And even the window appears. But only in test mode. – Alexey Gapon Nov 08 '16 at 11:25
  • Are you telling us, that either of **`EA.init() nquotes_init()-> [?]` + `EA.init() nquotes_setup()-> [?]` did not print / log on real MT4.graph** but only if having been run in MT4.StrategyTester mode? – user3666197 Nov 08 '16 at 11:51
  • 1
    Wnd EURUSD,M10: EA.init() nquotes_init()-> [-4097] Wnd EURUSD,M10: Invalid license. Please switch to a demo account, or order/prolong the license. Problem Solved Thank you all. – Alexey Gapon Nov 08 '16 at 12:19
0

the nquotes package is only workable on demo accts unless you purchase the library. The entire solution goes into the folder that your projects are stored in. The projects are usually class library projects and require an executable project to call the DLL..Also looks like your files are in wrong dir. and not wtitten in c#.