How to code? - page 23

 
islandrock:
that code does not make each trade my EA opens expire 12 hours from the time it opens...

Order expiration time works on pending orders only. If OrderSend() is OP_BUY or OP_SELL, you need to time your order within the code. Here is one simple example.

int OrderTime;

OrderSend(Symbol(),OP_BUY,LotsOptimized(),Ask,3,Ask+TakeProfit*Point,"timetest",16384,0,Green)

OrderTime=TimeCurrent();

int total = OrdersTotal();

for(int cnt=0;cnt<total;cnt++)

{

OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);

if((OrderType() <= OP_SELL) && (OrderSymbol() == Symbol()) )

{

if(OrderType()==OP_BUY && TimeCurrent()-OrderTime>(12*60)*60)

{

OrderClose(OrderTicket(),LotsOptimized(),Bid,3,Violet);

}

}

}

Wackena

 

code not function right

I used this to email the status of my account every hour to me. however after i compile and loaded it. it sent that email perfectly the next hour at minute# 59 as it's supposed to then it never sent another one again. what i'm i doing wrong? it looks perfect ?

i dont need it at min #59 i just need it every hour!!

bool mail;

int start()

{

if (Minute()>=59 && !mail){

SendMail("Account Status", "Account Balance is="+DoubleToStr(AccountBalance(),2)+"_Account Equity is="+DoubleToStr(AccountEquity(),2)+

"_Account Profit is="+DoubleToStr(AccountProfit(),2)+"_Account Margin is="+DoubleToStr(AccountMargin(),2)+

"_Account Free Margin is="+DoubleToStr(AccountFreeMargin(),2));

mail=true;

}

 

maybe you just need to put mail = false at some point or just remove this test on mail variable because of course the current code will send only 1 mail.

 

what test on mail variable ?.. i do not under stand please explain..

how about right after mail=true i put

if (minute()<=58 && !mail)

mail= false;

think that might work?...

i think it's coded wrong

 

I think you can put

if (minute()<=58 && mail) // be careful not !mail but mail

mail= false;

and that should be but outside your first if , so not after mail = true; but after }

There are probably better ways to code that but that should work

 

going to try

thanks will give it a shot...will let you know in two hours

 

great it works.... or at least it looks like it does

 

?? need help with this part of code

can anyone tell me how to write this correctly? im trying to single out the open buy and sell trades individually...

i.e. : if open bid > 2.

if open ask >2

I got the rest I just cant code that part right

i know it's simple but i'm pulling out my hair.

 

anybody?

anybody? wow maybe this was a bad question

 

if(Open[0] > 2){ //open bid

//your code

}

if(Open[0]+(Ask-Bid) > 2){ //open ask

//your code

}

depending on your broker, backtesting of open ask may not work

Reason: