Está perdiendo oportunidades comerciales:
- Aplicaciones de trading gratuitas
- 8 000+ señales para copiar
- Noticias económicas para analizar los mercados financieros
Registro
Entrada
Usted acepta la política del sitio web y las condiciones de uso
Si no tiene cuenta de usuario, regístrese
detalle de la última vela
Hola,
necesito un indicador que muestre el valor de la última vela alta, baja, abierta y cerrada...
¿Por qué no usar un trailing stop entonces? Quiero decir que haría casi el 100% (casi) de lo que su idea original es y es mucho, mucho más fácil de código
La cuestión es (creo que no lo he expresado bien o no era 100% correcto) que los stops (por ahora) seguirán siendo los mismos durante toda la operación. ¿Qué tal un enfoque como este, cuando dos operaciones están abiertas, un código puede comprobar el número de órdenes abiertas, si es superior a 1 (básicamente 2), entonces ambas operaciones tienen sus ganancias modificadas a una cierta cantidad que era mayor que antes. Esencialmente algún tipo de cobertura va aquí.
Gracias,
madmax3
[langtitle=pl]Proszę o pomoc w napisaniu EA działającego n[/langtitle]
[lang=pl]Witam czy bugł by ktoś mi to dopracować był rym wdzięczny : Chciałbym rzeby kupywał LevelRSIbuy=20; a sprzeawał jak dojdzie LevelRSIsell=80; i żeby dało się ustawiać pozostałe żeczy kt�re są pod extern int MagicNumber
#define SEÑAL_NADA 0
#define SEÑAL_BUY 1
#define SEÑAL_VENTA 2
#define SEÑAL_CLOSEBUY 3
#define SEÑAL_CLOSESELL 4
#propiedad copyright "Expert Advisor Builder"
#property link "http://sufx.core.t3-ism.net/ExpertAdvisorBuilder/"
extern int NúmeroMágico = 0;
extern bool SignalMail = False;
extern bool EachTickMode = True;
extern double Lots = 0.1
extern int Slippage = 1;
extern bool UseStopLoss = True
extern int StopLoss = 10;
extern bool UseTakeProfit = True
extern int TakeProfit = 5
extern bool UseTrailingStop = False
extern int TrailingStop = 30;
extern int LevelRSIbuy=20;
extern int LevelRSIsell=80;
int BarCount;
int Actual;
bool TickCheck = False;
//+------------------------------------------------------------------+
//| función de inicialización de expertos ||.
//+------------------------------------------------------------------+
int init() {
BarCount = Bars;
si (EachTickMode) Current = 0; si no, Current = 1;
return(0);
}
//+------------------------------------------------------------------+
//| función de desinicialización experta ||.
//+------------------------------------------------------------------+
int deinit() {
return(0);
}
//+------------------------------------------------------------------+
//| función de inicio experta |
//+------------------------------------------------------------------+
int inicio() {
int Orden = SIGNAL_NONE;
int Total, Ticket;
double StopLossLevel, TakeProfitLevel;
if (EachTickMode && Bars != BarCount) TickCheck = False;
Total = OrdersTotal();
Orden = SIGNAL_NONE;
//+------------------------------------------------------------------+
//| Comienzo de la variable |++
//+------------------------------------------------------------------+
double Var1 = iRSI("EURUSD", PERIOD_M1, 14, PRICE_OPEN, Current + 0);
double Buy1_1 = iRSI("EURUSD", PERIOD_M1, 14, PRICE_OPEN, Current + 0);
double Sell1_1 = iRSI("EURUSD", PERIOD_M1, 14, PRICE_OPEN, Current + 0);
//+------------------------------------------------------------------+
//| Fin de la Variable ||++
//+------------------------------------------------------------------+
//Comprobar posición
bool IsTrade = False;
for (int i = 0; i < Total; i ++) {
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if(OrderType() <= OP_SELL && OrderSymbol() == Symbol()) {
IsTrade = True;
if(OrderType() == OP_BUY) {
//Cerrar
//+------------------------------------------------------------------+
//| Señal Inicio(Salida Compra) || /Cerrar
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Señal de Fin(Salir de la compra) ||
//+------------------------------------------------------------------+
if (Order == SIGNAL_CLOSEBUY && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {
OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, MediumSeaGreen);
if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + " Close Buy");
if (!EachTickMode) BarCount = Bars;
IsTrade = False;
continuar;
}
//Trailing stop
if(UseTrailingStop && TrailingStop > 0) {
if(Bid - OrderOpenPrice() > Point * TrailingStop) {
if(OrderStopLoss() < Bid - Point * TrailingStop) {
OrderModify(OrderTicket(), OrderOpenPrice(), Bid - Point * TrailingStop, OrderTakeProfit(), 0, MediumSeaGreen);
if (!EachTickMode) BarCount = Bars;
continuar;
}
}
}
} else {
//Cerrar
//+------------------------------------------------------------------+
//| Señal de inicio (salida de la venta)
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Señal Fin(Salir de la Venta) |||
//+------------------------------------------------------------------+
if (Order == SIGNAL_CLOSESELL && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {
OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, DarkOrange);
if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + " Close Sell");
if (!EachTickMode) BarCount = Bars;
IsTrade = False;
continuar;
}
/Trailing stop
if(UseTrailingStop && TrailingStop > 0) {
if((OrderOpenPrice() - Ask) > (Point * TrailingStop)) {
if((OrderStopLoss() > (Ask + Point * TrailingStop)) || (OrderStopLoss() == 0)) {
OrderModify(OrderTicket(), OrderOpenPrice(), Ask + Point * TrailingStop, OrderTakeProfit(), 0, DarkOrange);
if (!EachTickMode) BarCount = Bars;
continuar;
}
}
}
}
}
}
//+------------------------------------------------------------------+
//| Señal Begin(Entry) |
//+------------------------------------------------------------------+
si (False) Orden = SIGNAL_BUY;
si (False) Orden = SEÑAL_VENTA;
//+------------------------------------------------------------------+
//| Señal de fin |++
//+------------------------------------------------------------------+
//Compra
if (Order == SIGNAL_BUY && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {
if(!IsTrade) {
//Comprobar el margen libre
if (AccountFreeMargin() < (1000 * Lots)) {
Print("No tenemos dinero. Margen libre = ", AccountFreeMargin());
return(0);
}
if (UseStopLoss) StopLossLevel = Ask - StopLoss * Point; si no, StopLossLevel = 0.0;
si (UseTakeProfit) TakeProfitLevel = Ask + TakeProfit * Point; si no, TakeProfitLevel = 0.0;
Ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, StopLossLevel, TakeProfitLevel, "Buy(#" + MagicNumber + ")", MagicNumber, 0, DodgerBlue);
if(Ticket > 0) {
if (OrderSelect(Ticket, SELECT_BY_TICKET, MODE_TRADES)) {
Print("Orden de COMPRA abierta : ", OrderOpenPrice());
if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + " Open Buy");
} else {
Print("Error al abrir la orden de COMPRA : ", GetLastError());
}
}
if (EachTickMode) TickCheck = True;
if (!EachTickMode) BarCount = Bars;
return(0);
}
}
/Vender
if (Order == SIGNAL_SELL && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {
if(!IsTrade) {
//Comprobar el margen libre
if (AccountFreeMargin() < (1000 * Lots)) {
Print("No tenemos dinero. Margen libre = ", AccountFreeMargin());
return(0);
}
if (UseStopLoss) StopLossLevel = Bid + StopLoss * Point; si no, StopLossLevel = 0.0;
si (UseTakeProfit) TakeProfitLevel = Bid - TakeProfit * Point; si no, TakeProfitLevel = 0.0;
Ticket = OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, StopLossLevel, TakeProfitLevel, "Sell(#" + MagicNumber + ")", MagicNumber, 0, DeepPink);
if(Ticket > 0) {
if (OrderSelect(Ticket, SELECT_BY_TICKET, MODE_TRADES)) {
Print("Orden de venta abierta : ", OrderOpenPrice());
if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + " Open Sell");
} else {
Print("Error al abrir una orden de VENTA : ", GetLastError());
}
}
if (EachTickMode) TickCheck = True;
if (!EachTickMode) BarCount = Bars;
return(0);
}
}
if (!EachTickMode) BarCount = Bars;
return(0);
}
//+------------------------------------------------------------------+[/lang]
Estoy tratando de usar este código para aumentar el take profit de las operaciones abiertas (si hay dos operaciones abiertas).
if(OrderType()==OP_BUY)
OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),Ask+((TakeProfit+20)*Point),0,Blue);
if(OrderType()==OP_SELL)
OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),Ask+((TakeProfit+20)*Point),0,Blue);total=OrdersTotal(); por cierto.
Todavía no puedo conseguir que funcione, ¿alguna sugerencia?
Gracias,
madmax3
Ayuda para limitar el número de operaciones diarias a 1
Soy nuevo en la programación y necesito ayuda en MQL4. He estudiado algunas guías de codificación y he averiguado cómo abrir y cerrar operaciones en función de mi estrategia comercial. Mi dificultad es limitar el número de operaciones diarias a 1. Quiero abrir no más de 1 operación por día (según la hora del servidor). Así que me gustaría comprobar las órdenes abiertas y cerradas para ver si se ha abierto una orden hoy. Si una orden fue abierta hoy, entonces no abrir ninguna orden adicional para el día.
Por favor, ayuda.
PD: se supone que su EA tiene un parámetro MagicNumber (ese nombre exacto)
PPS: funcionará en marcos de tiempo hasta daiy. No funcionará bien en gráficos semanales y mensuales
Soy nuevo en la programación y necesito ayuda en MQL4. He estudiado algunas guías de codificación y he averiguado cómo abrir y cerrar operaciones basadas en mi estrategia de trading. Mi dificultad es limitar el número de operaciones diarias a 1. Quiero abrir no más de 1 operación por día (según la hora del servidor). Así que me gustaría comprobar las órdenes abiertas y cerradas para ver si se ha abierto una orden hoy. Si una orden fue abierta hoy, entonces no abrir ninguna orden adicional para el día. Por favor, ayúdeme.
[langtitle=pl]Convertir la función Tema en Tema(close,period)[/langtitle]
Witam
Jeszcze raz bo cos sie zle wkleilo. Jak przekazac wartosc funkcji Tema do Var1. En este caso, el tema se ha puesto a disposición de Var1.
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 DarkBlue
#property indicator_width1 2
//---- input parameters
extern int EMA_period=4;
//---- buffers
string txt;
double TemaBuffer[];
double Ema[];
double EmaOfEma[];
double EmaOfEmaOfEma[];
double Var1;
int Var2;
int i,limit,limit2,limit3;
extern int Apply_To_Price=1;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
IndicatorBuffers(5);
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,Var1);
SetIndexBuffer(1,TemaBuffer);
SetIndexBuffer(2,Ema);
SetIndexBuffer(3,EmaOfEma);
SetIndexBuffer(4,EmaOfEmaOfEma);
IndicatorShortName("TEMA("+EMA_period+")");
switch(Apply_To_Price)
{
case 1:
{txt="Open";break;}
case 2:
{txt="High";break;}
case 3:
{txt="Low"; break;}
case 4:
{txt="Median"; break;}
case 5:
{txt="Typical"; break;}
case 6:
{txt="WghtdClose"; break;}
default:
{txt="Close";}
}
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
//----
int counted_bars=IndicatorCounted();
if (counted_bars==0)
{
limit=Bars-1;
limit2=limit-EMA_period;
limit3=limit2-EMA_period;
}
if (counted_bars>0)
{
limit=Bars-counted_bars-1;
limit2=limit;
limit3=limit2;
}
for (i=limit3;i>=0;i--)
{
Var1 = Tema(Apply_To_Price,4); //=======================TUTAJ JEST PROBLEM W VAR1 NIC NIE MA. DLACZEGO?
// Alert(Var1);
}
Var2 = dodawanie (2,3);
return(0);
}
double Tema(int Cena, int cykl)
{
//----
for (i=limit;i>=0;i--) Ema=iMA(NULL,0,cykl,0,MODE_EMA,Cena,i);
for (i=limit2;i>=0;i--) EmaOfEma=iMAOnArray(Ema,0,cykl,0,MODE_EMA,i);
for (i=limit3;i>=0;i--) EmaOfEmaOfEma=iMAOnArray(EmaOfEma,0,cykl,0,MODE_EMA,i);
for (i=limit3;i>=0;i--)
{
TemaBuffer=3*Ema-3*EmaOfEma+EmaOfEmaOfEma;
//Alert(TemaBuffer);
}
return(TemaBuffer);
}
int dodawanie (int a, int b)
{
int c;
c=a+b;
return(c);
}
Así (TEMA) ...
Si lo quieres como función, entonces debería ser algo como esto :Adjunto un indicador de ejemplo también. La ventaja de pasar un valor en lugar del tipo de precio es que de esta manera se puede aplicar tema a cualquier valor (no tiene que ser un tema de un precio, puede ser tema de otro indicador por ejemplo)
Witam
Jeszcze raz bo cos sie zle wkleilo. Jak przekazac wartosc funkcji Tema do Var1. Jak robie tak jak w kodzie ponizej to Var1 jest puste.
[PHP]
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 DarkBlue
#property indicator_width1 2
//---- parámetros de entrada
extern int EMA_period=4;
//---- buffers
string txt;
double TemaBuffer[];
double Ema[];
double EmaOfEma[];
double EmaOfEmaOfEma[];
double Var1;
int Var2;
int i,limit,limit2,limit3;
extern int Apply_To_Price=1;
//+------------------------------------------------------------------+
//| Función de inicialización del indicador personalizada ||.
//+------------------------------------------------------------------+
int init()
{
//---- indicadores
IndicatorBuffers(5);
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,Var1);
SetIndexBuffer(1,TemaBuffer);
SetIndexBuffer(2,Ema);
SetIndexBuffer(3,EmaOfEma);
SetIndexBuffer(4,EmaOfEmaOfEma);
IndicatorShortName("TEMA("+EMA_period+")";
switch(Apply_To_Price)
{
caso 1:
{txt="Open";break;}
caso 2:
{txt="Alto";break;}
caso 3:
{txt="Baja"; break;}
caso 4:
{txt="Mediana"; break;}
caso 5: {txt="Típico"; break;}
{txt="Típico"; break;}
caso 6:
{txt="WghtdClose"; break;}
por defecto:
{txt="Cerrar";}
}
//----
return(0);
}
//+------------------------------------------------------------------+
//| Función de desinicialización del indicador personalizada ||
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Función de iteración del indicador personalizada ||
//+------------------------------------------------------------------+
int inicio()
{
//----
int barras_contadas=IndicadorContado();
if (counted_bars==0)
{
limit=Barras-1;
limit2=limit-EMA_period;
limit3=limit2-EMA_period;
}
if (counted_bars>0)
{
limit=barras_contadas-1;
limit2=limit;
limit3=limit2;
}
for (i=limit3;i>=0;i--)
{
Var1 = Tema(Apply_To_Price,4); //=======================TUTAJ JEST PROBLEM W VAR1 NIC NIE MA. DLACZEGO?
// Alert(Var1);
}
Var2 = dodawanie (2,3);
return(0);
}
double Tema(int Cena, int cykl)
{
//----
for (i=limit;i>=0;i--) Ema=iMA(NULL,0,cykl,0,MODE_EMA,Cena,i);
for (i=limit2;i>=0;i--) EmaOfEma=iMAOnArray(Ema,0,cykl,0,MODE_EMA,i);
for (i=limit3;i>=0;i--) EmaOfEmaOfEma=iMAOnArray(EmaOfEma,0,cykl,0,MODE_EMA,i);
for (i=limit3;i>=0;i--)
{
TemaBuffer=3*Ema-3*EmaOfEma+EmaOfEmaOfEma;
//Alert(TemaBuffer);
}
return(TemaBuffer);
}
int dodawanie (int a, int b)
{
int c;
c=a+b;
return(c);
}
Ayuda con el código HAMMER por favor
Hola,
Estoy empezando recientemente en mql4. Intento elegir martillos blancos y negros en las velas con el siguiente indicador. Sin embargo, en el gráfico a veces las velas obtienen un texto de identificación erróneo (la vela de martillo blanco se identifica como vela de martillo negro y viceversa). Por favor, ayúdeme con esta situación, gracias de antemano.
#property ventana_del_gráfico
int limit;
//---- buffers
string hammer[200000];
//+------------------------------------------------------------------+
//| Función de inicialización del indicador CuStom
//+------------------------------------------------------------------+
int init()
{
return(0);
}
//+------------------------------------------------------------------+
//| Función de desinicialización del indicador CuStor ||
//+------------------------------------------------------------------+
int deinit()
{
//----
ObjectsDeleteAll(hammer,OBJ_TEXT);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Función de iteración del indicador CuStom ||
//+------------------------------------------------------------------+
int inicio()
{
int N
int N1
int N2;
cadena de texto;
int barras_contadas=IndicadorContado();
limit=Barras_contadas;
for(N = 1; N < límite; N++) {
martillo[N]= CharToStr(N);
N1 = N + 1;
N2 = N + 2;
//----
//---- comprobar posibles errores
if(counted_bars<0) {
Alert("NO Bars..");
return(-1);
}
// Comprobar si hay martillo blanco
if (((Close[N1]>Open[N1]) && ((Open[N1]-Low[N1])>=2*(Close[N1]-Open[N1])) && ((High[N1]-Close[N1])<=(Open[N1]-Low[N1])*0.10)) {
ObjectCreate(hammer[N], OBJ_TEXT, 0, Time[N1], Low[N1] - Point);
ObjectSetText(hammer[N], "WHmr", 9, "Times New Roman", LawnGreen);
}
// Comprobar si el martillo es negro
if (((Close[N1]=2*(Open[N1]-Close[N1])) && ((High[N1]-Open[N1])<=(Close[N1]-Low[N1])*0.10))) {
ObjectCreate(hammer[N], OBJ_TEXT, 0, Time[N1], Low[N1] - Point);
ObjectSetText(hammer[N], "BHmr", 9, "Times New Roman", LawnGreen);
}
//----
} // Fin del bucle for
return(0);
}
//+------------------------------------------------------------------+
Hola,
Estoy empezando recientemente en mql4. Tratando de elegir martillos blancos y negros en velas con el siguiente indicador. Sin embargo, en el gráfico a veces las velas obtienen un texto de identificación erróneo (la vela de martillo blanco se identifica como vela de martillo negro y viceversa). Por favor, ayúdeme con esta situación, gracias de antemano.
#property ventana_del_gráfico
int limit;
//---- buffers
string hammer[200000];
//+------------------------------------------------------------------+
//| Función de inicialización del indicador CuStom
//+------------------------------------------------------------------+
int init()
{
return(0);
}
//+------------------------------------------------------------------+
//| Función de desinicialización del indicador CuStor ||
//+------------------------------------------------------------------+
int deinit()
{
//----
ObjectsDeleteAll(hammer,OBJ_TEXT);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Función de iteración del indicador CuStom ||
//+------------------------------------------------------------------+
int inicio()
{
int N
int N1
int N2;
cadena de texto;
int barras_contadas=IndicadorContado();
limit=Barras_contadas;
for(N = 1; N < límite; N++) {
martillo[N]= CharToStr(N);
N1 = N + 1;
N2 = N + 2;
//----
//---- comprobar posibles errores
if(counted_bars<0) {
Alert("NO Bars..");
return(-1);
}
// Comprobar si hay martillo blanco
if (((Close[N1]>Open[N1]) && ((Open[N1]-Low[N1])>=2*(Close[N1]-Open[N1])) && ((High[N1]-Close[N1])<=(Open[N1]-Low[N1])*0.10)) {
ObjectCreate(hammer[N], OBJ_TEXT, 0, Time[N1], Low[N1] - Point);
ObjectSetText(hammer[N], "WHmr", 9, "Times New Roman", LawnGreen);
}
// Comprobar si el martillo es negro
if (((Close[N1]=2*(Open[N1]-Close[N1])) && ((High[N1]-Open[N1])<=(Close[N1]-Low[N1])*0.10))) {
ObjectCreate(hammer[N], OBJ_TEXT, 0, Time[N1], Low[N1] - Point);
ObjectSetText(hammer[N], "BHmr", 9, "Times New Roman", LawnGreen);
}
//----
} // Fin del bucle for
return(0);
}
//+------------------------------------------------------------------+Hola Svezir,
Tengo este indicador para los patrones de velas tal vez le ayudará.