1 Answer
<p id="isPasted">In most cases you can create a custom function within an EA that replicates an indicator by using buffers. I have done this numerous times for clients as it makes the EA a more robust solution when not relying on external indicators.</p><p><br></p><p>Example code:</p><p>//+------------------------------------------------------------------+</p><p>double customIndicator(int IDX, int timeFrame)</p><p>//+------------------------------------------------------------------+</p><p>{</p><p> double Buffer[1];</p><p> int buffersize=iBars(Symbol(), timeFrame);</p><p> ArrayResize(Buffer, buffersize);</p><p> ArraySetAsSeries(Buffer, true);</p><p><br></p><p> int pos=buffersize-1;</p><p> while(pos>=0)</p><p> {</p><p> // Indicator calculations</p><p> Buffer[pos]=...</p><p> pos--;</p><p> }</p><p><br></p><p>return(buffer[IDX]);</p><p>}</p>