Trying to capture the current closed price
Does anyone know how to capture the current closed price? I'm writing an EA program and I assumed that the current closed price was contained within the below but I was wrong.
Why not just use:
Close[0]
Not sure what you mean by Close[0]. What function does that belong to?
Close[0] has no value it's always open so you check Close[1]
double close=Close[1]; //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { if(close!=Close[1]) { Print(" New close: ",close); close=Close[1]; } } //+------------------------------------------------------------------+
Close[0] has no value it's always open so you check Close[1]
yes i mean the candle is always open i thought he needed the close price of candle [0] which can only be taken from [1] after [0] has closed.
yes i mean the candle is always open i thought he needed the close price of candle [0] which can only be taken from [1] after [0] has closed.
Yeah I'm not sure what he's trying to capture to be honest, think we need more info from the OP.......
Thanks for the feedback. I really do appreciate it and what I am trying to do is capture the most current close. I played around with the below but it doesn't give me any numbers to the right of the decimal with is not very helpful. Also do I have to hard-code the symbol? Thoughts?
double myClose[]; double LastClose = CopyClose("EURUSD", 1, 0, 1, myClose);
start position 1 and data count to copy 0 ?
maybe you can switch them.
int OnInit() { CloseHandle=CopyClose("EURUSD", 1, 0, 32, CloseArray); if(CloseHandle==INVALID_HANDLE) { Print(" Was not possible to recieve handle of Close"); return(INIT_FAILED); } } double ArrayTotal; double ArrayAverage; void OnTick() { ArrayTotal =0.0; for(int x=0; x<32; x++) { ArrayTotal+=CloseArray[x]; } ArrayAverage=ArrayTotal/32; double AskBuy = ArrayAverage - .00051; double AskSale = ArrayAverage + .00051; Print("-- "); Print("Buy Array Average = ",NormalizeDouble(ArrayAverage,_Digits)); Print("Buy Last Close = ",NormalizeDouble(CloseArray[0],_Digits)); Print("-- "); }
Does anyone know how to capture the current closed price? I'm writing an EA program and I assumed that the current closed price was contained within the below but I was wrong.