I tried to do a EA base in ZZ indicator... I could open the buy order when the ZZ indicatos get a value; but the order is not close...
Can you help me?
Thanks in advanced...
int MagicN =1453;
extern int Barras=5; // Cantidad de barras extern int y =5; //-------------------------------------------------------------------- extern double Lots = 0.01; extern double Slippage = 3; extern double Period1 = 5; extern string Dev_Step_1 ="0,5"; extern int Symbol_1_Kod =140;
//-------------------------------------------------------------------- bool GV_Flag_NuevaBarra=false; // Flag de una nueva barra //======================================================================
int start() // Special funct. start() { //-------------------------------------------------------------------- Fun_NuevaBarra(); // Funcion call if (GV_Flag_NuevaBarra==false) // Si no hay nueva barra.. return; // ..return //========================================================================= int IndMin =ArrayMinimum(Low,Barras,1); int IndMax =ArrayMaximum(High,Barras,1); double ZZ, CC;
int ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,0,0,"Jeaa",MagicN,0,Blue);
Print ("Orden de Compra enviada: xxxx");// falta colocar el OrderTicket() } //=========================================================================
if (XX == CC)
{ if(OrderMagicNumber()== MagicN) { //---- check order type if(OrderType()==OP_BUY) { OrderClose(OrderTicket(),OrderLots(),Bid,3,White);
void Fun_NuevaBarra() // Descripción de la Funcion que detecta .. { // .. una nueva barra static datetime NewTime=0; // variable que almacena fecha y hora GV_Flag_NuevaBarra=false; // Inicializa nueva barra a falso (no hay nueva barra) if(NewTime!=Time[0]) // Si existe nueva barra el dato es distinto de cero.. { NewTime=Time[0]; //.. y en ese caso se registra el hora y fecha de la.. GV_Flag_NuevaBarra=true; //nueva barra y se activa el flag que señaliza la… //existencia de una nueva barra
the code dosnt work.it has fault.that i have changed "input "to the "extern" for "MA_TF".
then it worked.but the problem still remained.I mean it doesnt shift(transport) the indicator in the end of the chart.the positive shift doesnt work .
but negative works well.
thank you again.
It works with no problem at all
I don't know what did you tests but this is what I used for testing (attached it) and this is what the result of the test looks like (both positive and negative test included). So all works as expected and described
I don't know what did you tests but this is what I used for testing (attached it) and this is what the result of the test looks like (both positive and negative test included). So all works as expected and described
//--- input parameters --- input double Lotes=0.01; input int MagicNumber=1453; input int Barras=5; input int y=5; input double Period1= 5; input string Dev_Step_1="0,5"; input int Symbol_1_Kod=140; input int Slippage=3;
//+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) {
} //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { //--- long TicketEnUso = Ticket(); if (TicketEnUso>0) // significa que hay una operación... debo controlar salida... { if (OrderSelect(TicketEnUso,SELECT_BY_TICKET, MODE_TRADES)) { if (OrderType()==OP_BUY) // buscar una salida por debajo de un promedio { if (Open[y]==ZZ(Period1)) Cierre(TicketEnUso); } if (OrderType()==OP_SELL) // buscar una salida por encima de un promedio { if (Close[y]==CC(Period1)) Cierre(TicketEnUso); } } } if (TicketEnUso<1) // no hay operación debo revisar si hay trade posible { if (Close[y]==CC(Period1)) { Abre(OP_BUY); Alert(Symbol(),": Barras= ",Barras,", ZZ= ",DoubleToString(ZZ(Period1),Digits),", Precio= ",DoubleToString(Close[y],Digits)); Print ("===COMPRA==="); } if (Open[y]==ZZ(Period1)) { Abre(OP_SELL); Alert(Symbol(),": Barras= ",Barras,", CC= ",DoubleToString(CC(Period1),Digits),", Precio= ",DoubleToString(Open[y],Digits)); Print ("===VENTA==="); }
double CC (int Periodos) { return (iCustom(Symbol(),0,"3_Level_ZZ_Semafor",Periodos,Dev_Step_1,Symbol_1_Kod,0,y)); }
//============================================================================================== long Ticket() { for (int o=0; o<OrdersTotal(); o++) { if (OrderSelect(o,SELECT_BY_POS,MODE_TRADES)) { if (MagicNumber == OrderMagicNumber()) return(OrderTicket()); } } return(0); }
void Abre(int Tipo) { if (AccountFreeMargin()<(1000*Lotes))// filtro operaciones que no podria correr por falta de margen disponible { Print ("No hay dinero disponible. Free Margin= ",AccountFreeMargin()); return; } // seleccionar precio por operación double Precio=0; if(Tipo==OP_BUY) Precio=Ask; else Precio=Bid; ResetLastError(); if (OrderSend(NULL,Tipo,Lotes,Precio,Slippage,0,0,NULL,MagicNumber,0,clrNONE)<1) Print (GetLastError());// 10 es fracciones de pips... }
void Cierre(long TicketNo) { double Precio=0; if (OrderSelect(TicketNo,SELECT_BY_TICKET,MODE_TRADES)) { if(OrderType()==OP_BUY) Precio=Bid; else Precio=Ask;//selecciono precio de salida segun tipo de operación ResetLastError();//reseteo número de error if(OrderClose(TicketNo,Lotes,Precio,Slippage,clrNONE)) Print(GetLastError());//si al cerrar manda error que lo imprima } }
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Dear mladen,
I hope you are very well.
I tried to do a EA base in ZZ indicator... I could open the buy order when the ZZ indicatos get a value; but the order is not close...
Can you help me?
Thanks in advanced...
int MagicN =1453;
extern int Barras=5; // Cantidad de barras
extern int y =5;
//--------------------------------------------------------------------
extern double Lots = 0.01;
extern double Slippage = 3;
extern double Period1 = 5;
extern string Dev_Step_1 ="0,5";
extern int Symbol_1_Kod =140;
//--------------------------------------------------------------------
bool GV_Flag_NuevaBarra=false; // Flag de una nueva barra
//======================================================================
int start() // Special funct. start()
{
//--------------------------------------------------------------------
Fun_NuevaBarra(); // Funcion call
if (GV_Flag_NuevaBarra==false) // Si no hay nueva barra..
return; // ..return
//=========================================================================
int IndMin =ArrayMinimum(Low,Barras,1);
int IndMax =ArrayMaximum(High,Barras,1);
double ZZ, CC;
double Buy=Low[IndMin];
double XX=High[IndMax];
ZZ=iCustom(Symbol(),0,"3_Level_ZZ_Semafor",Period1,Dev_Step_1,Symbol_1_Kod,0,y);
CC=iCustom(Symbol(),0,"3_Level_ZZ_Semafor",Period1,Dev_Step_1,Symbol_1_Kod,1,y);
if (Buy == ZZ)
{
Alert(Symbol(),": Barras= ",Barras,", ZZ= ",DoubleToString(ZZ,Digits),", Precio= ",DoubleToString(Buy,Digits) );
int ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,0,0,"Jeaa",MagicN,0,Blue);
Print ("Orden de Compra enviada: xxxx");// falta colocar el OrderTicket()
}
//=========================================================================
if (XX == CC)
{
if(OrderMagicNumber()== MagicN)
{ //---- check order type
if(OrderType()==OP_BUY)
{
OrderClose(OrderTicket(),OrderLots(),Bid,3,White);
Alert(Symbol(),": Barras= ",Barras,", CC= ",DoubleToString(CC,Digits),", Precio= ",DoubleToString(XX,Digits) );
Print ("=====ORDEN CERRADA=====");
}
}
}
//=============================================================================
return;
}
//=========================================================================
void Fun_NuevaBarra() // Descripción de la Funcion que detecta ..
{ // .. una nueva barra
static datetime NewTime=0; // variable que almacena fecha y hora
GV_Flag_NuevaBarra=false; // Inicializa nueva barra a falso (no hay nueva barra)
if(NewTime!=Time[0]) // Si existe nueva barra el dato es distinto de cero..
{
NewTime=Time[0]; //.. y en ese caso se registra el hora y fecha de la..
GV_Flag_NuevaBarra=true; //nueva barra y se activa el flag que señaliza la…
//existencia de una nueva barra
}
}
//--------------------------------------------------------------------
As far as I see you are testing a wrong condition
Values for buffer 1 and too of 3_Level_ZZ_Semafor can not be the same (they are displayed at different places)
Please, dear sir
Change the code to the following :
thank you dear friend,mladen.
thanks a lot for your help.
Change the code to the following :
dear mladen
the code dosnt work.it has fault.that i have changed "input "to the "extern" for "MA_TF".
then it worked.but the problem still remained.I mean it doesnt shift(transport) the indicator in the end of the chart.the positive shift doesnt work .
but negative works well.
thank you again.
dear mladen
the code dosnt work.it has fault.that i have changed "input "to the "extern" for "MA_TF".
then it worked.but the problem still remained.I mean it doesnt shift(transport) the indicator in the end of the chart.the positive shift doesnt work .
but negative works well.
thank you again.
It works with no problem at all
I don't know what did you tests but this is what I used for testing (attached it) and this is what the result of the test looks like (both positive and negative test included). So all works as expected and described
It works with no problem at all
I don't know what did you tests but this is what I used for testing (attached it) and this is what the result of the test looks like (both positive and negative test included). So all works as expected and described
DEAR MLADEN
YOU ARE RIGHT .IT WAS MY MISTAKE.
THANKS ALOT AGAIN MY FRIEND FOR YOUR HELP.
As far as I see you are testing a wrong condition
Values for buffer 1 and too of 3_Level_ZZ_Semafor can not be the same (they are displayed at different places)
Dear mlanden...
Thanks for your comments...
I modified the EA to use the MagicNumber... but the custom indicator full the memory:
2016.09.18 00:33:10.627 Not enough memory for 1039 bars for custom indicator 3_Level_ZZ_Semafor EURUSD,M5
What can I do? Thanks in advanced... Jesús...
//+------------------------------------------------------------------+
//| MA_jeaa_EA.mq4 |
//+------------------------------------------------------------------+
#property copyright "Jesus Acedo"
//--- input parameters ---
input double Lotes=0.01;
input int MagicNumber=1453;
input int Barras=5;
input int y=5;
input double Period1= 5;
input string Dev_Step_1="0,5";
input int Symbol_1_Kod=140;
input int Slippage=3;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
long TicketEnUso = Ticket();
if (TicketEnUso>0) // significa que hay una operación... debo controlar salida...
{
if (OrderSelect(TicketEnUso,SELECT_BY_TICKET, MODE_TRADES))
{
if (OrderType()==OP_BUY) // buscar una salida por debajo de un promedio
{
if (Open[y]==ZZ(Period1)) Cierre(TicketEnUso);
}
if (OrderType()==OP_SELL) // buscar una salida por encima de un promedio
{
if (Close[y]==CC(Period1)) Cierre(TicketEnUso);
}
}
}
if (TicketEnUso<1) // no hay operación debo revisar si hay trade posible
{
if (Close[y]==CC(Period1))
{
Abre(OP_BUY);
Alert(Symbol(),": Barras= ",Barras,", ZZ= ",DoubleToString(ZZ(Period1),Digits),", Precio= ",DoubleToString(Close[y],Digits));
Print ("===COMPRA===");
}
if (Open[y]==ZZ(Period1))
{
Abre(OP_SELL);
Alert(Symbol(),": Barras= ",Barras,", CC= ",DoubleToString(CC(Period1),Digits),", Precio= ",DoubleToString(Open[y],Digits));
Print ("===VENTA===");
}
}
}
//==============================================================================================
double ZZ (int Periodos)
{
return (iCustom(Symbol(),0,"3_Level_ZZ_Semafor",Periodos,Dev_Step_1,Symbol_1_Kod,1,y));
}
double CC (int Periodos)
{
return (iCustom(Symbol(),0,"3_Level_ZZ_Semafor",Periodos,Dev_Step_1,Symbol_1_Kod,0,y));
}
//==============================================================================================
long Ticket()
{
for (int o=0; o<OrdersTotal(); o++)
{
if (OrderSelect(o,SELECT_BY_POS,MODE_TRADES))
{
if (MagicNumber == OrderMagicNumber()) return(OrderTicket());
}
}
return(0);
}
void Abre(int Tipo)
{
if (AccountFreeMargin()<(1000*Lotes))// filtro operaciones que no podria correr por falta de margen disponible
{
Print ("No hay dinero disponible. Free Margin= ",AccountFreeMargin());
return;
}
// seleccionar precio por operación
double Precio=0;
if(Tipo==OP_BUY) Precio=Ask; else Precio=Bid;
ResetLastError();
if (OrderSend(NULL,Tipo,Lotes,Precio,Slippage,0,0,NULL,MagicNumber,0,clrNONE)<1) Print (GetLastError());// 10 es fracciones de pips...
}
void Cierre(long TicketNo)
{
double Precio=0;
if (OrderSelect(TicketNo,SELECT_BY_TICKET,MODE_TRADES))
{
if(OrderType()==OP_BUY) Precio=Bid; else Precio=Ask;//selecciono precio de salida segun tipo de operación
ResetLastError();//reseteo número de error
if(OrderClose(TicketNo,Lotes,Precio,Slippage,clrNONE)) Print(GetLastError());//si al cerrar manda error que lo imprima
}
}
//======================================================================
Hi mladen, is it possible to make this indicator no repaint and mtf????... thank you....
That is a renamed and decompiled sidus (the repainting version)
You can use sidus version 3 or higher for non-repainting version