OrderOpenTime() problem regarding getting last order open time - page 2

 
Keith Watford:

First loop through the orders and find which one has the latest OrderOpenTime().

That is the only order that you are interested in.

thank you my friend for your reply 

but still I can not figure it out 

I mean we need to go through order select 

then choose the last order with OrdersTotoal ( ) -1 

then we get the information we need such as OrderOpenTime ( ) 

that is the only way my mind is set to :)

is there another way ? 

please if it does not take a lot of your time I appreciate it if you elaborate . 

 

Don't assume that the latest order is at the index OrdersTotal()-1.

   datetime lastOrderTime=0;
   for (int cnt=OrdersTotal()-1; cnt>=0 ; cnt--)
     {
      if(OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderOpenTime()>lastOrderTime)
            lastOrderTime=OrderOpenTime();
        }
     }
 
rkomm:

I have deleted your new topic.

The subject is very similar to what is being discussed here so no need for a new topic.

Adapt the above code to fit your requirements.

 
Keith Watford:

Don't assume that the latest order is at the index OrdersTotal()-1.

datetime lastOrderTime=0;
   for (int cnt=OrdersTotal()-1; cnt>=0 ; cnt--)
     {
      if(OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderOpenTime()>lastOrderTime)
            lastOrderTime=OrderOpenTime();
        }
     }

Keith Watford:

I have deleted your new topic.

The subject is very similar to what is being discussed here so no need for a new topic.

Adapt the above code to fit your requirements.

thank you my dear friend you've been a great help to me . may god bless you with happiness :)

regarding my last topic that got deleted , if it's not taking your time can you help me with that too ?

I promise when become a pro such as you , I would help a rookie like me :)

the GOAL is to get these line of code for SPECIFIC chart like CHFJPY

because these line of codes is for all orders form all chart 

p.s : I have used " if( OrderSymbol( ) == Symbol ( ) ) "  but it did not work 

 
rkomm:

p.s : I have used " if( OrderSymbol( ) == Symbol ( ) ) "  but it did not work 

Yes, it will work.

Think about it and insert it into the code that I showed you.

 
Keith Watford:

Yes, it will work.

Think about it and insert it into the code that I showed you.

of course my good friend 

thank you for being a bright light to my dark path 

I will try it as you said 

either we find a way or we make one :)

thanks for every thing 

 
what is the equation for some int like X if X be like 

int X = TimeCurrent () - OrderOpenTime()

and we want to X be greater than X + 360

certainly it wont be as X >= X + 360 

because X is getting increased by both side of equation 
 
rkomm:

and we want to X be greater than X + 360

Not a valid argument

X cannot be greater than X+360

Think about it

If x=100

Can 100 be greater than 460?

 
Keith Watford:

Not a valid argument

X cannot be greater than X+360

Think about it

If x=100

Can 100 be greater than 460?

I know as I mentioned it is a false equation 

but you know my purpose is this :

when we do :  int X = TimeCurrent () - OrderOpenTime()

x is a number like 9000 

and with every tick that comes X get increased too   like 9001

is there a way to save that value 9000 to stay still and frozen at 9000     and then we compare renewed value of X ( which gets renewed with every tick ) that X be greater than 9000+360 ?


all lines above serves the purpose of telling ea to wait 360 second form last order open time so that you can enter another trade

 
rkomm: is there a way to save that value 9000 to stay still and frozen at 9000     and then we compare renewed value of X ( which gets renewed with every tick ) that X be greater than 9000+360 ?

Save the value in a globally scoped variable or in a locally scoped static variable. Both variable types will keep the value saved between OnTick() events.

Globally scoped variables are defined outside all functions, usually at the start of the MQL file, while locally scoped static variables are defined inside a function but with the keyword "static" in front of it.

Static Variables - Variables - Language Basics - MQL4 Reference
Static Variables - Variables - Language Basics - MQL4 Reference
  • docs.mql4.com
Static Variables - Variables - Language Basics - MQL4 Reference
Reason: