Some technical indicators have several buffers drawn in the chart. Numbering of indicator buffers starts with 0. When copying indicator values using the CopyBuffer() function into an array of the double type, for some indicators one may indicate the identifier of a copied buffer instead of its number.
There are no objects when using the 'DRAW_ARROW' style. There is only an indicator buffer.
Work with the indicator buffer - using 'CopyBuffer' receive data from the indicator buffer and check the received value.
Also I recommend: first write a simple indicator based on the 'DRAW_ARROW' style. Then the advisor.
I updated my code to check the CopyBuffer() value, but the value always equal to the CopyBuffer() count parameter. For example in the updated code below, the count is 123 and the CopyBuffer() value is also 123 regardless of the timeframe.
double MA[];
int MA_handle;
//+------------------------------------------------------------------+//| Expert initialization function |//+------------------------------------------------------------------+intOnInit()
{
MA_handle=iCustom(NULL,PERIOD_M15,"MyTrendIndicator");
return(0);
}
//+------------------------------------------------------------------+//| Expert tick function |//+------------------------------------------------------------------+voidOnTick()
{
ArraySetAsSeries(MA,true);
int cBufValue = CopyBuffer(MA_handle,0,0,123,MA);
Print( "buffer value for M15 is: "+cBufValue);
}
I updated my code to check the CopyBuffer() value, but the value always equal to the CopyBuffer() count parameter. For example in the updated code below, the count is 123 and the CopyBuffer() value is also 123 regardless of the timeframe.
Counting of elements of copied data (indicator buffer with the index buffer_num) from the starting position is performed from the present to the past, i.e., starting position of 0 means the current bar (indicator value for the current bar). When copying the yet unknown amount of data, it is recommended to use a dynamic array as a buffer[]...
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Okay. Please how do I access the arrow objects in an EA?
Use CopyBuffer - just indicate the indicator buffer number (the indication of buffers starts from '0').
Use CopyBuffer - just indicate the indicator buffer number (the indication of buffers starts from '0').
I did that, please see code below. But that gives me MA values. How will I use the CopyBuffer for objects?
I did that, please see code below. But that gives me MA values. How will I use the CopyBuffer for objects?
There are no objects when using the 'DRAW_ARROW' style. There is only an indicator buffer.
Work with the indicator buffer - using 'CopyBuffer' receive data from the indicator buffer and check the received value.
Also I recommend: first write a simple indicator based on the 'DRAW_ARROW' style. Then the advisor.
There are no objects when using the 'DRAW_ARROW' style. There is only an indicator buffer.
Work with the indicator buffer - using 'CopyBuffer' receive data from the indicator buffer and check the received value.
Also I recommend: first write a simple indicator based on the 'DRAW_ARROW' style. Then the advisor.
I updated my code to check the CopyBuffer() value, but the value always equal to the CopyBuffer() count parameter. For example in the updated code below, the count is 123 and the CopyBuffer() value is also 123 regardless of the timeframe.
I updated my code to check the CopyBuffer() value, but the value always equal to the CopyBuffer() count parameter. For example in the updated code below, the count is 123 and the CopyBuffer() value is also 123 regardless of the timeframe.
Please read the help carefully: CopyBuffer
Return Value
Returns the copied data count or -1 in case of an error.
CopyBuffer copies data INTO ARRAY. Now you need to print any value from the array (for example, the value MA [0])