Hi,
I am porting my EA from MQL4 to MQL5. In that I am using iCustom() function. It returns a very different data. The output is
2013.07.01 13:23:48 test (EURUSD,H1) Sell = 4035.0
2013.07.01 13:23:48 test (EURUSD,H1) Buy = 4034.0
It is supposed to be 0 and 1 to 1.9. Cuz it is been used in EURUSD. Please help with this. Thanks in Advance.
Please read the documentation for the functions you are using, do not assume they work as they do in mql4, most do not . . . iCustom() "The function returns the handle of a specified custom indicator."
Please, don't multiply the topics on the same issue. You already received the answers to this issue.
/////////////Global///////////// double preBuy = 0; double preSell = 0; double Sell_Signal[]; double Buy_Signal[]; ////////////////Inside OnTick()/////////////// if(WithIndicator) { int Stoc_Handler = iCustom(_Symbol,PERIOD_H1,"Examples\\BFS_Stoc"); int iBuy = CopyBuffer(Stoc_Handler,1,1,1,Buy_Signal); int iSell = CopyBuffer(Stoc_Handler,0,1,1,Sell_Signal); if(Buy_Signal[0] != Sell_Signal[0] && (Buy_Signal[0] != preBuy || Sell_Signal[0] != preSell)) { Print("Buy = ", Buy_Signal[0]); preBuy = Buy_Signal[0]; Print("Sell = ", Sell_Signal[0]); preSell = Sell_Signal[0]; } sIndi = "Indicator,"; }
Sorry for multiplying posts. I have a doubt in iCustom again. Please have a look in the code given below.
~~~~~~~~~~~~~~~~Second Signal~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2013.07.02 18:59:03 2013.01.02 12:00:00 Sell = 1.3278175
2013.07.02 18:59:03 2013.01.02 12:00:00 Buy = 0.0
~~~~~~~~~~~~~~~~~First Signal~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2013.07.02 18:58:50 2013.01.02 07:00:00 Sell = 9.881312916824931e-324
2013.07.02 18:58:50 2013.01.02 07:00:00 Buy = 0.0
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I get the above output. There is no first signal. But I get some garbage value when I start the tester. Tell me whats wrong with this code.
~~~~~~~~~~~~~~~~Second Signal~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2013.07.02 18:59:03 2013.01.02 12:00:00 Sell = 1.3278175
2013.07.02 18:59:03 2013.01.02 12:00:00 Buy = 0.0
~~~~~~~~~~~~~~~~~First Signal~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2013.07.02 18:58:50 2013.01.02 07:00:00 Sell = 9.881312916824931e-324
2013.07.02 18:58:50 2013.01.02 07:00:00 Buy = 0.0
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I get the above output. There is no first signal. But I get some garbage value when I start the tester. Tell me whats wrong with this code.
You probably have to use something like :
if((Buy_Signal[0] != EMPTY_VALUE && Buy_Signal[0] != preBuy) || (Sell_Signal[0] != EMPTY_VALUE && Sell_Signal[0] != preSell))
The value printed show maybe an empty value for the Sell buffer of your indicator. Not sure as this is value is weird (by default EMPTY_VALUE = DBL_MAX). If that doesn't work the issue is probably in your indicator.
Then try to check the returned value of CopyBuffer :
Sorry to disturb you. Again same issue. Even after adding "if (iBuy==1 && iSell==1 ...."
Sorry for multiplying posts. I have a doubt in iCustom again. Please have a look in the code given below.
~~~~~~~~~~~~~~~~Second Signal~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2013.07.02 18:59:03 2013.01.02 12:00:00 Sell = 1.3278175
2013.07.02 18:59:03 2013.01.02 12:00:00 Buy = 0.0
~~~~~~~~~~~~~~~~~First Signal~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2013.07.02 18:58:50 2013.01.02 07:00:00 Sell = 9.881312916824931e-324
2013.07.02 18:58:50 2013.01.02 07:00:00 Buy = 0.0
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I get the above output. There is no first signal. But I get some garbage value when I start the tester. Tell me whats wrong with this code.
Don't you need to resize your array and set it as a series array ? you are writing an EA not an Indicator, there are no buffers in EAs, you have to look after the arrays yourself.
In theory yes, but here he is only read 1 value so that doesn't make a difference.
Sorry to disturb you. Again same issue. Even after adding "if (iBuy==1 && iSell==1 ...."
In theory yes, but here he is only read 1 value so that doesn't make a difference.
I don't understand your problem, I can try to help you if you can provide the indicator's code.- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
I am porting my EA from MQL4 to MQL5. In that I am using iCustom() function. It returns a very different data. The output is
2013.07.01 13:23:48 test (EURUSD,H1) Sell = 4035.0
2013.07.01 13:23:48 test (EURUSD,H1) Buy = 4034.0
It is supposed to be 0 and 1 to 1.9. Cuz it is been used in EURUSD. Please help with this. Thanks in Advance.