Bonjour
Je decouvre la prog mt4. J ai realisé un petit indic qui ne me donne pas satisfaction. Le code est en fin de post.
Je souhaite obtenir le truc suivant sur un TF1H, à l ouverture d une bougie, sauvegarder toutes les infos relatives aux prix de la bougie precedente plus l open de la bougie actuelle dans un fichier qui reprend la date et l heure de sauvegarde.txt de la bougie close. donc un fichier different à chaque open et une seule fois à l ouverture.
Je souhaite aussi mettre une alerte sonore quand la sauvegarde s effectue.
Pourriez vous donc m aider à corriger mon indic afin qu il reponde à mes besoins ?
Merci pour votre aide
Stéphane
Code:
//+------------------------------------------------------------------+
//| Alli_export_v3.mq4 |
//| Copyright © 2010, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2010, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Red
#property indicator_width1 1
#property indicator_color2 Green
#property indicator_width2 1
#property indicator_color3 Blue
#property indicator_width3 1
double Buffer[], Buffer_1[], Buffer_2[];
int HandleEtat = -1;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexStyle(1,DRAW_LINE);
SetIndexStyle(2,DRAW_LINE);
SetIndexBuffer(0,Buffer);
SetIndexBuffer(1,Buffer_1);
SetIndexBuffer(2,Buffer_2);
IndicatorShortName("Surl ecran");
SetIndexLabel(0,"tableau");
SetIndexLabel(1,"tableau_1");
SetIndexLabel(2,"tableau_2");
IndicatorDigits(Digits);
HandleEtat=FileOpen("mon_indic.txt", FILE_READ|FILE_WRITE|FILE_CSV, "/t");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
if (HandleEtat>1)
FileClose(HandleEtat);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int i,counted_bars=IndicatorCounted();
int limit, no_paire;
string Texte;
double in1 = 0;
//----
if(counted_bars < 0) return(-1);
if ( counted_bars > 0 ) limit=Bars-counted_bars;
if ( counted_bars ==0 )
{
for(i=1;i<2;i++)//limit
{
Texte=(TimeToStr(Time[i], TIME_DATE)+";"+TimeToStr(Time[i], TIME_MINUTES)+";"+Paire[no_paire]
+";"+DoubleToStr(iOpen("EURUSD",PERIOD_H1,i),4)
+";"+DoubleToStr(iLow("EURUSD",PERIOD_H1,i),4)
+";"+DoubleToStr(iHigh("EURUSD",PERIOD_H1,i),4)
+";"+DoubleToStr(iClose("EURUSD",PERIOD_H1,i),4));
if (FileWrite(HandleEtat, Texte) < 1)
{
Print("Erreur écriture : Code ", GetLastError());
return;
}
}// fin no_paire
Alert("Sauvegarde "+TimeToStr(Time[2], TIME_DATE)+";"+TimeToStr(Time[2], TIME_MINUTES)+".txt effectuée.");
PlaySound("alert.wav");
}//fin i
}
if (HandleEtat>1)
FileClose(HandleEtat);
//----
return(0);
}
//+------------------------------------------------------------------+