for array passing (as written in headline) see functions
double GetArrayItemValue(double arr[],int,int); bool SetArrayItemValue(double& arr[],int,int,double); double GetRatesItemValue(double rates[][6],int,int,int);
in the ExpertSample.dll sample
for string passing see
string GetStringValue(string);
for call samples see ExportFunctions.mq4
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I am trying to pass the following string to an external DLL but can't do this as I do not know how to convert the string for export into an array for passing. This is what I want to send to the external DLL....
TB_PLACEORDER( , BUY, 6.0 , eurusd, , , MARKET, 0 , 0 , , Rod, Hurricane, Euro);
I want to send the part in brackets to an external DLL.
How do I send it as an array?
I dont know how to define it and size it as an array, and where do I put this in my code?
Thanking you kindly in advance.
This is my code below........
#import "TradeBoltUniLink32.DLL" // this is the DLL file so as MT4 can communicate with
// TradeBolt API. This DLL file is located in windows\system32 directory
// TB_PLACEORDER : Place order. Returns the TB ticket number which can later be
// cross referenced to the broker ticket via the TB_GetTicketXRef function. }
// the code below aims to declare and define the TB_PLACEORDER extrenal function......
int TB_PLACEORDER(string , string BuySell, double Qty, string TSSymbol, double LimitPrice,
double StopPrice, string OrderType1, double, double, string,
string Workspace, string System, string Signal);
// the code below is the input for sending a market buy order for 6.0 lots to TradeBolt API....
// TB_PlaceOrder( , BUY, 6.0, EURUSD, , , MARKET, 0 , 0 , , Rod, Hurricane, Euro);
// TB_PlaceOrder
// FUNCTION TB_PLACEORDER(Reserved1 AS ASCIIZ, BuySell AS ASCIIZ, BYVAL Qty AS DOUBLE,
// TSSymbol AS ASCIIZ, BYVAL LimitPrice AS DOUBLE, BYVAL StopPrice AS DOUBLE, OrderType AS ASCIIZ,
// BYVAL Reserved2 AS DOUBLE, BYVAL Reserved3 AS DOUBLE, Reserved4 AS ASCIIZ,Workspace AS ASCIIZ,
// System AS ASCIIZ, Signal AS ASCIIZ) EXPORT AS STRING
// Places an order with broker. Returns an internal tracking TB Ticket number.
// This can be used to cross reference the actual broker ticket using the TB_GetTicketXRef function.
// INPUT:
// Reserved: Reserved for future use and you MUST set it to a blank.
// BuySell: Either "BUY" or "SELL"
// Qty: Order Quantity
// TSSymbol: TS Symbol
// LimitPrice: Price to execute LIMIT order type. This is ignored for MARKET orders.
// StopPrice: Price to execute STOP order type. This is ignored for MARKET orders.
// OrderType: Either "LIMIT", "STOP", "MARKET", "STOPLIMIT". Some order types are NOT supported
by certain exchanges.
// Reserved2: Reserved for future use. Must be set to zero.
// Reserved3: Reserved for future use. Ignored. Must be set to zero.
// Reserved4: Reserved for future use. Ignored.
// Workspace: Workspace name
// System: System name
// Signal: Signal name
// OUTPUT:
// Returns the TB Ticket number for this order. Use the TB_GetTicketXRef function to cross reference the broker ticket.
#import
//+------------------------------------------------------------------+
//|
//+------------------------------------------------------------------+
extern double TakeProfit = 50;
extern double Lots = 0.1;
extern double MACDOpenLevel=3;
extern double MACDCloseLevel=2;
extern double MATrendPeriod=26;
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
double MacdCurrent, MacdPrevious, SignalCurrent;
double SignalPrevious, MaCurrent, MaPrevious;
int cnt, ticket, total;
string BUY;
string EURUSD;
string MARKET;
string Rod;
string Hurricane;
string Euro;
int TB_PlaceOrder;
// initial data checks
// it is important to make sure that the expert works with a normal
// chart and the user did not make any mistakes setting external
// variables (Lots, StopLoss, TakeProfit)
// in our case, we check TakeProfit INPUT VALUE
// and make sure we have at least 100 bars on the chart....
if(Bars<100)
{
Print("bars less than 100");
return(0);
}
if(TakeProfit<10)
{
Print("TakeProfit less than 10");
return(0); // check TakeProfit
}
// to simplify the coding and speed up access
// data are put into internal variables
MacdCurrent=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,0);
MacdPrevious=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,1);
SignalCurrent=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,0);
SignalPrevious=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,1);
MaCurrent=iMA(NULL,0,MATrendPeriod,0,MODE_EMA,PRICE_CLOSE,0);
MaPrevious=iMA(NULL,0,MATrendPeriod,0,MODE_EMA,PRICE_CLOSE,1);
total=OrdersTotal();
if(total<1)
{
// no opened orders identified
if(AccountFreeMargin()<(1000*Lots))
{
Print("We have no money. Free Margin = ", AccountFreeMargin());
return(0);
}
// check for long position (BUY) possibility
if(MacdCurrent<0 && MacdCurrent>SignalCurrent && MacdPrevious<SignalPrevious &&
MathAbs(MacdCurrent)>(MACDOpenLevel*Point) && MaCurrent>MaPrevious)
{
// the code below aims to send a market order for 6.0 lots to TradeBolt's API...........this string (which I
// want to send to the DLL) needs to be sent as an array - but I am having trouble converting the part in
// brackets to an array which can then be sent to the DLL.
TB_PLACEORDER( , BUY, 6.0, EURUSD, , , MARKET, 0 , 0 , , Rod, Hurricane, Euro);
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Ask+TakeProfit*Point,"macd sample",16384,0,Green);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());
}
else Print("Error opening BUY order : ",GetLastError());
return(0);
}
// check for short position (SELL) possibility
if(MacdCurrent>0 && MacdCurrent<SignalCurrent && MacdPrevious>SignalPrevious &&
MacdCurrent>(MACDOpenLevel*Point) && MaCurrent<MaPrevious)
{
ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,Bid-TakeProfit*Point,"macd sample",16384,0,Red);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice());
}
else Print("Error opening SELL order : ",GetLastError());
return(0);
}
return(0);
}
// it is important to enter the market correctly,
// but it is more important to exit it correctly...
for(cnt=0;cnt<total;cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderType()<=OP_SELL && // check for opened position
OrderSymbol()==Symbol()) // check for symbol
{
if(OrderType()==OP_BUY) // long position is opened
{
// should it be closed?
if(MacdCurrent>0 && MacdCurrent<SignalCurrent && MacdPrevious>SignalPrevious &&
MacdCurrent>(MACDCloseLevel*Point))
{
OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet); // close position
return(0); // exit
}
}
else // go to short position
{
// should it be closed?
if(MacdCurrent<0 && MacdCurrent>SignalCurrent &&
MacdPrevious<SignalPrevious && MathAbs(MacdCurrent)>(MACDCloseLevel*Point))
{
OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet); // close position
return(0); // exit
}
}
}
}
return(0);
}
// the end.