Bonjour à tous
Je ne m'en sort pas avec la gestion de tableaux !
J'ai lu la doc MQL4 mais rien n'y fait je n'arrive pas à transformer un indic en EA.
Je souhaite m'exercer en transformant l'indic MACD en EA.
L'EA ne prendrait pas de position pour l'instant mais afficherait via la fonction "comment" la valeur de macdbuffer[0], macdbuffer[1], SignalBuffer[0] et SignalBuffer[1]
Si quelqu'un peut m'aider se serait super cool car je galère depuis un bon moment.
Je pense que l'apprentissage par l'exemple est la seule solution pour que je comprenne enfin.
Si vous avez dèjà fait cette opération sur d'autres indic gérant des tableaux je suis preneur.
D'avance merci pour votre aide.
TAAD
Code:#property copyright "Copyright © 2004, MetaQuotes Software Corp." #property link "http://www.metaquotes.net/" //---- indicator settings #property indicator_separate_window #property indicator_buffers 2 #property indicator_color1 Silver #property indicator_color2 Red #property indicator_width1 2 //---- indicator parameters extern int FastEMA=12; extern int SlowEMA=26; extern int SignalSMA=9; //---- indicator buffers double MacdBuffer[]; double SignalBuffer[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- drawing settings SetIndexStyle(0,DRAW_HISTOGRAM); SetIndexStyle(1,DRAW_LINE); SetIndexDrawBegin(1,SignalSMA); IndicatorDigits(Digits+1); //---- indicator buffers mapping SetIndexBuffer(0,MacdBuffer); SetIndexBuffer(1,SignalBuffer); //---- name for DataWindow and indicator subwindow label IndicatorShortName("MACD("+FastEMA+","+SlowEMA+","+SignalSMA+")"); SetIndexLabel(0,"MACD"); SetIndexLabel(1,"Signal"); //---- initialization done return(0); } //+------------------------------------------------------------------+ //| Moving Averages Convergence/Divergence | //+------------------------------------------------------------------+ int start() { int limit; int counted_bars=IndicatorCounted(); //---- last counted bar will be recounted if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; //---- macd counted in the 1-st buffer for(int i=0; i<limit; i++) MacdBuffer[i]=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i)-iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i); //---- signal line counted in the 2-nd buffer for(i=0; i<limit; i++) SignalBuffer[i]=iMAOnArray(MacdBuffer,Bars,SignalSMA,0,MODE_SMA,i); //---- done return(0); } //+------------------------------------------------------------------+
![]() |
|


LinkBack URL
About LinkBacks

Répondre avec citation