How to code? - page 102

 

mmmm please explain more about this

also i tried boolean and if() but at a first look didn't work

 

I can't explain more if I don't see more...

but you have to follow the basics...

double a=iCustom(indiA);

double b=iCustum(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) BUY();

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

payback:
mmmm please explain more about this also i tried boolean and if() but at a first look didn't work
 

ok ok ok!

here is more!

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);

 

change these...

so, all the conditions are false and stay false till the if() conditions are true.

Remove the StopLong & StopSell in "double", every other "double" can stay.

This will do it for you!

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!

here is more!

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);

 

thanks i will try this evening!

 

one stupid question everything inside the {} is your comment or i have to write it? and why? why {;} and not {}; ?

also can i still use this statment right?

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);

 

Help Needed to code a simple ea, please...

Hello All,

I'd like to thank everyone who has help me in the past. Righ now, i have a new request.

Can someone help me code this ea and here are the parameters:

My ea is based on an doji bar and an inside bar.

For an Inside bar :

Place a BUY-STOP/BUY-LIMIT at the HIGH of the next bar

Place a SELL-STOP/SELL-LIMIT at the LOW of the next bar

Clarifications :

Inside Bar is bar 0 (zero)

The next Bar is where we going to to place buy and sell limit or stop

The bar after next is where the long or short will be triggered.

On a one hour chart, if we have an inside bar at 9 AM, then we place our BUY-STOP or LIMIT and SELL-Stop otr LIMIT at the high and low of the 10 AM bar. The long or shor will be triggered at the 11 AM bar providing that price goes higher or lower than the 10 AM bar.

For a Doji bar :

Place a BUY-STOP/BUY-LIMIT at the HIGH of the previous bar

Place a SELL-STOP/SELL-LIMIT at the LOW of the previou bar

Clarifications :

Doji Bar is bar 0 (zero)

The Previoust Bar or Bar before the doji bar is where we going to to place buy and sell limit or stop at the high and low.

The bar after the doji bar is where the long or short will be triggered.

On a one hour chart, if we have doji bar at 9 AM, then we place our BUY-STOP or LIMIT and SELL-Stop otr LIMIT at the high and low of the 8 AM bar. The long or shor will be triggered at the 10 AM bar providing that price goes higher or lower than the 8 AM bar.

...maybe, it's not that simple. If it was i would have done it 2 weeks ago.

Thanks in advance!

Best Regards,

forexcel

 

these are not comments, this is code.

they are a part of your if() statement.

if(SellCondition){

...

return(0);

}

if(SellCondition==true){

...

return(0);

}

both statements are ok, you can use one of them...

but see that every if() statement close with }

it doesn't show in your code that you provide here.

other example:

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

payback:
one stupid question everything inside the {} is your comment or i have to write it? and why? why {;} and not {}; ?

also can i still use this statment right?

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 i understood perfectly thx!!!!

i reviewing my C from college it s the same

anyway many thxs!!!

 

found some indicators to start with...

there is also an EA, but it doesn't perform so well I think, just did a quick test...

Reason: