You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
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.
thanks my friend I tried that too
does not seems to work though
Obviously not! What is the use of creating a static variable if you treat it as a discardable variable and immediately rewrite its contents every time?
You have to think about how you use it and the logic behind how you use it.
Don't be a "script kiddy"! Take some time to actually learn about programming in general first and how to think logically and in small steps to carry out sequences and build from that.
Also, you are still using old style MQL4 code which is obsolete. Try to first learn the language properly, by reading a good book on MQL4 programming. I will leave a suggestion for this at the end.
I'm not trying to be nasty, but just calling your attention to the fact that coding is not easy and should be taken seriously. It takes time to learn and become proficient at it.
Here is some suggested reading material (get the latest edition which is for MQL4+ and not the first edition, or consider going straight to MQL5 instead):
thanks my friend I tried that too
does not seems to work though
The title of this topic that you started is about getting the last order time..
I showed you example code to get the last order time.
Where in your last code do you get the last order time?
Oh, you don't! Why not?
Just a few posts back I replied to you
Not a valid argument
X cannot be greater than X+360
Think about it
If x=100
Can 100 be greater than 460?
Now in this code
I really don't know what you are trying to achieve, but you don't understand how to use a static variable. I have no idea what it is likely to be initialised with, but probably 0.
I'm guessing that you probably think that it would be updated every pass of the loop,( but it won't).
If that WAS the case, then the 2 variables would have exactly the same value which would make
ridiculous because it is the same as
Have you any idea how infuriating it is to waste time trying to help people who totally ignore the help?
Fernando correctly answered the question that you asked, but in this case you do not necessarily need to use a static/globalscope variable. If you do use one, you would need to update it every time a new order for the symbol is opened. I think that is beyond your current level.
All you need is to get the last order time for the symbol and compare it to the current time.
Obviously not! What is the use of creating a static variable if you treat it as a discardable variable and immediately rewrite its contents every time?
You have to think about how you use it and the logic behind how you use it.
Don't be a "script kiddy"! Take some time to actually learn about programming in general first and how to think logically and in small steps to carry out sequences and build from that.
Also, you are still using old style MQL4 code which is obsolete. Try to first learn the language properly, by reading a good book on MQL4 programming. I will leave a suggestion for this at the end.
I'm not trying to be nasty, but just calling your attention to the fact that coding is not easy and should be taken seriously. It takes time to learn and become proficient at it.
Here is some suggested reading material (get the latest edition which is for MQL4+ and not the first edition, or consider going straight to MQL5 instead):
it's a honor for a rookie like me be to be talking to a professional coder like you sir
but believe me or not , 1 month ago I did not know any thing about coding what so ever
less than a month I write my very own EA up and running
yesterday my EA made 54 $ with the lot of 0.01 (I can post a proof if it's not against the forum rules )
I have coded " the core " of EA
the rest is order management and balance management (Like break even and trailing stop )
all I wanted was to pause for 5 minute from last order that got opened in 1 minute chart time frame that was all ( to prevent opening unnecessary orders)
I have Andrew R young book printed in my shelf and mql4 pdf book too
but all and all you are right
I've got to learn it more fundamental kind of way
thank you for taking time and replying my good friend :)
The title of this topic that you started is about getting the last order time..
I showed you example code to get the last order time.
Where in your last code do you get the last order time?
Oh, you don't! Why not?
Just a few posts back I replied to you
Now in this code
I really don't know what you are trying to achieve, but you don't understand how to use a static variable. I have no idea what it is likely to be initialised with, but probably 0.
I'm guessing that you probably think that it would be updated every pass of the loop,( but it won't).
If that WAS the case, then the 2 variables would have exactly the same value which would make
ridiculous because it is the same as
Have you any idea how infuriating it is to waste time trying to help people who totally ignore the help?
Fernando correctly answered the question that you asked, but in this case you do not necessarily need to use a static/globalscope variable. If you do use one, you would need to update it every time a new order for the symbol is opened. I think that is beyond your current level.
All you need is to get the last order time for the symbol and compare it to the current time.
" Have you any idea how infuriating it is to waste time trying to help people who totally ignore the help? "
my good friend it was never my intention to disrespect you and your professional work believe me .
your answer gave me a prospective to look at it in better way and I appreciate it
but I wanted to make a new topic and I said it maybe it was close to this topic
the main purpose that got me creating this topic in the first place was this :
to pause a 5 minute between last order to next order in 1 minute chart time frame
and this code that you helped me with just identify the LAST OrderOpenTime( )
but how can we know how many second has passed since last OrderOpenTime() ?
that's why I send the stupid :) question today
but how can we know how many second has passed since last OrderOpenTime() ?
You already do it in your code with the selected order!
Just do it for the last order.
You already do it in your code with the selected order!
Just do it for the last order.
so far I implemented your advise and it's working BUT there is a problem first let me show you the code
problem is some times in within 1 second like 16:21:49 it opens 3 or 4 order
I will send the photo at end
so I searched between previous post to get the solution I have come across this :
he was saying " if many orders opened at one second. For select really last order use this code " :
now I see similarity between two set of codes
to solving " multiple orders opened in 1 second " what do you think I should do here ?
Your code does not open any orders.
Why are you doing this inside the loop?
Complete the loop and then do the check.
Your code does not open any orders.
Why are you doing this inside the loop?
Complete the loop and then do the check.
I know I simplified it so it wont get crowded
here is a sell EA based on our previous points
but as I sent the picture it's clear sometimes it opens 3 order within 1 second
but as I sent the picture it's clear sometimes it opens 3 order within 1 second
Read my post before yours, the one that you have quoted.
Use the styler to tidy up the code.