Ayuda a la codificación - página 490

 
tfi_markets:
Implementar; Indicador NonLag_Schaff_TrendCycle:

Hola Pro-Coders,

Me pregunto si alguien podría ayudarme a implementar el indicador NonLag_Schaff_TrendCycle.

Externas del indicador:

extern int FastLength = 23;

extern int SlowLength = 50;

extern int StcPeriod = 10;

extern int MacdPrice = PRICE_CLOSE;

extern bool Interpolate = true

extern bool MultiColor = true;

Buffer de Indicadores:

IndicatorBuffers(8);

SetIndexBuffer(0,stcBuffer);

SetIndexBuffer(1,stcBufferUA);

SetIndexBuffer(2,stcBufferUB);

SetIndexBuffer(3,macdBuffer);

SetIndexBuffer(4,fastKBuffer);

SetIndexBuffer(5,fastDBuffer);

SetIndexBuffer(6,fastKKBuffer);

SetIndexBuffer(7,trend);

Intento hacer algo como

double STC1_c=iCustom(Symbol(),0, "NonLag_Schaff_TrendCycle",FastLength,SlowLength,StcPeriod,MacdPrice,Interpolate,0,bar);

double STC2_c=iCustom(Symbol(),0, "NonLag_Schaff_TrendCycle",FastLength,SlowLength,StcPeriod,MacdPrice,Interpolate,0,bar+1);

