What is Shift Parameter?

User avatar
remix919
Trader
Posts: 91
Joined: Wed Jan 23, 2013 2:42 am
Location: Some Road in the USA

Re: What is Shift Parameter?

Post by remix919 »

So...like this? :D

Code: Select all

//--- input parameters
extern int       shift=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    bars=IndicatorCounted();
//----
for (bar = limit-1; bar >= 0; bar--) {
ACbuffer[bar] = iAC(null, 0, bar);
ACbufferShift[bar] = iAC(null, 0, bar + shift);
}
//----
   return(0);
  }
//+------------------------------------------------------------------+
Don't bash too hard, i'm still new :roll:
EA's are the best way to trade. Why? Because they take the emotion out of trading.
garyfritz

Re: What is Shift Parameter?

Post by garyfritz »

That's the right direction, but you're missing some crucial pieces -- like declaring the buffer arrays, and making them indicator buffer by calling SetIndexBuffer().

I suggest you look at a simple indicator (like RSI.mql or ATR.mql) and see how it works, rather than guessing and asking. Go read http://book.mql4.com/samples/icustom, too.
User avatar
remix919
Trader
Posts: 91
Joined: Wed Jan 23, 2013 2:42 am
Location: Some Road in the USA

Re: What is Shift Parameter?

Post by remix919 »

Ok, thanks, I'll go read up on those in the MQL4 docs, btw, are the default indicators accessible? I can't seem to find them anywhere, I can only find the custom indicators.
EA's are the best way to trade. Why? Because they take the emotion out of trading.
garyfritz

Re: What is Shift Parameter?

Post by garyfritz »

Look under experts\indicators. You'll find the two I mentioned and several others.
Post Reply

Return to “Coders Hangout”