va bene....
ecco il codice x metatrader:
//+------------------------------------------------------------------+
//| Tiz SoloBB.mq4 |
//| |
//| |
//+------------------------------------------------------------------+
#property copyright ""
#property link ""
#property indicator_chart_window
#property indicator_buffers 2
bool Log = false;
//---- buffers
double SoloSU[];
double SoloGIU[];
//---- input parameters
extern int MPrd=34;
//#include <TizFunction.mqh>
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 2, Red);
SetIndexBuffer(0, SoloSU);
SetIndexStyle(1, DRAW_LINE, STYLE_SOLID, 2, Chartreuse);
SetIndexBuffer(1, SoloGIU);
//---- name for DataWindow and indicator subwindow label
string short_name = "SoloBB";
IndicatorShortName(short_name);
SetIndexLabel(0, "SoloSU");
SetIndexLabel(1, "SoloGIU");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
int limit = 0;
string sS;
double max = 0, min = 0, mov = 0, bsu = 0, bgiu = 0;
//----
if(counted_bars>0) counted_bars--;
//limit = Bars - counted_bars -1 - MPrd;
//limit = Bars - counted_bars;
limit = Bars - 1 - MPrd;
for (int i=limit; i >= 0; i--)
{
max = High[ArrayMaximum(High, 30, i)];
min = Low[ArrayMinimum(Low, 30, i)];
mov = iMA(Symbol(), Period(), 3, 0, MODE_SMA, PRICE_CLOSE, i);
// (il massimo degli ultimi 30gg - chiusura attuale) + la media * massimo / chiusura attuale;
// in pratica la differenza con il max degli ultimi 30 giorni corretto con l'aggiunta di....
//
bsu = ( max - Close ) + ( mov * max) / Close;
bgiu = ( min - Close ) + ( mov * min) / Close;
SoloSU = bsu;
SoloGIU = bgiu;
//if (Log)
//{ sS = "i="+i+" bsu = "+bsu+" bgiu="+bgiu;
// HTMLRiga("TraceSoloBB", sS, false);
//}
}
//----
return(0);
}
//+------------------------------------------------------------------+