- Please use the link button (control-K.)
See the difference: https://www.mql5.com/en/code/1768
- Don't post a link to or attach a image, insert the image
- For small amounts of code just paste it
Play videoPlease edit your post.
For large amounts of code, attach it.int start(){
double openn, stopp;
openn = iCustom(NULL, 0, "pinbar",0, 1);
stopp = iCustom(NULL, 0, "pinbar",1, 1);
Print("This is the Opeh ", openn);
Print("This is the Stop ", stopp); - Your image shows the values from iCustom is the MQ4 constant
But your link is a MT5 indicator so it can't produce the value in your image.EMPTY_VALUE
Empty value in an indicator buffer. Default custom indicator empty value
2147483647 (0x7FFFFFFF)
- The data window shows you have the mouse over bar 10.25 16:00 but your iCustom/Print shows only bar zero (10.28 20:00) values, so of course they don't match. and since bar zero is not a pin bar, you expect no arrow, you expect EMPTY_VALUE.
- votes: 24
- 2013.07.31
- Andrey Shpilev
- www.mql5.com
- Please use the link button (control-K.)
See the difference: https://www.mql5.com/en/code/1768
- Don't post a link to or attach a image, insert the image
- For small amounts of code just paste it
Please edit your post.
For large amounts of code, attach it.int start(){
double openn, stopp;
openn = iCustom(NULL, 0, "pinbar",0, 1);
stopp = iCustom(NULL, 0, "pinbar",1, 1);
Print("This is the Opeh ", openn);
Print("This is the Stop ", stopp); - Your image shows the values from iCustom is the MQ4 constant
But your link is a MT5 indicator so it can't produce the value in your image.EMPTY_VALUE
Empty value in an indicator buffer. Default custom indicator empty value
2147483647 (0x7FFFFFFF)
- The data window shows you have the mouse over bar 10.25 16:00 but your iCustom/Print shows only bar zero (10.28 20:00) values, so of course they don't match. and since bar zero is not a pin bar, you expect no arrow, you expect EMPTY_VALUE.
Hi whroeder1
Thank you for your reply. I will use the methods specified in steps 1 - 3.
So in response to step 4 - > Does that mean I cannot obtain the value from the data window because it is a mt5 indicaor? (Although it is a mt5 indicator it is still working?)
Step 5 - > Notice the data window shows the bar corresponding to 10.25 16:00 has a green x (buffer 0) and a red x (buffer 1) plotted by the indicator. The values shown in the data window are not shown in the journal where I have highlighted the values shown. It is the default value for 'EMPTY_VALUE' but at that bar the buffers are not empty clearly (data window). Is this because MT5 indicators are not compatible with MT4? If so why does it work on MT4? Also how can I obtain what I am after (can I convert the code to MT4 somehow).
Thank You kindly for your response
So in response to step 4 - > Does that mean I cannot obtain the value from the data window because it is a mt5 indicaor? (Although it is a mt5 indicator it is still working?)
Step 5 - > Notice the data window shows the bar corresponding to 10.25 16:00 has a green x (buffer 0) and a red x (buffer 1) plotted by the indicator. The values shown in the data window are not shown
- You are not running the MQL5 indicator, that does not use that value as empty. Your link is wrong. You are running a MQL4 indicator.
- What do you mean not shown?
- You are printing out bar zero at the beginning of the bar. Therefor no bar will be printed as a pin bar.
- You are not running the MQL5 indicator, that does not use that value as empty. Your link is wrong. You are running a MQL4 indicator.
- What do you mean not shown?
- You are printing out bar zero at the beginning of the bar. Therefor no bar will be printed as a pin bar.
Hi
Sorry I think I have not explained my problem properly.
Ok, let's use the values shown in the Data window how would I for example place an order to buy on the following candle when/if the price reaches "OpenBuffer = 1.2217"?
It'll be something like this right?
{
double openn, stopp;
openn = iCustom(NULL, 0, "pinbar",0, 1);
stopp = iCustom(NULL, 0, "pinbar",1, 1);
int total, ticket;
// expire = TimeCurrent()+(60*60*12); //expire after 12 hours
total = OrdersTotal();
if(total<1)
{
if ((openn != EMPTY_VALUE && stopp != EMPTY_VALUE) && (openn > stopp))
{
ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, 3, stopp, Ask+(profits*Point), "EA",11111,0,Green);
if (ticket>0)
{
if(OrderSelect(ticket, SELECT_BY_TICKET, MODE_TRADES))
Print("BUY order opened: ",OrderOpenPrice());
}
else
Print("Error opening BUY order: ",GetLastError());
return(0);
}
if ((openn != EMPTY_VALUE && stopp != EMPTY_VALUE) && (openn < stopp))
{
ticket = OrderSend(Symbol(), OP_SELL, Lots, Bid, 3, stopp, Bid-(profits*Point), "EA",11111,0,Red);
if (ticket>0)
{
if(OrderSelect(ticket, SELECT_BY_TICKET, MODE_TRADES))
Print("SELL order opened: ",OrderOpenPrice());
}
else
Print("Error opening SELL order: ",GetLastError());
return(0);
}
return(0);
}
//+----------
return(0);
}
The EA dose not place any orders as 'openn and stopp = EMPTY_VALUES' only and not the values in the data window?
Kind Regards
openn = iCustom(NULL, 0, "pinbar",0, 1);
stopp = iCustom(NULL, 0, "pinbar",1, 1);
I haven't checked for a while, but I believe that you have to include the indicator parameters with iCustom. I know that the documentation states that the default input parameters will be used if they are not specified, but I have not found this to be the case.
Try it including the parameters.
- OPs original problem was looking at bar zero on the first tick.
- I'm not sure either, but I always recommend write a self documenting function instead of calling iCustom
directly, see
Detailed explanation of iCustom -
MQL4 forum
- ...
- I'm not sure either, but I always recommend write a self documenting function instead of calling iCustom
directly, see
Detailed explanation of iCustom -
MQL4 forum
Keith Watford:
...
I know that the documentation states that the default input parameters will be used if they are not specified, but I have not found this to be the case.
openn = iCustom(NULL, 0, "pinbar",0, 1);
stopp = iCustom(NULL, 0, "pinbar",1, 1);
I haven't checked for a while, but I believe that you have to include the indicator parameters with iCustom. I know that the documentation states that the default input parameters will be used if they are not specified, but I have not found this to be the case.
Try it including the parameters.
Hi Keith and Whroeder1
Thank You for your advice unfortunately it didn't work. I changed the code to the following but it still cannot read the buffer values for the pinbars. Any further advice?
int start()
{
#define Pinbar "pinbar"
#define Openn 0
#define Stopp 1
int MinBarSize=200;
int PriceOffset=50;
double BarRatio=2.2;
double TailRatio=1.3;
#define UseBodyDirection false
#define UseCloseThirds true
int ExtremumOfBars=10;
double OpenBuff, StopBuff;
OpenBuff = iCustom(NULL, 0, Pinbar, MinBarSize, PriceOffset, BarRatio, TailRatio, UseBodyDirection, UseCloseThirds,ExtremumOfBars, Openn, 1);
StopBuff = iCustom(NULL, 0, Pinbar, MinBarSize, PriceOffset, BarRatio, TailRatio, UseBodyDirection, UseCloseThirds,ExtremumOfBars, Stopp, 1);
Print("This is the Open ", OpenBuff);
Print("This is the Stop ", StopBuff);
//+----------
return(0);
}
- 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'm new to programming in mql4 so apologize in advance if I offend anyone with my questions.
My issue is I am trying to use a custom indicator (Pinbar - https://www.mql5.com/en/code/1768) in a EA using the "iCustom" function. For some reason the values shown in Data Window for the buffers used in 'pinbar' indicator does not match the values obtained in the EA. I have attached the screenshot and the EA file I used to test the buffers (it is very basic).
I would greatly appreciate any assistance or solutions for this issue. I have searched online but unfortunately have not found any solutions.
Thank You
P.s. I did not attach the 'pinbar' file as it is not mine but it can easily be downloaded from the link above from its rightful owner.