Trovata in rete, prova a vedere.
//+------------------------------------------------------------------+
//| Velocità New.mq4 |
//| Copyright © 2004, MetaQuotes Software Corp. |
//|
MetaTrader 4 Trading Platform / MetaQuotes Software Corp. |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net/"
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Blue
//---- input parameters
extern int MomPeriod=64;
//---- buffers
double Velo1[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string short_name;
//---- indicator line
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,Velo1);
//---- name for DataWindow and indicator subwindow label
short_name="Velo New("+MomPeriod+")";
IndicatorShortName(short_name);
SetIndexLabel(0,short_name);
//----
SetIndexDrawBegin(0,MomPeriod);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Velocità |
//+------------------------------------------------------------------+
int start()
{
int i,counted_bars=IndicatorCounted();
//----
if(Bars<=MomPeriod) return(0);
//---- initial zero
if(counted_bars<1)
for(i=1;i<=MomPeriod;i++) Velo1[Bars-i]=0.0;
//----
i=Bars-MomPeriod-1;
if(counted_bars>=MomPeriod) i=Bars-counted_bars-1;
while(i>=0)
{
Velo1
=(Close-iMA(NULL,0,MomPeriod,0,MODE_SMA,PRICE_CLOSE,i))-(Close[i+MomPeriod]-iMA(NULL,0,MomPeriod,0,MODE_SMA,PRICE_CLOSE,i+MomPeriod));
i--;
}
return(0);
}
//+------------------------------------------------------------------+