J'ai essaye d'encoder a partir d'un indicateur de croisement de MM mais c'est un echec...
Voila ce que j'ai fait:
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 SeaGreen
double CrossUp[];
double CrossDown[];
double Price;
extern int EMA = 200;
extern bool SoundON=true;
double alertTag;
double control=2147483647;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0, DRAW_ARROW, EMPTY,3);
SetIndexArrow(0, 233);
SetIndexBuffer(0, CrossUp);
SetIndexStyle(1, DRAW_ARROW, EMPTY,3);
SetIndexArrow(1, 234);
SetIndexBuffer(1, CrossDown);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start() {
int limit, i, counter;
double Pricenow, EMAnow, Priceprevious, EMAprevious, Priceafter, EMAafter;
double Range, AvgRange;
int counted_bars=IndicatorCounted();
//---- check for possible errors
if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
for(i = 0; i <= limit; i++) {
counter=i;
Range=0;
AvgRange=0;
for (counter=i ;counter<=i+9;counter++)
{
AvgRange=AvgRange+MathAbs(High[counter]-Low[counter]);
}
Range=AvgRange/10;
EMAnow = iMA(NULL, 0, EMA, 0, MODE_EMA, PRICE_CLOSE, i);
EMAprevious = iMA(NULL, 0, EMA, 0, MODE_EMA, PRICE_CLOSE, i+1);
EMAafter = iMA(NULL, 0, EMA, 0, MODE_EMA, PRICE_CLOSE, i-1);
Pricenow = iMA(NULL, 0, Price, 0, MODE_CLOSE, PRICE_CLOSE, i);
Priceprevious = iMA(NULL, 0, Price, 0, MODE_CLOSE, PRICE_CLOSE, i+1);
Priceafter = iMA(NULL, 0, Price, 0, MODE_CLOSE, PRICE_CLOSE, i-1);
if ((Pricenow > EMAnow) && (EMAprevious < Priceprevious) && (EMAafter > Priceafter)) {
CrossUp
= Low - Range*0.5;
}
else if ((EMAnow < Pricenow) && (EMAprevious > Priceprevious) && (EMAafter < Priceafter)) {
CrossDown = High + Range*0.5;
}
if (SoundON==true && i==1 && CrossUp > CrossDown && alertTag!=Time[0]){
Alert("EMA Cross Trend going Down on ",Symbol()," ",Period());
alertTag = Time[0];
}
if (SoundON==true && i==1 && CrossUp < CrossDown && alertTag!=Time[0]){
Alert("EMA Cross Trend going Up on ",Symbol()," ",Period());
alertTag = Time[0];
}
}
return(0);
}
Je pense que les erreurs ce situent aux niveau de la definition du prix et aussi au tout debut pour les para de variables. Mais bon j'ai tout le week-end pour ca il faut que ca marche je vais y arriver
