[ARCHIVE]Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Can't go anywhere without you - 5. - page 87

 
sergeev:

713
borilunad 15.01.2013 12:10

Could you please solve one mystery: Why when I inserted this function || isCloseLastPosByTake() == True || the expert in the tester started to slow down very much, times 10! This is one of the 4 mutually exclusive conditions, so I can't use the if chain as in summed conditions to make the code run faster. What can you advise me? Thank you in advance for your advice!

That function goes through the orders to find the last close at the take value. Rework this function to speed it up. They are all universal in Kim's case, which means that you can get rid of a lot of unnecessary things from there. Again, everything depends on the logic of your Expert Advisor.
 

Can you please tell me how to open a buy order? Sell order conditionsif(OrdersTotal()==0&& ma0<ma1 && ma1<ma2). I understand that we should usea switch. What should I write instead of(x,a,b)?

if(OrdersTotal()==0)

switch(x)case'a':case'b':

Thank you in advance!


 
artmedia70:
That function goes through the orders to find the last one closed at the take. Rework this function to speed it up. They are all universal in Kim's program, which means that a lot of unnecessary things can be removed from them. Again, everything depends on the logic of your Expert Advisor.
Thank you very much! I was thinking that I could use some operator, but they don't go through cases with "or" for one and the same action.
 
KoOr:

Can you tell me how to open a buy order? Sell order conditionsif(OrdersTotal()==0&& ma0<ma1 && ma1<ma2). I understand that we should usea switch. What should I write instead of(x,a,b)?

if(OrdersTotal()==0)

switch(x)case'a':case'b':

Thank you in advance!




if(OrdersTotal()==0)
 {
  if( ma0<ma1 && ma1<ma2) OrderSend(....,OP_SELL,.......);
  if( ma0>ma1 && ma1>ma2) OrderSend(....,OP_BUY,.......);
 }
Only one order will open, no more than that, either to sell or to buy.
 

I have been struggling all day to understand why the function returns -1

int typ(string t, int m)
{  datetime z=0 ; int p=-1,i;
   int d=OrdersHistoryTotal();
   if ( t=="0") t=Symbol(); 
   for( i=0;i<=d;i++){
   if ( OrderSelect(i,SELECT_BY_POS,MODE_HISTORY) ) {                     
   if ( (OrderSymbol() == t || t=="0" ) && ( OrderMagicNumber() == m || m==-1 ) ){
   if ( OrderCloseTime()>z&&OrderType()<=1)  
   {
   z =OrderCloseTime(); 
   p =OrderType();
   }}}}
return(p);
} 

The call goes like this

Comment(typ("0",-1));

All orders are in the history !

What can be the error?

 
VOLDEMAR:

I have been struggling all day to understand why the function returns -1

The call goes like this

All orders are in the history !

What can be the error?



Comment(typ(Symbol(),-1));
There is no "0", there is "EURUSD", "AUDUSD" etc.
 
Sepulca:


There is no such symbol "0", there is "EURUSD", "AUDUSD" etc.

If there is no such symbol if ( t=="0") t=Symbol(); then make t equal to our symbol to which the EA is attached;
 
but how can it be that the condition if DayOfWeek( ) ==1 ... ...would be met on a Tuesday?
 
VOLDEMAR:

If there is no such a symbol if ( t=="0") t=Symbol(); then make t equal to our symbol to which the EA is attached ;

I'm sorry, I didn't notice... Then here it is:

for( i=0;i<d; i++){

The last order number is OrdersTotal()-1; But that's not the point. I tried it, it turns out the history of closed orders is not visible in the tester, on the demo account your code works.

 

I don't have what you wrote in my code.

I do.

int d=OrdersHistoryTotal();

and it goes through first...

Well, it doesn't matter, I found the problem elsewhere in the code ....

Reason: