Ayuda a la codificación - página 25

 

Por favor, ayuda....

AYUDA....

Moving avarage línea roja, la dirección de la pendiente es bajo la Línea

Moving avarage línea azul, bajo la Línea Roja se está moviendo avarege

Precio "dirección de la pendiente Línea" tiempo de corte

Todo tiene lugar al mismo tiempo: DAR ALARMA INDma_crossover_lines.ex4ma_crossover_lines.mq4

slope_direction_line.ex4CATOR

Por favor, ayuda

--

UmUt EtİkEr

 

Función de ganancias diarias, semanales y mensuales requerida

Estoy teniendo problemas con la codificación. Estoy tratando de crear un indicador que muestre las ganancias cerradas diarias, cerradas semanales y cerradas mensuales.

¿Alguien tiene una función que calcule las ganancias de estos períodos?

Ej.

Hoy Cerrado : 5.3%

Semana Cerrada : 13.7%

Mes Cerrado 41.3%

Año Cerrado: 79.5%

Sé más o menos lo que hay que hacer pero tengo problemas para hacerlo bien. Si alguien tiene las funciones que harán esto puede por favor ayudarme?

 
Intenta usar esto como base :
//+------------------------------------------------------------------+

//| |

//+------------------------------------------------------------------+

//

//

//

// show statistics

//

//

//

double stat[18];

#define stat.OTodayBuy 0

#define stat.OTodaySell 1

#define stat.OTodayTotal 2

#define stat.OTodayBuyPips 3

#define stat.OTodaySellPips 4

#define stat.OTodayTotalPips 5

#define stat.TodayBuy 6

#define stat.TodaySell 7

#define stat.TodayTotal 8

#define stat.TodayBuyPips 9

#define stat.TodaySellPips 10

#define stat.TodayTotalPips 11

#define stat.TotalBuy 12

#define stat.TotalSell 13

#define stat.TotalTotal 14

#define stat.TotalBuyPips 15

#define stat.TotalSellPips 16

#define stat.TotalTotalPips 17

//

//

//

//

//

void stat.colect()

{

int pointRatio = MathPow(10,Digits%2);

int pipMultiplier = MathPow(10,Digits);

double temp;

//

//

//

//

//

ArrayInitialize(stat,0);

for(int i = 0; i < OrdersTotal(); i++)

{

if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES) == false) break;

if(OrderMagicNumber() != MagicNumber) continue;

if(OrderSymbol() != Symbol()) continue;

if(OrderType()==OP_BUY || OrderType()==OP_SELL)

{

double tempa = OrderProfit()+OrderSwap();

double tempp = 0;

if (OrderType()==OP_BUY)

{

tempp = (Bid-OrderOpenPrice())*pipMultiplier/pointRatio;

stat[stat.OTodayBuy] += tempa;

stat[stat.OTodayBuyPips] += tempp;

}

else

{

tempp = (OrderOpenPrice()-Ask)*pipMultiplier/pointRatio;

stat[stat.OTodaySell] += tempa;

stat[stat.OTodaySellPips] += tempp;

}

}

stat[stat.OTodayTotal] += tempa;

stat[stat.OTodayTotalPips] += tempp;

}

//

//

//

// now check the history

//

//

//

datetime startTime = StrToTime(StringSubstr(TimeToStr(TimeCurrent()),0,10)+" 00:00");

datetime endTime = StrToTime(StringSubstr(TimeToStr(TimeCurrent()),0,10)+" 24:00");

//

//

//

//

//

for(i = 0; i < OrdersHistoryTotal(); i++)

{

if(OrderSelect(i, SELECT_BY_POS, MODE_HISTORY) == false) break;

if(OrderMagicNumber() != MagicNumber) continue;

if(OrderSymbol() != Symbol()) continue;

//

//

//

//

//

bool isOutOfToday = (OrderCloseTime()endTime);

if(OrderType()==OP_BUY || OrderType()==OP_SELL)

{

tempa = OrderProfit()+OrderSwap();

tempp = 0;

if (OrderType()==OP_BUY)

{

tempp = (OrderClosePrice()-OrderOpenPrice())*pipMultiplier/pointRatio;

stat[stat.TotalBuy] += tempa;

stat[stat.TotalBuyPips] += tempp;

if (!isOutOfToday)

{

stat[stat.TodayBuy] += tempa;

stat[stat.TodayBuyPips] += tempp;

}

}

else

{

tempp = (OrderOpenPrice()-OrderClosePrice())*pipMultiplier/pointRatio;

stat[stat.TotalSell] += tempa;

stat[stat.TotalSellPips] += tempp;

if (!isOutOfToday)

{

stat[stat.TodaySell] += tempa;

stat[stat.TodaySellPips] += tempp;

}

}

//

//

//

//

//

if (!isOutOfToday)

{

stat[stat.TodayTotal] += tempa;

stat[stat.TodayTotalPips] += tempp;

}

stat[stat.TotalTotal] += tempa;

stat[stat.TotalTotalPips] += tempp;

}

}

}

