
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
How can I test from the code if the connection to the broker is on or off?
You can use the IsConnected() function for that, but ...
That function will never be reached if there are no new ticks coming in.
So, you have to keep it in either an endless loop (which is unacceptable for an EA) or you have to use timer events to check that (in which case, if it is an EA, it could warn you that there is no connection. I assume that we all consider indicators as less connection critical - no operations with orders and so on - so the timer solution can be applied to indicators too, but are probably less important to check from there than from EA) . Otherwise your code will not know that the connection has been lost
You can use the IsConnected() function for that, but ...
That function will never be reached if there are no new ticks coming in.
So, you have to keep it in either an endless loop (which is unacceptable for an EA) or you have to use timer events to check that (in which case, if it is an EA, it could warn you that there is no connection. I assume that we all consider indicators as less connection critical - no operations with orders and so on - so the timer solution can be applied to indicators too, but are probably less important to check from there than from EA) . Otherwise your code will not know that the connection has been lostcan you post some code example that would do that, please?
can you post some code example that would do that, please?
Will post an example tomorrow. OK?
Will post an example tomorrow. OK?
OK. Lets take some rest
can you post some code example that would do that, please?
apprentice coder
Here is a simple indicator (but the way how it is used, you can do it exactly the same in the EA) that checks the broker connection status at a desired time interval : _check_connection.mq4
extern int CheckStatusEveryNMilliseconds = 250;
int init() { EventSetMillisecondTimer(CheckStatusEveryNMilliseconds); return(0); }
int deinit() { EventKillTimer(); return(0); }
int start() { return(0); }
void OnTimer()
{
static bool previouslyConnected = true;
bool currentlyConnected = IsConnected();
if (previouslyConnected != currentlyConnected)
{
previouslyConnected = currentlyConnected;
string cdescription = "disconnected"; if (currentlyConnected) cdescription = "connected";
Comment("connection status changed.\nterminal is now : "+cdescription);
}
As you can see, it is a simple example how it can be done
apprentice coder
Here is a simple indicator (but the way how it is used, you can do it exactly the same in the EA) that checks the broker connection status at a desired time interval : _check_connection.mq4
extern int CheckStatusEveryNMilliseconds = 250;
int init() { EventSetMillisecondTimer(CheckStatusEveryNMilliseconds); return(0); }
int deinit() { EventKillTimer(); return(0); }
int start() { return(0); }
void OnTimer()
{
static bool previouslyConnected = true;
bool currentlyConnected = IsConnected();
if (previouslyConnected != currentlyConnected)
{
previouslyConnected = currentlyConnected;
string cdescription = "disconnected"; if (currentlyConnected) cdescription = "connected";
Comment("connection status changed.\nterminal is now : "+cdescription);
}
thanks :0
I see it work even today (without ticks). interesting. learning, learning
Change the name of either the fxpreislevelsv5.ex4 or fxpreislevelsv5.dll (metatrader does not recognize extensions in this case - you have to have different name of the file regardless of the extension)
Thanks for the help!!!
But i ran into a diffrent problem after compiling there were no errors but it doesn't run and keeps on removing
"2014.09.20 19:56:40.262 Custom indicator Trend_Imperator_V2e GBPUSDe,M5: removed
2014.09.20 19:56:38.901 Custom indicator Trend_Imperator_V2e GBPUSDe,M5: loaded successfully"
always happens do i have to update codes?
Thanks for the help!!!
But i ran into a diffrent problem after compiling there were no errors but it doesn't run and keeps on removing
"2014.09.20 19:56:40.262 Custom indicator Trend_Imperator_V2e GBPUSDe,M5: removed
2014.09.20 19:56:38.901 Custom indicator Trend_Imperator_V2e GBPUSDe,M5: loaded successfully"
always happens do i have to update codes?forexeaexpert
That error usually happens when the indicator is called with wrong parameters
Check the parameters in the iCustom() call to that indicator
Hello mladen ,
I was trying to insert this indicator to my ea .
But after testing it was only getting a buy signal .
Please help me to see is that a right code i insert
And i know macd>0 and macd<0 is the signal crossing zero line .
But how can i get another signal from the slope direction ?
I was very confuse , after trying so many time
Hello mladen ,
I was trying to insert this indicator to my ea .
But after testing it was only getting a buy signal .
Please help me to see is that a right code i insert
And i know macd>0 and macd<0 is the signal crossing zero line .
But how can i get another signal from the slope direction ?
I was very confuse , after trying so many timestevenpun
For that it would be the easiest to add some "slope direction" buffer to that indicator or to use some other MACD that already has that slope solved in a buffer