Try this code:
//+------------------------------------------------------------------+ //| Previous Force.mq5 | //| Copyright 2013, MetaQuotes Software Corp. | //| http://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2013, MetaQuotes Software Corp." #property link "http://www.mql5.com" #property version "1.00" //+------------------------------------------------------------------+ //| Script program start function | //+------------------------------------------------------------------+ void OnStart() { //--- int ForcePeriod = 14; double myForce[]; ArraySetAsSeries(myForce,true); int ForceHandle=iForce(NULL,0,ForcePeriod,MODE_SMA,VOLUME_TICK); if(CopyBuffer(ForceHandle,0,0,3,myForce)<0) { Alert("Error copying Force indicator buffer - error:",GetLastError()); ResetLastError(); return; } Print("Previously closed bar Force = ", DoubleToString(myForce[1],_Digits), " Current Force = ", DoubleToString(myForce[0],_Digits)); } //+------------------------------------------------------------------+
Do you see where the change?
in
if(CopyBuffer(ForceHandle,0,0,3,myForce)<0)
YES !!! Thanks a lot this did the trick :)
Phi.nuts
Yes you are right I was missing the ArraySetAsSeries

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
Hi All,
I have trouble applying a condition to the iForce value of the previously closed candle. Below you will find how I get the force variables.
I tried printing myForce[0], myForce[1] and myForce[2] but myForce[0] corresponds to two candles in the past and not the previously closed candle.
Changing the ForceHandle to us 0,0,3 returns a myForce[0] that does not correspond to anything : (
Let me know if I'm not clear and thank you for your help!