if((STC1_c>15 && STC2_c85 && STC2_c BUY

if((STC1_c15)||(STC1_c85) -> VENDER

Pero me sale un mensaje de error

Error: NonLag_Schaff_TrendCycle ha sido eliminado.

Supongo que puedo leer mal los buffers. ¿Alguien tiene alguna sugerencia?

Gracias de antemano.

El primer parámetro del ciclo de tendencia nonlag schaf es "TimeFrame". Te falta en la llamada iCustom. La llamada a iCustom() debería ser así:

iCustom(Symbol(),0, "NonLag_Schaff_TrendCycle","",FastLength,SlowLength,StcPeriod,MacdPrice,Interpolate,0,bar);

 

Necesito ayuda

Hola mladen

gracias por tu ayuda anterior

he intentado hacer este indicador pero no aparece

así que por favor ayúdame de nuevo

Gracias de antemano

mtf_rsi_candle_all_in_one.mq4

Archivos adjuntos:
 

Hola Mladen,

muchas gracias por tu ayuda. Ahora ya funciona

Saludos cordiales,

Thomas

mladen:
El primer parámetro del ciclo de tendencia nonlag schaf es "TimeFrame". Te falta en la llamada iCustom. La llamada iCustom() debería ser así: iCustom(Symbol(),0, "NonLag_Schaff_TrendCycle","",FastLength,SlowLength,StcPeriod,MacdPrice,Interpolate,0,bar);
 

¡Hola, Mladen!

Cuando la nueva construcción de largo hace la optimización.

Si se vuelve a la build 670, la velocidad de optimización es buena.

¿Cuál podría ser el problema?

experttsi.mq4

tsi.mq4

Archivos adjuntos:
experttsi.mq4  2 kb
tsi.mq4  4 kb
 
QuantF:
¡Hola, Mladen!

Cuando la nueva build long hace la optimización.

Si se vuelve a la build 670, la velocidad de optimización es buena.

¿Cuál podría ser el problema?

experttsi.mq4

tsi.mq4

Firs en el indicador TSI eliminar la línea que va así :

#property strict

Con esa línea no funcionará

______________

Por lo demás : todos debemos esperar y rezar. Con cada nueva build, el backtesting es cada vez más lento (ver queja de la build 840). No hay mucho que hacer. Llegó al punto de que el backtestin visual es más rápido que el backtesting regular (la build 788 es la que estoy usando) y no hay ninguna lógica en ello

 

Hola Pro Coders,

por alguna razón mi EA está cerrando posiciones pero no abriendo nuevas, después de que la tendencia ha cambiado. ¿Podría alguien echar un vistazo?

Gracias de antemano.

//----------------------- LOAD INDICATORS FOR CLOSING POSITIONS

double STC0_c=iCustom(Symbol(),0,"NonLag_Schaff_TrendCycle","",FastLength,SlowLength,StcPeriod,MacdPrice,Interpolate,MultiColor,0,bar+2);

double STC1_c=iCustom(Symbol(),0,"NonLag_Schaff_TrendCycle","",FastLength,SlowLength,StcPeriod,MacdPrice,Interpolate,MultiColor,0,bar+1);

double STC2_c=iCustom(Symbol(),0,"NonLag_Schaff_TrendCycle","",FastLength,SlowLength,StcPeriod,MacdPrice,Interpolate,MultiColor,0,bar);

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

for(int i=OrdersTotal()-1;i>=0 ; i--)

{

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

if(OrderMagicNumber()!= MAGIC)continue;

if(OrderSymbol()!= s_symbol) continue;

//----------------------- CLOSE BUY CONDITION

if(STC1_c!=STC2_c) // Check trend

{

if(OrderType()==OP_BUY)

{

if(STC1_c>STC0_c&&STC2_c<STC1_c)

{

bool buyClose=OrderClose(OrderTicket(),OrderLots(),MarketInfo(s_symbol,MODE_BID),Slippage*pipMultiplier,clCloseBuy);

if(buyClose==false)

{

int ErrorCode = GetLastError();

string ErrDesc = ErrorDescription(ErrorCode);

string ErrAlert= StringConcatenate("Close Buy Order - Error ",ErrorCode,": ",ErrDesc);

if(ShowAlerts == true) Alert(ErrAlert);

string ErrLog=StringConcatenate("Bid: ",MarketInfo(s_symbol,MODE_BID)," Lots: ",OrderLots()," Ticket: ",OrderTicket());

Print(ErrLog);

}

break;

} // mod

}

}

//----------------------- CLOSE SELL CONDITION

if(STC1_c!=STC2_c)

{

if(OrderType()==OP_SELL)

{

if(STC1_cSTC1_c)

{

bool sellClose= OrderClose(OrderTicket(),OrderLots(),MarketInfo(s_symbol,MODE_ASK),Slippage*pipMultiplier,clCloseSell);

if(sellClose == false)

{

ErrorCode = GetLastError();

ErrDesc = ErrorDescription(ErrorCode);

ErrAlert=StringConcatenate("Close Sell Order - Error ",ErrorCode,": ",ErrDesc);

if(ShowAlerts==true) Alert(ErrAlert);

ErrLog=StringConcatenate("Ask: ",MarketInfo(s_symbol,MODE_ASK)," Lots: ",OrderLots()," Ticket: ",OrderTicket());

Print(ErrLog);

}

break;

} // mod

}

}

}

}

Archivos adjuntos:
trendcycle.jpg  97 kb
 
tfi_markets:
Hola Pro Coders,

por alguna razón mi EA está cerrando posiciones pero no abriendo nuevas, después de que la tendencia ha cambiado. ¿Podría alguien echar un vistazo?

Gracias de antemano.

//----------------------- LOAD INDICATORS FOR CLOSING POSITIONS

double STC0_c=iCustom(Symbol(),0,"NonLag_Schaff_TrendCycle","",FastLength,SlowLength,StcPeriod,MacdPrice,Interpolate,MultiColor,0,bar+2);

double STC1_c=iCustom(Symbol(),0,"NonLag_Schaff_TrendCycle","",FastLength,SlowLength,StcPeriod,MacdPrice,Interpolate,MultiColor,0,bar+1);

double STC2_c=iCustom(Symbol(),0,"NonLag_Schaff_TrendCycle","",FastLength,SlowLength,StcPeriod,MacdPrice,Interpolate,MultiColor,0,bar);

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

for(int i=OrdersTotal()-1;i>=0 ; i--)

{

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

if(OrderMagicNumber()!= MAGIC)continue;

if(OrderSymbol()!= s_symbol) continue;

//----------------------- CLOSE BUY CONDITION

if(STC1_c!=STC2_c) // Check trend

{

if(OrderType()==OP_BUY)

{

if(STC1_c>STC0_c&&STC2_c<STC1_c)

{

bool buyClose=OrderClose(OrderTicket(),OrderLots(),MarketInfo(s_symbol,MODE_BID),Slippage*pipMultiplier,clCloseBuy);

if(buyClose==false)

{

int ErrorCode = GetLastError();

string ErrDesc = ErrorDescription(ErrorCode);

string ErrAlert= StringConcatenate("Close Buy Order - Error ",ErrorCode,": ",ErrDesc);

if(ShowAlerts == true) Alert(ErrAlert);

string ErrLog=StringConcatenate("Bid: ",MarketInfo(s_symbol,MODE_BID)," Lots: ",OrderLots()," Ticket: ",OrderTicket());

Print(ErrLog);

}

break;

} // mod

}

}

//----------------------- CLOSE SELL CONDITION

if(STC1_c!=STC2_c)

{

if(OrderType()==OP_SELL)

{

if(STC1_cSTC1_c)

{

bool sellClose= OrderClose(OrderTicket(),OrderLots(),MarketInfo(s_symbol,MODE_ASK),Slippage*pipMultiplier,clCloseSell);

if(sellClose == false)

{

ErrorCode = GetLastError();

ErrDesc = ErrorDescription(ErrorCode);

ErrAlert=StringConcatenate("Close Sell Order - Error ",ErrorCode,": ",ErrDesc);

if(ShowAlerts==true) Alert(ErrAlert);

ErrLog=StringConcatenate("Ask: ",MarketInfo(s_symbol,MODE_ASK)," Lots: ",OrderLots()," Ticket: ",OrderTicket());

Print(ErrLog);

}

break;

} // mod

}

}

}

}

En ese código no hay ningún código que abra una posición en absoluto(la función OrderSend() no se utiliza en absoluto)

 
mladen:
Firs en el indicador TSI eliminar la línea que va así :

#property strict

Con esa línea no funcionará

______________

Por lo demás : todos debemos esperar y rezar. Con cada nueva build, el backtesting es cada vez más lento (ver queja de la build 840). No hay mucho que hacer. Llegó al punto de que el backtestin visual es más rápido que el backtesting regular (la build 788 es la que estoy usando) y no hay ninguna lógica en ello

¡Gracias por la respuesta!

Claro. Me quedo en una build antigua.

 
mladen:
En ese código no hay ningún código que abra una posición en absoluto (la función OrderSend() no se utiliza en absoluto)

Hola Mladen,

tienes razón, por favor encuentra el código de abajo que está llamando a "OpenSell()".

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

//| OPEN BUY / OPEN SELL

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

//----------------------- BUY CONDITION

for(i=OrdersTotal()-1;i>=0; i--)

if(OrderType()==OP_SELL) break;

{

if(STC1!=STC2)

{

/*if(STC1STC1)BUY="true";*/

if(STC1STC1)

/*if((STC115) || (STC185)) // code for buy */

OpenBuy();

return(0);

}

openedOrders++;

}

//----------------------- SELL CONDITION

// if(STC1>STC0&&STC2<STC1)SELL="true";

//if((STC1>15 && STC285 && STC2<85)) // code for sell

if(STC1>STC0&&STC2<STC1) // code for sell

{

OpenSell();

return(0);

}

}

//----------------------- OPEN SELL

void OpenSell()

{

double lsStop = 0; if(sStopLoss>0) lsStop = NormalizeDouble(MarketInfo(s_symbol,MODE_BID)+sStopLoss *pPoint*pipMultiplier,digit);

double lsTake = 0; if(sTakeProfit>0) lsTake = NormalizeDouble(MarketInfo(s_symbol,MODE_BID)-sTakeProfit*pPoint*pipMultiplier,digit);

if(AccountFreeMargin()<(100*Lots)) { Print("We have no money. Free Margin = ",AccountFreeMargin()); return; }

// ECN

if(!EcnBroker)

dummyResult=OrderSend(s_symbol,OP_SELL,LotsOptimized(),MarketInfo(s_symbol,MODE_BID),Slippage*pipMultiplier,lsStop,lsTake,ExpertName,MAGIC,0,clOpenSell);

else

{

int sellTicket = OrderSend(s_symbol,OP_SELL,LotsOptimized(),MarketInfo(s_symbol,MODE_BID),Slippage*pipMultiplier,0,0,ExpertName,MAGIC,0,clOpenSell);

if(sellTicket >= 0)

bool sellOrderMod=OrderModify(sellTicket,OrderOpenPrice(),lsStop,lsTake,0,CLR_NONE);

if(sellOrderMod==false)

{

int ErrorCode = GetLastError();

string ErrDesc = ErrorDescription(ErrorCode);

string ErrAlert=StringConcatenate("Modify Sell Order - Error ",ErrorCode,": ",ErrDesc);

if(ShowAlerts==true) Alert(ErrAlert);

string ErrLog=StringConcatenate("Ask: ",MarketInfo(s_symbol,MODE_ASK)," Bid: ",MarketInfo(s_symbol,MODE_BID)," Ticket: ",sellTicket," Stop: ",lsStop," Profit: ",lsTake);

Print(ErrLog);

}

}

}

 

querido mladen, mrtools esperando a ver su respuesta para mis consultas de fxultratrend indicador en el post anterior.

espero que no me decepcione.

Gracias.

Razón de la queja: