| / | Forum |
|
bar4ka
2006.04.09 05:56
I would like to implement a library function that can modify a given value passed
as parameter.
This is a Test Case for what i am looking for:
I would like that the output would be:
But currently the output is Mydouble: 1 in both Prints |
|
Forecasting Financial Time-Series Forecasting financial time-series is a required element of any investing activity. The concept of investing itself - put up money now to gain profits in future - is based on the concept of predicting the future. Therefore, forecasting financial time-series underlies the activities of the whole investing industry - all organized exchanges and other securities trading systems. |
|
CockeyedCowboy
2006.04.10 12:07
bar4ka
The problem you encountered is that a variable is only visible to the function that is described in that includes the start function. If you want all function to see a variable you must decleare it as a global scope variable out side of any function discription (see type A below), or pass it by referance (see type B below). Decleare the veriable mydouble out side of any function discription will make it a global variable. If you add the & in the function pamater discription it will change the value of the variable pased it. Also; It is not required with functions that don't return any values, but good coding style to use the return statement at the end of all function even if they return nothing as in a sub routine procedure. type A using global scope variable
Type B passing by referance.
The CockeyedCowboy bar4ka: I would like to implement a library function that can modify a given value passed as parameter. This is a Test Case for what i am looking for:
I would like that the output would be:
But currently the output is Mydouble: 1 in both Prints |
|
RickD
2006.04.15 00:00
Another way is:
|
|
bar4ka
2006.04.15 03:46
CockeyedCowboy: Despite my Test case use only one parameter in reality i need to pass a lot of parameters,
so the & solves my problem.bar4ka If you add the & in the function pamater discription it will change the value of the variable pased it. Also; It is not required with functions that don't return any values, but good coding style to use the return statement at the end of all function even if they return nothing as in a sub routine procedure. Type B passing by referance.
Does mql has any support for composite types like c struct, pascal record, or even a class ? |
|
CockeyedCowboy
2006.04.16 00:09
bar4ka MQL dosnot to my knoweladge support composite / class types, directly. You can simulate that effect with some code tricks. More work then its worth I think. What is it your trying to acheive. MQL doesnot support Sub Routine Procedures ( only Function Precedures ). However, if you view a function that returns nothing, but performs a duty, as a sub routine then you can create sub routines (functions) that have the ability to alter a large number of variables ( global scope ) with ease. Here is an example of a call to a sub routine to open orders ( pending or market ) were all you have to pass it is the order type you want and the price to establish it. So instead of using the OrderSend( ) function and passing it all the parameters you just have to place EstablishPosition( ordertype, price ); and the sub routine procedure will place your order. This is done because all the parameters to establish an order have been defind as global scope type. The Parameters by the way have been set in another sub routine InstituteNewCampaign( ordertype ); before hand. This is all acheived buy using global scope variables were needed in your code along with Sub Routine Precedures with in your code. The code below is taken from an EA I am currently working on, and is only an example of what can be done. code:
The CockeyedCowboy bar4ka:
CockeyedCowboy: Despite my Test case use only one parameter in reality i need to pass a lot of parameters,
so the & solves my problem.bar4ka If you add the & in the function pamater discription it will change the value of the variable pased it. Also; It is not required with functions that don't return any values, but good coding style to use the return statement at the end of all function even if they return nothing as in a sub routine procedure. Type B passing by referance.
Does mql has any support for composite types like c struct, pascal record, or even a class ? |