Thebattlefront Posted May 20, 2022 Report Share Posted May 20, 2022 (edited) Hello, I was wondering if it were possible to use a system-defined indexed variable as an argument to a function. For example, this function: //----------------------------------------- lowest function private double Lowest(double Value, int candle_Start, int candle_End) { double a = Min(candle_Start, candle_End, Value); return a; } Returns an error because the variable "Value" is not an indexed variable. In this context, I'd like the variable "Value" to be one of either Close, Low, or High (something that is inherently an indexed variable) but I'm not sure how to declare the variable type in the function's argument. I know it's not double, but I don't know what exactly the variable type it is. So an example of how I want this function to work is: Lowest(Close, 0, 4) Will return the lowest value of the close from day 0 to day 4. Edit: I understand I can separate the function definitions to be LowestClose(candle_start, candle_End) and LowestHigh(), LowestLow() etc but I'd like for the function to be more dynamic if I could make it that way because It allows for less repetition. Edited May 20, 2022 by Thebattlefront Quote Link to comment Share on other sites More sharing options...
Mike Medved Posted May 21, 2022 Report Share Posted May 21, 2022 Unfortunately no. The pre-processor does some "magic" to convert Min(1, 10, Close) to Close.Min(1, 10, (i, x) => { return Close; }); It needs an indexed variable as that third parameter otherwise it's a problem. You cannot even pass Close to the function as an IndexedPropertyDouble variable because the preprocessor converts Close to Close[0], and that breaks things. Basically it is the convenience of preprocessor sugar that spoils things... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.