This forum is in read-only mode now. You may discuss your questions on forums of MQL4.community and MQL5.community
previous value of indicator ?Back to topics list |
|
maestrade
2005.05.23 17:29
At this step , I have :
double var double var1 var = Formula; now I want to have var1 = previous value of Formula If Formula was an Array such as High I would just write var1 = High[1] But writing var1 = Formula[1] is not recognized. who could help ? Thanks In general, the question is : how to transform the value of a formula into an Array |
|
pedfx
2005.05.27 17:01
Hi maestrade,
This would not work. If you are coding a formula it will only return a single value so you would just reference as normal variable not as an array ie[]. If you want to return an array as your formula you would need to create a function or loop to build the array, then you could reference it as an array. Here is an example of a funciton
bool GetArray( double& anArray[])
{
for (i = bars; i >= 0; i--)
{
anArray[i] = some formula;
}
}
// now you could call
double myArray[100];
GetArray(myArray);
double val = myArray[1];
|
|
EmeraldKing
2005.05.27 18:05
Hello Maestrade,
Try this double var; double var1; var1 = var; var = Formula;
At this step , I have : double var double var1 var = Formula; now I want to have var1 = previous value of Formula If Formula was an Array such as High I would just write var1 = High[1] But writing var1 = Formula[1] is not recognized. who could help ? Thanks In general, the question is : how to transform the value of a formula into an Array |
|
maestrade
2005.05.29 00:42
Pedro,
Thanks for your time Unfortunately your suggestion does not work at all. First, the way you define the function is not proper. If you think it works, could you write the code for MACD using the sample given by Metaquotes How to get the previous value of the MACD or better the value of the MACD n bars before ? |
Download MetaTrader 5 (450 Kb, web installer) — a new terminal for financial markets
