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.
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.
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;
}
Many thanks to you!! I will try this
Hey cruddiforth2c. I tried this but didn’t work. I got an error. Which is :
'MagicNumber' - undeclared identifier
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,
Before int Ontick you must declare your magic number :
input int MagicNumber = 11223344;
Or whatever number you want