The_Investor: Any help would be appreciated.
|
|
//+------------------------------------------------------------------+ //| Start.mq4 | //| Copyright © 2004, MetaQuotes Software Corp. | //| http://www.metaquotes.net/ | //+------------------------------------------------------------------+ #property copyright "Copyright © 2004, MetaQuotes Software Corp." #property link "http://www.metaquotes.net/" #property indicator_separate_window #property indicator_buffers 1 #property indicator_color1 Red #property indicator_width1 2 //---- indicator buffers double ExtMapBuffer[]; //---- int ExtCountedBars=0; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- drawing settings SetIndexStyle(0,DRAW_LINE); IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)); IndicatorShortName(Bars); SetIndexDrawBegin(0,0); //---- indicator buffers mapping SetIndexBuffer(0,ExtMapBuffer); //---- initialization done return(0); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int start() { sma(); return(0); } void sma() { int pos=1000; while(pos>=0) { ExtMapBuffer[pos]=iClose(Symbol(),0,pos); pos--; } }
To clarify a little. This essentially shows a 1 period moving average, back 1000 bars. Now the issue, on the start bar (1000) it's taking the calculation as the start for the value on the indicator. I'm trying to figure out how to have the initial bar have a value of 0, as opposed to the calculated value, then bars 999->0 be calculated value of iClose(Symbol(),0,pos). Bar1000 = 0; Bar999 = Bar1000+Calculated; Bar998 = Bar 999+Calculated; etc.
void sma() { int pos=1000; ExtMapBuffer[pos]=0); pos--; while(pos>=0) { ExtMapBuffer[pos]=iClose(Symbol(),0,pos); pos--; } }
.
Exactly what I needed, thanks GumRai!
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Trying to get a buffer to start from 0, as opposed to the calculated amount. Below is a simplistic example where the initial value (1000) will reflect the close of the current symbol. I'm trying to get it to start from 0 and show the movement from that point on. Any help would be appreciated. Thanks
int k=1000;
while (k>=0)
{
ExtMapBuffer[k]=iClose(Symbol(),0,k);
k--;
}