void showStatistics()

{

if (!showStatistics) return;

//

//

//

//

//

stat.colect();

createLabel( 1,"opened buy profit" ,stat[stat.OTodayBuy] , 10);

createLabel( 2,"opened buy profit (pips)" ,stat[stat.OTodayBuyPips] , 20,0);

createLabel( 3,"opened sell profit" ,stat[stat.OTodaySell] , 30);

createLabel( 4,"opened sell profit (pips)",stat[stat.OTodaySellPips] , 40,0);

createLabel( 5,"opened profit" ,stat[stat.OTodayTotal] , 50);

createLabel( 6,"opened profit (pips)" ,stat[stat.OTodayTotalPips], 60,0);

createLabel( 7,"daily buy profit" ,stat[stat.TodayBuy] , 80);

createLabel( 8,"daily buy profit (pips)" ,stat[stat.TodayBuyPips] , 90,0);

createLabel( 9,"daily sell profit" ,stat[stat.TodaySell] ,100);

createLabel(10,"daily sell profit (pips)" ,stat[stat.TodaySellPips] ,110,0);

createLabel(11,"daily profit" ,stat[stat.TodayTotal] ,120);

createLabel(12,"daily profit (pips)" ,stat[stat.TodayTotalPips] ,130,0);

createLabel(13,"total buy profit" ,stat[stat.TotalBuy] ,150);

createLabel(14,"total buy profit (pips)" ,stat[stat.TotalBuyPips] ,160,0);

createLabel(15,"total sell profit" ,stat[stat.TotalSell] ,170);

createLabel(16,"total sell profit (pips)" ,stat[stat.TotalSellPips] ,180,0);

createLabel(17,"total profit" ,stat[stat.TotalTotal] ,190);

createLabel(18,"total profit (pips)" ,stat[stat.TotalTotalPips] ,200,0);

WindowRedraw();

}

//

//

//

//

//

void createLabel(string lname, string text, double value,int ypos,int decimals=2)

{

string name = "stat."+lname;

if (ObjectFind(name) == -1)

{

ObjectCreate(name,OBJ_LABEL,0,0,0);

ObjectSet(name,OBJPROP_CORNER ,0);

ObjectSet(name,OBJPROP_XDISTANCE,5);

ObjectSet(name,OBJPROP_YDISTANCE,ypos+5);

}

ObjectSetText(name,text,9,"Arial",Gray);

//

//

//

//

//

name = name+"value";

if (ObjectFind(name) == -1)

{

ObjectCreate(name,OBJ_LABEL,0,0,0);

ObjectSet(name,OBJPROP_CORNER ,0);

ObjectSet(name,OBJPROP_XDISTANCE,145);

ObjectSet(name,OBJPROP_YDISTANCE,ypos+5);

}

color theColor = DimGray;

if (value < 0) theColor = Orange;

if (value > 0) theColor = Lime;

ObjectSetText(name,DoubleToStr(value,decimals),9,"Arial",theColor);

}

tienes las estadísticas abiertas, diarias y totales cubiertas en este. Añadir semanales y mensuales no debería ser difícil (sólo hay que seguir la lógica de la recogida de datos diarios)

sbwent:
Estoy teniendo problemas con la codificación. Estoy intentando crear un indicador que muestre las ganancias cerradas diarias, cerradas semanales y cerradas mensuales.

¿Alguien tiene una función que calcule las ganancias de estos períodos?

Ej.

Hoy Cerrado : 5.3%

Semana cerrada: 13,7%.

Mes Cerrado: 41.3%

Año Cerrado: 79.5%

Sé más o menos lo que hay que hacer pero tengo problemas para hacerlo bien. ¿Si alguien tiene las funciones que harán esto puede por favor ayudarme?
 

Gracias, lo intentaré.

mladen:
Intenta usar esto como base :
//+------------------------------------------------------------------+

//| |

//+------------------------------------------------------------------+

//

//

//

// show statistics

