Welcome to Forex-TSD!, one of the largest Forex forums worldwide, where you will be able to find the most complete and reliable Forex information imaginable.
From the list below, select the forum that you want to visit and register to post, as many times you want. It’s absolutely free. Click here for registering on Forex-TSD.
EXCLUSIVE FORUM
The Exclusive Forum is the only paid section. Once you subscribe, you will get free access to real cutting-edge Trading Systems (automated and not), Indicators, Signals, Articles, etc., that will help and guide you, in ways that you could only imagine, with your Forex trading.
Elite Section
Get access to private discussions, specialized support, indicators and trading systems reported every week.
Advanced Elite Section
For professional traders, trading system developers and any other member who may need to use and/or convert, the most cutting-edge exclusive indicators and trading systems for MT4 and MT5.
I've developed a set of functions to manage configuration settings from an EA.
Those functions are exported by a c++ DLL and each of the exported function has the __stdcall calling convetion requested my MQL4.
My problem arises when a function need to return a string to the EA.
Naturally the function cannot:
- return a pointer to a local variabile (variable goes out of scope)
- return a pointer to a dll global variable (problems with concurrent access)
- return a pointer to a heap allocated string (need functions to free memory to be called from the EA: I don't not like this approach)
So i resolved to pass a string and string size from the EA. Es:
Code:
string buffer;
GetString( buffer, 30 );
and from the c++ dll, something like this
Code:
void __stdcall GetString( LPTSTR buffer, int BufSize )
{
// Read a string from a some source
....
// -1 to take into account the terminating null character
StringCchCopy( buffer, BufSize-1, ReadStringFromASource );
}
Here starts the weird behaviour of MQL managing strings returned from a DLL.
using the following code:
Code:
string buffer;
GetString( buffer, 30 );
the first time buffer contains the right string. A first question arises: buffer is not initialized but after calling GetString it contains the string returned. I have to suppose that MQL allocates space for a string variable when it's declared.
Next time GetString() is called the string returned seems to be truncated to the length-1 of the previous string length and not resetted as expected because of the 'string buffer;' statement.
but after the first time, when the execution returns to this code, the assignment of buffer does not work any more and buffer still contains the previous read string, and it seems it can only contains the number of characters of his content.
At first I have thought that the null character is not handled very well by MQL and modified the c++ code like this ...
What is the difference between a Limit order and a Stop order?
Thanks
Here's the MT4 platform help file:
Quote:
Pending Order
Pending order is the client's commitment to the brokerage company to buy or sell a security at a pre-defined price in the future. This type of orders is used for opening of a trade position provided the future quotes reach the pre-defined level. There are four types of pending orders available in the terminal:
Buy Limit — buy provided the future "ASK" price is equal to the pre-defined value. The current price level is higher than the value of the placed order. Orders of this type are usually placed in anticipation of that the security price, having fallen to a certain level, will increase;
Buy Stop — buy provided the future "ASK" price is equal to the pre-defined value. The current price level is lower than the value of the placed order. Orders of this type are usually placed in anticipation of that the security price, having reached a certain level, will keep on increasing;
Sell Limit — sell provided the future "BID" price is equal to the pre-defined value. The current price level is lower than the value of the placed order. Orders of this type are usually placed in anticipation of that the security price, having increased to a certain level, will fall;
Sell Stop — sell provided the future "BID" price is equal to the pre-defined value. The current price level is higher than the value of the placed order. Orders of this type are usually placed in anticipation of that the security price, having reached a certain level, will keep on falling.
Hope that helps.
FerruFx
__________________ FerruFx / www.ervent.net - Professional Coding Services (EAs/Indicators/Alerts)
This seems to be simple to code but my trades do not close when they are supposed to.
In this example trades should close at the cross of the lower time frame.
if (CloseSell1_1 > CloseSell1_2) Order = SIGNAL_CLOSESELL;
As you see , this is my code of my expert Advisor.
Some variables are in greek.
Timi_Tora: -> Price_Now
my_string_timi_tora: -> The string of Price_Now
Mesi_Timi: -> Average_Price
my_string_mesos_oros:-> My string of Average
pinakas_timon[5]:-> Table of Variables
mesos_oros:-> Average
ypologisa_ton_meso_oro:->I calsulated the average
timi_high:-> Price High
timi_open:-> Price Open
xronos:-> Chronos
I put some english translate to my greek variables.
This expert advisor , Compares the high of the previously bar with the high of the current bar.
If the current bar with index[0] is lower than the previously bar , index[1] then I am opening one sell order.
Most of times the order is lower At least on pip of the previously , because as a high of this bar , have big change to go below at least one pip.
I have put 10 pips as take profit but some times the value reach the 9 pips and the order does not establish.
So some trailing ston need to wost time to take one pip profit.
This code is working with H1 Time Period
How do I do that?
This code working with H1 Time Period
Thank you very much.
I made some changes in another code...
And I had abnormal results , I backtest it from 1999 to 2007 and it made this Idea , about four hundred trilion dolars.
Then after 2007 program got crazy and drop OrderSend Error 138 .