Need help converting a Tradestation ELA to MQ4
I have been working on converting a Tradestation ELA to Metatrader to use as an indicator. The mq4 uses a dll to access a neural net I have trained. It is giving me some problems.
Here is the current problem. The neural net was developed to take 10 inputs. When I run the mq4 I get an eror to "do a TRADE_ASK" before adding more inputs. This is an error from the dll. It seems the stack doesn't flush if a previous attempt to run the mq4 fails.
here is the code I've come up with so far
//+------------------------------------------------------------------+
//| darNN.mq4 |
//| Doug Robertson |
//| |
//+------------------------------------------------------------------+
#property copyright "Doug Robertson"
#property link ""
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Lime
#property indicator_color2 Red
double ExtMapBuffer0[];
double ExtMapBuffer1[];
double bc_ask1;
double bc_ask2;
double answer1;
double answer2;
double getprice;
//---- indicators
//import Tradecel.dll and funtions
#import "TRADECELGBPHI.dll"
int TRADE_OPEN_NET(string netname,string password);
int TRADE_ADD_TO_ASKLIST(int currpair);
int TRADE_ASK(int currask);
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
SetIndexStyle(0,DRAW_LINE,0,1, Lime);
SetIndexBuffer(0, ExtMapBuffer0);
SetIndexStyle(1,DRAW_LINE,0,1,Red);
SetIndexBuffer(1,ExtMapBuffer1);
SetIndexDrawBegin(0,0);
SetIndexDrawBegin(1,0);
int success;
int currpair;
// int currask[];
int answer;
double answer1[];
string netname;
string password;
//---- input parameters
//---- buffers
double ExtMapBuffer0[];
double ExtMapBuffer1[];
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
/*int deinit()
{}
{Return(0)}
*/
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
// Open neural net named GBOPEN.NET and test
// to see if it succeeded
string netname="H:\ForexNets\GBPOPEN.NET";
int success=TRADE_OPEN_NET("H:\ForexNets\GBPOPEN.NET","");
{
if(success==1)
int currpair;
//Multiply currency pairs to be used in NN, multiply
// them to get int type
TRADE_ADD_TO_ASKLIST(iOpen("AUDUSDm",PERIOD_M1,0)*10000);
TRADE_ADD_TO_ASKLIST(iClose("AUDUSDm",PERIOD_M1,0)*10000);
TRADE_ADD_TO_ASKLIST(iOpen("USDJPYm",PERIOD_M1,0)*100);
TRADE_ADD_TO_ASKLIST(iClose("USDJPYPm",PERIOD_M1,0)*100);
TRADE_ADD_TO_ASKLIST(iOpen("EURUSDm",PERIOD_M1,0)*10000);
TRADE_ADD_TO_ASKLIST(iClose("EURUSDm",PERIOD_M1,0)*10000);
TRADE_ADD_TO_ASKLIST(iOpen("EURGBPm",PERIOD_M1,0)*10000);
TRADE_ADD_TO_ASKLIST(iClose("EURGBPm",PERIOD_M1,0)*10000);
TRADE_ADD_TO_ASKLIST(iOpen("GBPUSDm",PERIOD_M1,0)*10000);
TRADE_ADD_TO_ASKLIST(iClose("GBPUSDm",PERIOD_M1,0)*10000);
//Ask NN for result based on current GBPUSD price
getprice=iClose("GBPUSDm",PERIOD_M1,0);
int currask;
currask=getprice*10000;
int answer[];
answer[1]=TRADE_ASK(currask);
{return(answer[1]);}
}
}
/////////////////////////////////////////////////////////////////////////////////
Here is the documentation that came with the Neural net sortware to create the ELA
"BC_Ask" Study (Indicator) :
[LegacyColorValue = true];
{
This demonstration indicator shows how to plot the results from a
Braincel neural net, as called by the demonstration function BC_ASK.
}
value1 = BC_ASK ;
plot1 ( value1, "NeuralNet") ;
"BC_Ask" User Function :
[LegacyColorValue = true];
{
This is a demonstration of how to send data to and receive a
response from a Braincel neural net that was originally
created in Microsoft Excel.
BC_ASK performs these tasks:
1. Finds and opens a neural net produced by Braincel
2. Collects data to be sent as a group to the net.
3. Sends that data to the net and retrieves the net's output
4. Returns the net's output to the indicator which called BC_ASK.
BC_ASK requires the user to specify the following:
1. When the function is to be applied
2. The file path to the neural net .NET file on your hard drive.
3. What data is to be collected and sent to the net.
================================================================
}
var: success(2), answer(0), k(0);
{ -------------------
Each of the 3 DefineDllFunc commands below tell TradeStation
the following information:
* the name of the file containing generic NN code.
* the generic NN function names: "TRADE_ASK", "TRADE_OPEN_NET", "TRADE_ADD_TO_ASKLIST"
* the generic NN function input and output parameter types.
---------------------
}
DefineDllFunc:"Tradecel.DLL",INT,"TRADE_OPEN_NET",LPSTR,LPSTR;
DefineDllFunc:"Tradecel.DLL",INT,"TRADE_ADD_TO_ASKLIST",FLOAT;
DefineDllFunc:"Tradecel.DLL",INT,"TRADE_ASK",LPFLOAT;
{--- Initialize the NN output value ---}
Answer = 0;
/////////////////////////////////////////////////////////////////////////////////
Can anyone here give me some advice on finishing this project. I think wit will be an awesome tool.