//

//

//

double stat[18];

#define stat.OTodayBuy 0

#define stat.OTodaySell 1

#define stat.OTodayTotal 2

#define stat.OTodayBuyPips 3

#define stat.OTodaySellPips 4

#define stat.OTodayTotalPips 5

#define stat.TodayBuy 6

#define stat.TodaySell 7

#define stat.TodayTotal 8

#define stat.TodayBuyPips 9

#define stat.TodaySellPips 10

#define stat.TodayTotalPips 11

#define stat.TotalBuy 12

#define stat.TotalSell 13

#define stat.TotalTotal 14

#define stat.TotalBuyPips 15

#define stat.TotalSellPips 16

#define stat.TotalTotalPips 17

//

//

//

//

//

void stat.colect()

{

int pointRatio = MathPow(10,Digits%2);

int pipMultiplier = MathPow(10,Digits);

double temp;

//

//

//

//

//

ArrayInitialize(stat,0);

for(int i = 0; i < OrdersTotal(); i++)

{

if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES) == false) break;

if(OrderMagicNumber() != MagicNumber) continue;

if(OrderSymbol() != Symbol()) continue;

if(OrderType()==OP_BUY || OrderType()==OP_SELL)

{

double tempa = OrderProfit()+OrderSwap();

double tempp = 0;

if (OrderType()==OP_BUY)

{

tempp = (Bid-OrderOpenPrice())*pipMultiplier/pointRatio;

stat[stat.OTodayBuy] += tempa;

stat[stat.OTodayBuyPips] += tempp;

}

else

{

tempp = (OrderOpenPrice()-Ask)*pipMultiplier/pointRatio;

stat[stat.OTodaySell] += tempa;

stat[stat.OTodaySellPips] += tempp;

}

}

stat[stat.OTodayTotal] += tempa;

stat[stat.OTodayTotalPips] += tempp;

}

//

//

//

// now check the history

//

//

//

datetime startTime = StrToTime(StringSubstr(TimeToStr(TimeCurrent()),0,10)+" 00:00");

datetime endTime = StrToTime(StringSubstr(TimeToStr(TimeCurrent()),0,10)+" 24:00");

//

//

//

//

//

for(i = 0; i < OrdersHistoryTotal(); i++)

{

if(OrderSelect(i, SELECT_BY_POS, MODE_HISTORY) == false) break;

if(OrderMagicNumber() != MagicNumber) continue;

if(OrderSymbol() != Symbol()) continue;

//

//

//

//

//

bool isOutOfToday = (OrderCloseTime()endTime);

if(OrderType()==OP_BUY || OrderType()==OP_SELL)

{

tempa = OrderProfit()+OrderSwap();

tempp = 0;

if (OrderType()==OP_BUY)

{

tempp = (OrderClosePrice()-OrderOpenPrice())*pipMultiplier/pointRatio;

stat[stat.TotalBuy] += tempa;

stat[stat.TotalBuyPips] += tempp;

if (!isOutOfToday)

{

stat[stat.TodayBuy] += tempa;

stat[stat.TodayBuyPips] += tempp;

}

}

else

{

tempp = (OrderOpenPrice()-OrderClosePrice())*pipMultiplier/pointRatio;

stat[stat.TotalSell] += tempa;

stat[stat.TotalSellPips] += tempp;

if (!isOutOfToday)

{

stat[stat.TodaySell] += tempa;

stat[stat.TodaySellPips] += tempp;

}

}

//

//

//

//

//

if (!isOutOfToday)

{

stat[stat.TodayTotal] += tempa;

stat[stat.TodayTotalPips] += tempp;

}

stat[stat.TotalTotal] += tempa;

stat[stat.TotalTotalPips] += tempp;

}

}

}

void showStatistics()

