EA con medias movilesBuenas Tardes.
Queria ver si me pueden ayudar con un EA con cruce de medias moviles, que cuando se crucen abran a compra o venta segun corresponda, y cuando se vuelvan a cruzar, cierre la que tenia en ejecucion y abra la que corresponda. o bien, ayudarme a colocar en este codigo lo que se necesita para enviar las ordenes //+------------------------------------------------------------------+ //| 2EMAS Cross Alert.mq4 | //| by Ciclo | //| | //+------------------------------------------------------------------+ #property copyright "Ciclo" #property link "" #property indicator_chart_window #property indicator_buffers 2 #property indicator_color1 Orange #property indicator_color2 Orange #property indicator_width1 0 #property indicator_width2 0 //---- input parameters extern bool SoundON=true; extern bool EmailON=false; extern bool show_cross=true; extern int PeriodoMA1=9; extern int PeriodoMA2=18; extern int Shift1=0; extern int Shift2=0; extern string nota_Metodo="0=SMA,1=EMA,2=SMMA,3=LWMA"; extern int MetodoMA1=1; extern int MetodoMA2=1; extern string PrecioAplicado="0=Close,1=Open,2=High,3=Low"; extern string PrecioAplicado2="4=(H+L)/2,5=(H+L+C)/3"; extern int PrecioAplicadoMA1=0; extern int PrecioAplicadoMA2=0; double CrossUp[]; double CrossDown[]; int flagval1=0; int flagval2=0; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexStyle(0,DRAW_ARROW,EMPTY); SetIndexArrow(0,225); SetIndexBuffer(0,CrossUp); SetIndexStyle(1,DRAW_ARROW,EMPTY); SetIndexArrow(1,226); SetIndexBuffer(1,CrossDown); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int limit, i, counter; double tmp=0; double MA1now, MA1prev,MA2now, MA2prev,MA3now, MA3prev,MA4now, MA4prev; 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=1; i<=limit; i++) { counter=i; Range=0; AvgRange=0; for(counter=i ;counter<=i+5;counter++) { AvgRange=AvgRange+MathAbs(High[counter]-Low[counter]); } Range=AvgRange/5; MA1now=iMA(NULL,0,PeriodoMA1,Shift1,MetodoMA1,PrecioAplicadoMA1,i); MA1prev=iMA(NULL,0,PeriodoMA1,Shift1,MetodoMA1,PrecioAplicadoMA1,i+1); MA2now=iMA(NULL,0,PeriodoMA2,Shift2,MetodoMA2,PrecioAplicadoMA2,i); MA2prev=iMA(NULL,0,PeriodoMA2,Shift2,MetodoMA2,PrecioAplicadoMA2,i+1); CrossUp[i]=EMPTY_VALUE; CrossDown[i]=EMPTY_VALUE; //=== Condicion de cruce if (show_cross && MA1now > MA2now && MA1prev < MA2prev) { if (i==1 && flagval1==0) { flagval1=1;flagval2=0; if (SoundON) Alert(Symbol()," MAs Cross Up ",PeriodoMA1,"-",PeriodoMA2," en ",Period()," min. ","\n \n Ask=",Ask,", Bid=",Bid,"\n Fecha y hora:",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime())); if (EmailON) SendMail(Symbol()," MAs Cross Up "+PeriodoMA1+"-"+PeriodoMA2+" en "+Period()+" min. "+"Fecha y hora:"+TimeToStr(CurTime(),TIME_DATE)+" "+TimeHour(CurTime())+":"+TimeMinute(CurTime()) ); } CrossUp[i]=Low[i] - Range; // CrossUp[i] = AvgRange; CrossDown[i]=EMPTY_VALUE; } else if (show_cross && MA1now < MA2now && MA1prev > MA2prev) { if (i==1 && flagval2==0) { flagval2=1;flagval1=0; if (SoundON)Alert(Symbol()," MAs Cross Down ",PeriodoMA1,"-",PeriodoMA2," en ",Period()," min. ","\n \n Ask=",Ask,", Bid=",Bid,"\n Fecha y hora:",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime())); if (EmailON) SendMail(Symbol()," MAs Cross Down "+PeriodoMA1+"-"+PeriodoMA2+" en "+Period()+" min. "+"Fecha y hora:"+TimeToStr(CurTime(),TIME_DATE)+" "+TimeHour(CurTime())+":"+TimeMinute(CurTime()) ); } CrossDown[i]=High[i] + Range; // CrossDown[i] = AvgRange; CrossUp[i]=EMPTY_VALUE; } } //---- return(0); } //+-------------- saludos.
Re: EA con medias movilesHola donjon, echa un vistazo al que tienes en este hilo, creo que te ahorrará bastante tiempo
post79655.html Saludos, FXWizard
2 mensajes
• Página 1 de 1
|
|
Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 1 invitado