| New signals service! | |
|
|||||||
| Register in Forex TSD! | |
|
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time). Click here to register and get more information |
|
![]() |
|
|
LinkBack (1) | Thread Tools | Display Modes |
|
|||
|
Maybe someone can help me, i dont know if its possible or very hard to do it, but I would be very happy to have such tool. I need a simple EA or script with a help of MT4-LevelStop-Reverse indicator. I want my orders to be closed when i get opposite signal from indicator. If i have opened long order and get short signal the EA or script closes order and if i am short open order and get long sygnal the EA or script closes my short position. That's it
![]() Thank you in advance |
|
||||
|
Quote:
PHP Code:
|
|
|||
|
Quote:
Lux
__________________
Build An Expert Advisor. FREE E-course As Seen On TV ![]() ForexArea.com Users of Gap Trader from 'Forex-Assistant' MUST Read This |
|
||||
|
Sorry, I meant ||
and I was trying this to; //+---------Trade hour variables------------------ // if (Hour() < StartHour) TradeHourS = false; // if (Hour() > EndHour) TradeHourE = false; So if StartHour=5 and EndHour=17 it should only trade within those hours correct? But it trade anytime still ?? is it a problem using the Strategy Tester? |
|
|||
|
Why not just use the example straight from the help file?
Code:
bool is_siesta=false;
if(Hour()>=12 || Hour()<17)
is_siesta=true;
__________________
Build An Expert Advisor. FREE E-course As Seen On TV ![]() ForexArea.com Users of Gap Trader from 'Forex-Assistant' MUST Read This |
|
|||
|
Returning string from a c/c++ DLL exported functions
Hi everyone,
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 ); 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 ); 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. Tried even: Code:
string buffer = " "; // 'allocate' 30 blank characters GetString( buffer, StringLen(buffer) ); At first I have thought that the null character is not handled very well by MQL and modified the c++ code like this ... Code:
CopyMemory( buffer, ReadStringFromASource, min(BufferSize,ReadStringFromASourceLength) ); But when called from MQL, no string at all is returning. Has someone an answer ? Last edited by gorgoroth; 08-08-2008 at 11:28 AM. |
|
||||
|
Quote:
bool TradeHour=false; if(Hour()>=12 || Hour()<17) TradeHour=true but the OR line won't work because if Hour happens to be 22 then it satisfies the first part "if(Hour()>=12" and Still trades whenever it wants and I did add && TradeHour to by Buy/Sell statements. The second example I gave should to the trick, I don't get it ![]() |
|
|||
|
Quote:
Code:
bool TradingEnabled=false; // Global variable
...
...
TradingEnabled=false; // Reset every tic run
if(Hour()>=12 && Hour()<17)
TradingEnabled=true;
...
...
if( TradingEnabled )
{
// Trading logic here
}
...
...
|
![]() |
| Bookmarks |
| Tags |
| candle time, CHinGsMAroonCLK, coders guru, expert advisor, forex, how to code, I_XO_A_H, mechanical trading, trading |
| Thread Tools | |
| Display Modes | |
|
|
LinkBacks (?)
LinkBack to this Thread: http://www.forex-tsd.com/metatrader-programming/554-how-code.html
|
||||
| Posted By | For | Type | Date | |
| Need an experienced programmer? - Page 2 | Post #0 | Refback | 09-24-2008 07:24 AM | |
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to code this? | iscuba11 | Metatrader 4 mql 4 - Development course | 1 | 08-03-2007 05:22 PM |