{

if (!showStatistics) return;

//

//

//

//

//

stat.colect();

createLabel( 1,"opened buy profit" ,stat[stat.OTodayBuy] , 10);

createLabel( 2,"opened buy profit (pips)" ,stat[stat.OTodayBuyPips] , 20,0);

createLabel( 3,"opened sell profit" ,stat[stat.OTodaySell] , 30);

createLabel( 4,"opened sell profit (pips)",stat[stat.OTodaySellPips] , 40,0);

createLabel( 5,"opened profit" ,stat[stat.OTodayTotal] , 50);

createLabel( 6,"opened profit (pips)" ,stat[stat.OTodayTotalPips], 60,0);

createLabel( 7,"daily buy profit" ,stat[stat.TodayBuy] , 80);

createLabel( 8,"daily buy profit (pips)" ,stat[stat.TodayBuyPips] , 90,0);

createLabel( 9,"daily sell profit" ,stat[stat.TodaySell] ,100);

createLabel(10,"daily sell profit (pips)" ,stat[stat.TodaySellPips] ,110,0);

createLabel(11,"daily profit" ,stat[stat.TodayTotal] ,120);

createLabel(12,"daily profit (pips)" ,stat[stat.TodayTotalPips] ,130,0);

createLabel(13,"total buy profit" ,stat[stat.TotalBuy] ,150);

createLabel(14,"total buy profit (pips)" ,stat[stat.TotalBuyPips] ,160,0);

createLabel(15,"total sell profit" ,stat[stat.TotalSell] ,170);

createLabel(16,"total sell profit (pips)" ,stat[stat.TotalSellPips] ,180,0);

createLabel(17,"total profit" ,stat[stat.TotalTotal] ,190);

createLabel(18,"total profit (pips)" ,stat[stat.TotalTotalPips] ,200,0);

WindowRedraw();

}

//

//

//

//

//

void createLabel(string lname, string text, double value,int ypos,int decimals=2)

{

string name = "stat."+lname;

if (ObjectFind(name) == -1)

{

ObjectCreate(name,OBJ_LABEL,0,0,0);

ObjectSet(name,OBJPROP_CORNER ,0);

ObjectSet(name,OBJPROP_XDISTANCE,5);

ObjectSet(name,OBJPROP_YDISTANCE,ypos+5);

}

ObjectSetText(name,text,9,"Arial",Gray);

//

//

//

//

//

name = name+"value";

if (ObjectFind(name) == -1)

{

ObjectCreate(name,OBJ_LABEL,0,0,0);

ObjectSet(name,OBJPROP_CORNER ,0);

ObjectSet(name,OBJPROP_XDISTANCE,145);

ObjectSet(name,OBJPROP_YDISTANCE,ypos+5);

}

color theColor = DimGray;

if (value < 0) theColor = Orange;

if (value > 0) theColor = Lime;

ObjectSetText(name,DoubleToStr(value,decimals),9,"Arial",theColor);

}

tienes las estadísticas abiertas, diarias y totales cubiertas en este. Añadir las semanales y las mensuales no debería ser difícil (sólo hay que seguir la lógica de la recopilación de datos diarios)

Gracias, has sido de gran ayuda. Voy a ver si lo resuelvo a partir de esto.

 

Mtf cci hook

Chicos, puede alguien echar un vistazo y ayudarme con el indicador de gancho CCI adjunto, he añadido la función MTF en él, pero me gustaría ver los puntos alineados horizontalmente y no puedo manejarlo .. o sólo un punto de la barra cerrada de mayor TF.

Gracias de antemano.

ccihookmtf.mq4

Archivos adjuntos:
 

...

Pruebe algo como esto. Este muestra todos los puntos del marco de tiempo objetivo alineados horizontalmente

altoronto:
Chicos, puede alguien echar un vistazo y ayudarme con el indicador adjunto CCI hook, he añadido la función MTF en él, pero me gustaría ver los puntos alineados horizontalmente y no puedo manejarlo .. o sólo un punto de la barra cerrada de mayor TF.

Gracias de antemano.

ccihookmtf.mq4
Archivos adjuntos:
 
mladen:
Prueba algo como esto. Este muestra todos los puntos del marco de tiempo objetivo alineados horizontalmente

Gracias Mladen, realmente sabes cómo torturar los datos

 

...

Si desea limitarlo a un solo punto por barra de marco de tiempo de destino (primera barra que pertenece a la barra de marco de tiempo de destino en este caso), entonces usted podría hacer algo como lo que se han hecho en esta versión (en el ejemplo es una hora cci gancho en el gráfico de 15 minutos - opción añadida al indicador para que pueda elegir)

altoronto:
Gracias Mladen, usted realmente sabe cómo torturar a los datos
Archivos adjuntos:
cci_hk.gif  28 kb
 

Hola chicos

cómo puedo obtener la hora del próximo bar

He intentado

datetime Tiempo[-1];

que no funcionó

saludos

 

Hora del futuro bar ....

Prueba así :
datetime futureBarTime = Time[0]+Period()*60;
Deorn:
hola chicos

como puedo obtener la hora del bar que viene

he intentado

datetime Tiempo[-1];

que no funcionó

saludos
Razón de la queja: