Hello everyone! I need help :)
How to implement this to an advisor.
If ( 5 minutes have passed since the last position was opened )
Do this
Else
Dont
Thanks for your interest.
- Simple question about RSI
- Need help !
- Need Help with simple Expert Advisor
int OnTick() { // if(LastOrderTime()+5*60<=TimeCurrent()) { //Do This } else { //Do } return 0; } datetime LastOrderTime() { datetime time; for(int i=OrdersTotal()-1; i>=0; i--) { if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES))continue; if(OrderSymbol()==_Symbol && OrderMagicNumber()==MagicNumber) { time=OrderOpenTime(); break; } } return time; }
Mehrdad Jeddi:
Many thanks to you!! I will try this
Hey Mehrdad. I tried this but didn't work. I got an error. Which is :
'MagicNumber' - undeclared identifierDo you know why and how to fix this. Thanks for your help :)
apleasewouldbenice boom:
Before int Ontick you must declare your magic number : Hey guys I need help. I get magic number error which is :
I dont know how to fix this.
Here is my whole code :
Thanks for your interest :) Have a good day.
input int MagicNumber = 11223344;
Or whatever number you want
apleasewouldbenice boom:
Hey Mehrdad. I tried this but didn't work. I got an error. Which is :
Do you know why and how to fix this. Thanks for your help :)So this is a custom global variable that you would define it in your code for example :
int MagicNumber=12345;
The orders will be detected by their Magic Number,
apleasewouldbenice boom:
Do not double post.
I have deleted your other topic and moved the reply to here.
Many thanks to Mehrdad Jeddi and Catalin Zachiu :)
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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