How to get the nearest Bid price (to the current Bid price) ?
Hi RaptorUK, thanks for your attention, but you mistook my idea,
if you assign "x=Bid;"
The variable x just stores the value of the newest Bid price.
How to get the value of the previous Bid price (the bid price just beside the current quote)
Example:
If at 00:00:00 there is a price quote, with Bid=1645.25
and then, 2 seconds later, at 00:00:02, a new quote comes, with Bid=1645.31
I want a function as this: if called at 00:00:02 it returns 1645.25, instead of 1645.31
I hope you get my idea, and can help me.
I want a function as this: if called at 00:00:02 it returns 1645.25, instead of 1645.31
There is no such a built-in function, I think Raptor's variable is the best you can do, like this:
double PrevBid; // a globally defined variable keeps it's value between ticks int init() { PrevBid = 0.0; // ... return(0); } int start() { if (PrevBid == 0.0) { PrevBid = Bid; return(0); } // here you can use Bid and PrevBid // ... PrevBid = Bid; return(0); }
int start() { static double PrevBid; if (PrevBid == 0.0) { PrevBid = Bid; return(0); } // here you can use Bid and PrevBid // ... PrevBid = Bid; // Update for next tick. return(0); }
I agree with Raptor's idea as explained and expounded upon by erzo and WHRoeder.
I might also suggest that you could use an array to store several (your choice on the size of "several") past bid prices.
Or use a static
Thanks to all,
I do know how !
We use "Bid" to get the current bid price of every quote
So, How to get the previous bid price ?
Thanks for your guide !