Calling .ex4 custom indicator into EA.

 

Hello Guys,

I am Back. Yes Back because I was 'Banned' from this Forum! I didn't get any warning about it though and it was my ignorance about the matter. I apologize for it and understood what I shouldn't had done.

Anyway, I am opening this thread with the hope of the solution as this is the Core of everything about Meta Trader.

I want to call a Custom indicator (in .ex4 format) into an EA. I have made a speculation about it. Please correct my mistakes.


I have opened the 'Data Window' by pressing Ctrl+D. There I got three parameters: Y,G and R.

While I hover the mouse over the bars I notice change in the value of these parameters. But the change happens when the indicator changes it's color.

When the indicator goes from Gray to Blue Y becomes 1.0000 to 0.0000 and G becomes 0.0000 to 1.0000 and vice versa for Blue to Gray changing. The value of R never changes.

In spite of it I guessed this indicator has 3 buffers. So for any 'Current Bar' I wrote the iCustom() function for the buffers as below:

iCustom(Symbol(),Timefram e,"CUSOMT INDI NAME",all parameters separated by coma, 0, 0);
iCustom(Symbol(),Timefram e,"CUSOMT INDI NAME",all parameters separated by coma, 1, 0);

iCustom(Symbol(),Timefram e,"CUSOMT INDI NAME",all parameters separated by coma, 2, 0);


Till this, what mistakes I have made? Please correct me. I want to approach step by step.


Regards

 
Arav007:

Hello Guys,

I am Back. Yes Back because I was 'Banned' from this Forum! I didn't get any warning about it though and it was my ignorance about the matter. I apologize for it and understood what I shouldn't had done.

You have a thread about this already . . . if you persist with this subject I will BAN this User ID too.

RaptorUK:
You seem fixed on using stolen property, so I am BANNING you.

 
RaptorUK:

You have a thread about this already . . . if you persist with this subject I will BAN this User ID too.


Sorry I had to start this thread but I had no other way as you have Banned me. So I was unable to continue with that thread.

Also this thread is about something else. Previously I was trying to know the code of that indicator but now I am trying to use that indicator without knowing it's code. I hope this is not violation of anything.

 

Hello,

I have tried to build a simple EA but the EA is not opening any trade! I am not understanding what wrong I did. What link up I have missed hence the program is not running at all or I have failed to call the .ex4 files by Custom()? Please Help.

I have used Two indicators here:


FIM and MoneyFlowIndex.


My observations about these 2 indicators are:

When 1st Indicator goes from Gray to Blue, it's 'Buffer 1' [Here G] goes 0 to 1.
When 2nd indicator goes from Red to Blue, it's 'Buffer 1' [Here G] goes 0 to 1.

When 1st Indicator goes from Blue to Gray, it's 'Buffer 0' [Here Y] goes 1 to 0.
When 2nd indicator goes from Blue to Red, it's 'Buffer 2' [Here R] goes 1 to 0.

My conditions for opening trade are:

When G(1st) and G(2nd) become 1, EA will open a Buy order.
When Y(1st) and R(2nd) become 0, EA will open a Sell order.

My Code:

#property copyright "N"
#property link ""

//--- input parameters
extern double LotSize=0.01;
extern double Stoploss=30.0;
extern double TakeProfit=10.0;
extern int Slippage=5;
extern int MagicNumber=786;
extern bool EarlySignal=true;
extern bool M3_Coral_Filter=true;
int BuyOrder;
int SellOrder;

//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
return(0);
}

//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
double Y1, Y2, Y3, Y4;
int SL, TP;
SL=Bid- New_Stop(Stoploss)*Point;
TP=Bid+New_Stop(TakeProfit)*Point;
{
Y1 = iCustom(NULL,0,"FIM",EarlySignal,M3_Coral_Filter,1,0);
Y2 = iCustom(NULL,0,"MoneyFlowIndex",EarlySignal,M3_Coral_Filter,1,0);
Y3 = iCustom(NULL,0,"FIM",EarlySignal,M3_Coral_Filter,0,0);
Y4 = iCustom(NULL,0,"MoneyFlowIndex",EarlySignal,M3_Coral_Filter,2,0);
}
if (Y1==1 && Y2==1)
{
BuyOrder=OrderSend(Symbol(), OP_BUY, LotSize,Ask,5,SL,TP,"Buy Order",MagicNumber, 0,Blue);

}

if (Y3==0 && Y4==0)
{
SellOrder=OrderSend(Symbol(), OP_SELL, LotSize,Bid,5,SL,TP,"Sell Order",MagicNumber, 0,Red);

}

return(0);
}
int New_Stop(int Warning) 
{
int Min_Dist=MarketInfo(Symbol(),MODE_STOPLEVEL);

if (Warning > Min_Dist) 
{
Warning=Min_Dist; 
Alert("Stop level increased.");
}
return(Warning); 
}
Files:
fim.ex4  18 kb
 

  1. Play video
    Please edit your post.
    For large amounts of code, attach it.

  2. Find out if you are even calling OrderSend and/or why they are failing. What are Function return values ? How do I use them ? - MQL4 forum
 

Yes,

I am getting the Error message in Expert tab.

'Order send failed, error#'

Now how can I detect why it is failing?

Thanks

*Update:

It opened an Order just now at Gold. But just one. Other time showing the same error.

It opened another Buy order in Gold yet showing the failing message for Gold too!

 
Arav007:

Yes,

I am getting the Error message in Expert tab.

'Order send failed, error#'

Now how can I detect why it is failing?

Thanks

*Update:

It opened an Order just now at Gold. But just one. Other time showing the same error.

It opened another Buy order in Gold yet showing the failing message for Gold too!


WHRoeder has given the link

What are Function return values ? How do I use them ? - MQL4 forum

is this not answering your question ??

 
deVries:


WHRoeder has given the link

What are Function return values ? How do I use them ? - MQL4 forum

is this not answering your question ??

There I got the idea how to check whether the function is working correctly or not but I haven't found how to detect the reason there I mean detailed process.

Wait I have found that the errors are showing in Journal tab too. Pardon me for my ignorance.

It opens log files of those errors. Now I am trying to figure out the errors reading log files.

 
No one can tell me about the mistakes here pls?
Reason: