¿Cómo codificar? - página 102

 

mmmm por favor explique más sobre esto

también probé con boolean e if() pero a primera vista no funcionó

 

No puedo explicar más si no veo más...

pero hay que seguir lo básico...

double a=iCustom(indiA);

double b=iCustom(indiB);

double c=iCustom(indiC);

int ORDer=0;

if( a==1 && b>0 && c!=0 ) ORDer=1;

if( a==-1 && b<0 && c!=0 ) ORDer=-1;

if(ORDer==1) COMPRA();

if(ORDer==-1) SELL();

payback:
mmmm por favor explica más sobre esto también he intentado boolean y if() pero a primera vista no funcionó
 

¡ok ok ok!

¡aquí hay más!

double

BuyValueCurrent,

SellValuePrevious,

SellValueCurrent,

BuyValuePrevious2,

BuyValueCurrent2,

SellValuePrevious2,

SellValueCurrent2,

BuyValueCurrent1min,

BuyValueCurrent5min,

BuyValueCurrent21min,

BuyValueCurrent25min,

SellValueCurrent1min,

SellValueCurrent5min,

SellValueCurrent21min,

SellValueCurrent25min,

TrendEnvUp,

TrendEnvDown,

TrendEnvUp1min,

TrendEnvUp5min,

TrendEnvDown1min,

TrendEnvDown5min,

Compra,

Vendi,

StopLong,

StopSell;

[/php]

the icustom funcions and buy sell

BuyValuePrevious = iCustom(NULL,TimeFrame,IndicatorName1,NumBars,0,2);

BuyValueCurrent = iCustom(NULL,0,IndicatorName1,NumBars,1,0);

BuyValuePrevious2 = iCustom(NULL,TimeFrame,IndicatorName2,NumBars,0,2);

BuyValueCurrent2 = iCustom(NULL,0,IndicatorName2,NumBars,0,0);

SellValuePrevious = iCustom(NULL,TimeFrame,IndicatorName1,NumBars,1,2);

SellValueCurrent = iCustom(NULL,0,IndicatorName1,NumBars,0,0);

SellValuePrevious2 = iCustom(NULL,TimeFrame,IndicatorName1,NumBars,1,2);

SellValueCurrent2 = iCustom(NULL,0,IndicatorName2,NumBars,1,0);

BuyValueCurrent1min = iCustom(NULL,1,IndicatorName1,NumBars,1,0);

BuyValueCurrent5min = iCustom(NULL,5,IndicatorName1,NumBars,1,0);

BuyValueCurrent21min = iCustom(NULL,1,IndicatorName2,NumBars,0,0);

BuyValueCurrent25min = iCustom(NULL,5,IndicatorName2,NumBars,0,0);

SellValueCurrent1min = iCustom(NULL,1,IndicatorName1,NumBars,0,0);

SellValueCurrent5min = iCustom(NULL,5,IndicatorName1,NumBars,0,0);

SellValueCurrent21min = iCustom(NULL,1,IndicatorName2,NumBars,1,0);

SellValueCurrent25min = iCustom(NULL,5,IndicatorName2,NumBars,1,0);

TrendEnvUp = iCustom(NULL,0,IndicatorName4,Ma_Period,Ma_Shift,Ma_Method,Applied_Price,Deviation,0,0); // trendenvelopes

TrendEnvDown = iCustom(NULL,0,IndicatorName4,Ma_Period,Ma_Shift,Ma_Method,Applied_Price,Deviation,1,0); // trendenvelopes

TrendEnvUp1min = iCustom(NULL,1,IndicatorName4,Ma_Period,Ma_Shift,Ma_Method,Applied_Price,Deviation,0,0);

TrendEnvUp5min = iCustom(NULL,5,IndicatorName4,Ma_Period,Ma_Shift,Ma_Method,Applied_Price,Deviation,0,0);

TrendEnvDown1min = iCustom(NULL,1,IndicatorName4,Ma_Period,Ma_Shift,Ma_Method,Applied_Price,Deviation,1,0);

TrendEnvDown5min = iCustom(NULL,5,IndicatorName4,Ma_Period,Ma_Shift,Ma_Method,Applied_Price,Deviation,1,0);

BuyCondition = (BuyValueCurrent !=0 && BuyValueCurrent2 !=0 && TrendEnvUp != EMPTY_VALUE)&& (BuyValueCurrent1min !=0 && BuyValueCurrent21min !=0 && TrendEnvUp1min != EMPTY_VALUE) && (BuyValueCurrent5min !=0 && BuyValueCurrent25min !=0 && TrendEnvUp5min != EMPTY_VALUE) ;

SellCondition = (SellValueCurrent !=0 && SellValueCurrent2 !=0 && TrendEnvDown != EMPTY_VALUE)&& (SellValueCurrent1min != 0 && SellValueCurrent21min != 0 && TrendEnvDown1min != EMPTY_VALUE)&& (SellValueCurrent5min != 0 && SellValueCurrent25min != 0 && TrendEnvDown5min != EMPTY_VALUE) ;

StopLong = ((SellValueCurrent !=0 && SellValueCurrent2 !=0) || (TrendEnvDown != EMPTY_VALUE));

StopSell = ((BuyValueCurrent !=0 && BuyValueCurrent2 !=0) || (TrendEnvUp != EMPTY_VALUE));

the exit condition

[php]

StopBuy = (SellValueCurrent !=0 && SellValueCurrent2 !=0 || TrendEnvDown != EMPTY_VALUE);

StopSell = (BuyValueCurrent !=0 && BuyValueCurrent2 !=0 || TrendEnvUp != EMPTY_VALUE);

 

cambiar estos...

para que todas las condiciones sean falsas y permanezcan falsas hasta que las condiciones if() sean verdaderas.

Elimine el StopLong & StopSell en el "doble", todos los demás "dobles" pueden permanecer.

¡Esto lo hará por ti!

bool BuyCondition=false;

bool SellCondition=false;

bool StopLong=false

bool StopSell=false;

if((BuyValueCurrent !=0 && BuyValueCurrent2 !=0 && TrendEnvUp != EMPTY_VALUE) && (BuyValueCurrent1min !=0 && BuyValueCurrent21min !=0 && TrendEnvUp1min != EMPTY_VALUE) && (BuyValueCurrent5min !=0 && BuyValueCurrent25min !=0 && TrendEnvUp5min != EMPTY_VALUE)) {BuyCondition=true;}

if((SellValueCurrent !=0 && SellValueCurrent2 !=0 && TrendEnvDown != EMPTY_VALUE) && (SellValueCurrent1min != 0 && SellValueCurrent21min != 0 && TrendEnvDown1min != EMPTY_VALUE) && (SellValueCurrent5min != 0 && SellValueCurrent25min != 0 && TrendEnvDown5min != EMPTY_VALUE)) {SellCondition=true;}

if((SellValueCurrent !=0 && SellValueCurrent2 !=0) || (TrendEnvDown != EMPTY_VALUE)) {StopLong=true;}

if((BuyValueCurrent !=0 && BuyValueCurrent2 !=0) || (TrendEnvUp != EMPTY_VALUE)) {StopSell=true;}

payback:
¡ok ok ok!

¡aquí hay más!

double

BuyValueCurrent,

SellValuePrevious,

SellValueCurrent,

BuyValuePrevious2,

BuyValueCurrent2,

SellValuePrevious2,

SellValueCurrent2,

BuyValueCurrent1min,

BuyValueCurrent5min,

BuyValueCurrent21min,

BuyValueCurrent25min,

SellValueCurrent1min,

SellValueCurrent5min,

SellValueCurrent21min,

SellValueCurrent25min,

TrendEnvUp,

TrendEnvDown,

TrendEnvUp1min,

TrendEnvUp5min,

TrendEnvDown1min,

TrendEnvDown5min,

Compra,

Vendi,

StopLong,

StopSell;

[/php]the icustom funcions and buy sell

BuyValuePrevious = iCustom(NULL,TimeFrame,IndicatorName1,NumBars,0,2);

BuyValueCurrent = iCustom(NULL,0,IndicatorName1,NumBars,1,0);

