Is there a way to store the same variable for a min and compore the current value?
You need a variable to store the old value, and another variable to remember when you stored it. You could use a structure if you prefer.
The variables need to be either static or globally-scoped.
Simple example:
static datetime OldTime = TimeCurrent();
if(TimeCurrent() >= OldTime + 300) // 300 seconds == 5 minutes
{
if(Ask > OldValue) Print("Current Ask price is greater than Ask price 5 minutes ago");
else Print("Current Ask price is less than or equal to Ask price 5 minutes ago");
OldValue = Ask;
OldTime = TimeCurrent();
}
You need a variable to store the old value, and another variable to remember when you stored it. You could use a structure if you prefer.
The variables need to be either static or globally-scoped.
Simple example:
static datetime OldTime = TimeCurrent();
if(TimeCurrent() >= OldTime + 300) // 300 seconds == 5 minutes
{
if(Ask > OldValue) Print("Current Ask price is greater than Ask price 5 minutes ago");
else Print("Current Ask price is less than or equal to Ask price 5 minutes ago");
OldValue = Ask;
OldTime = TimeCurrent();
}
Hi All,
I did some research but could not find what I need. Hence, I hope anyone can help me.
I am trying to store value A for X minutes until the value change and compare the current A value. So I am comparing a X min ago A value and the current value.
I am not looking for the current and previous bar value.
Any help is appreciated.