BuyValuePrevious2 = iCustom(NULL,TimeFrame,IndicatorName2,NumBars,0,2);

BuyValueCurrent2 = iCustom(NULL,0,IndicatorName2,NumBars,0,0);

SellValuePrevious = iCustom(NULL,TimeFrame,IndicatorName1,NumBars,1,2);

SellValueCurrent = iCustom(NULL,0,IndicatorName1,NumBars,0,0);

SellValuePrevious2 = iCustom(NULL,TimeFrame,IndicatorName1,NumBars,1,2);

SellValueCurrent2 = iCustom(NULL,0,IndicatorName2,NumBars,1,0);

BuyValueCurrent1min = iCustom(NULL,1,IndicatorName1,NumBars,1,0);

BuyValueCurrent5min = iCustom(NULL,5,IndicatorName1,NumBars,1,0);

BuyValueCurrent21min = iCustom(NULL,1,IndicatorName2,NumBars,0,0);

BuyValueCurrent25min = iCustom(NULL,5,IndicatorName2,NumBars,0,0);

SellValueCurrent1min = iCustom(NULL,1,IndicatorName1,NumBars,0,0);

SellValueCurrent5min = iCustom(NULL,5,IndicatorName1,NumBars,0,0);

SellValueCurrent21min = iCustom(NULL,1,IndicatorName2,NumBars,1,0);

SellValueCurrent25min = iCustom(NULL,5,IndicatorName2,NumBars,1,0);

TrendEnvUp = iCustom(NULL,0,IndicatorName4,Ma_Period,Ma_Shift,Ma_Method,Applied_Price,Deviation,0,0); // trendenvelopes

TrendEnvDown = iCustom(NULL,0,IndicatorName4,Ma_Period,Ma_Shift,Ma_Method,Applied_Price,Deviation,1,0); // trendenvelopes

TrendEnvUp1min = iCustom(NULL,1,IndicatorName4,Ma_Period,Ma_Shift,Ma_Method,Applied_Price,Deviation,0,0);

TrendEnvUp5min = iCustom(NULL,5,IndicatorName4,Ma_Period,Ma_Shift,Ma_Method,Applied_Price,Deviation,0,0);

TrendEnvDown1min = iCustom(NULL,1,IndicatorName4,Ma_Period,Ma_Shift,Ma_Method,Applied_Price,Deviation,1,0);

TrendEnvDown5min = iCustom(NULL,5,IndicatorName4,Ma_Period,Ma_Shift,Ma_Method,Applied_Price,Deviation,1,0);

BuyCondition = (BuyValueCurrent !=0 && BuyValueCurrent2 !=0 && TrendEnvUp != EMPTY_VALUE)&& (BuyValueCurrent1min !=0 && BuyValueCurrent21min !=0 && TrendEnvUp1min != EMPTY_VALUE) && (BuyValueCurrent5min !=0 && BuyValueCurrent25min !=0 && TrendEnvUp5min != EMPTY_VALUE) ;

SellCondition = (SellValueCurrent !=0 && SellValueCurrent2 !=0 && TrendEnvDown != EMPTY_VALUE)&& (SellValueCurrent1min != 0 && SellValueCurrent21min != 0 && TrendEnvDown1min != EMPTY_VALUE)&& (SellValueCurrent5min != 0 && SellValueCurrent25min != 0 && TrendEnvDown5min != EMPTY_VALUE) ;

StopLong = ((SellValueCurrent !=0 && SellValueCurrent2 !=0) || (TrendEnvDown != EMPTY_VALUE));

StopSell = ((BuyValueCurrent !=0 && BuyValueCurrent2 !=0) || (TrendEnvUp != EMPTY_VALUE));

the exit condition

[php]

StopBuy = (SellValueCurrent !=0 && SellValueCurrent2 !=0 || TrendEnvDown != EMPTY_VALUE);

StopSell = (BuyValueCurrent !=0 && BuyValueCurrent2 !=0 || TrendEnvUp != EMPTY_VALUE);

 

Gracias, lo intentaré esta tarde.

 

una pregunta estúpida todo lo que está dentro de la {} es su comentario o tengo que escribirlo? y por qué? por qué {;} y no {}; ?

¿también puedo usar esta declaración correctamente?

if(SellCondition)

{

ticket = subOpenOrder(OP_SELL,NewStopLossSell,TakeProfit,TicketComment); // open SELL order

subCheckError(ticket,"SELL");

LastTrade = "SELL";

return(0);

[/php]

or i have to write:

[php]

if(SellCondition = true)

{

ticket = subOpenOrder(OP_SELL,NewStopLossSell,TakeProfit,TicketComment); // open SELL order

subCheckError(ticket,"SELL");

LastTrade = "SELL";

return(0);

 

Se necesita ayuda para codificar un simple ea, por favor...

Hola a todos,

Me gustaría agradecer a todos los que me han ayudado en el pasado. Ahora, tengo una nueva solicitud.

Alguien puede ayudarme a codificar este ea y aquí están los parámetros:

Mi ea se basa en una barra doji y una barra inside.

Para una barra interior:

Colocar un BUY-STOP/BUY-LIMIT en el HIGH de la siguiente barra

Coloque un SELL-STOP/SELL-LIMIT en el LOW de la siguiente barra

Aclaraciones :

La barra interior es la barra 0 (cero)

La barra siguiente es donde vamos a colocar el límite de compra y venta o el stop

La barra siguiente es donde se activará el largo o el corto.

En un gráfico de una hora, si tenemos una barra interna a las 9 AM, entonces colocamos nuestro BUY-STOP o LIMIT y SELL-Stop otr LIMIT en el máximo y mínimo de la barra de las 10 AM. El largo o corto se activará en la barra de las 11 AM siempre que el precio suba o baje de la barra de las 10 AM.

Para una barra Doji:

Coloque un BUY-STOP/BUY-LIMIT en el ALTO de la barra anterior

Coloque un SELL-STOP/SELL-LIMIT en el LOW de la barra anterior

Aclaraciones :

La barra Doji es la barra 0 (cero)

La barra anterior o barra antes de la barra doji es donde vamos a colocar el límite de compra y venta o el stop en el máximo y el mínimo.

La barra después de la barra doji es donde se activará la compra o venta.

En un gráfico de una hora, si tenemos una barra doji a las 9 AM, entonces colocamos nuestro BUY-STOP o LIMIT y SELL-Stop otr LIMIT en el máximo y mínimo de la barra de las 8 AM. El largo o corto se activará en la barra de las 10 AM siempre que el precio suba o baje de la barra de las 8 AM.

...tal vez, no es tan simple. Si lo fuera lo habría hecho hace 2 semanas.

Gracias de antemano.

Un saludo,

forexcel

 

estos no son comentarios, esto es código.

son parte de su declaración if().

if(CondiciónDeVenta){

...

return(0);

}

if(CondiciónDeVenta==true){

...

return(0);

}

ambas sentencias están bien, puedes usar una de ellas...

pero mira que cada sentencia if() se cierra con }

no aparece en el código que aportas aquí.

otro ejemplo:

if(a==b){c=1; d=2; return(0);}

payback:
una pregunta estupida todo lo que esta dentro de {} es tu comentario o tengo que escribirlo? y por que? por que {;} y no {}; ?

También puedo utilizar este statment derecho?

if(SellCondition)

{

ticket = subOpenOrder(OP_SELL,NewStopLossSell,TakeProfit,TicketComment); // open SELL order

subCheckError(ticket,"SELL");

LastTrade = "SELL";

return(0);

[/php]

or i have to write:

[php]

if(SellCondition = true)

{

ticket = subOpenOrder(OP_SELL,NewStopLossSell,TakeProfit,TicketComment); // open SELL order

subCheckError(ticket,"SELL");

LastTrade = "SELL";

return(0);

 

¡¡¡¡ahhhhh he entendido perfectamente thx!!!!

revisando mi C de la universidad es lo mismo

¡¡¡de todas formas muchas gracias!!!

 

encontrado algunos indicadores para comenzar con ...

también hay un EA, pero no funciona tan bien creo, sólo hizo una prueba rápida...

Archivos adjuntos: