In the "Create Functions" form, click on "Add", then type the function name (Example: Test1) Select this function, click on "Add parameter" then Change "NoName" to "Param1" (In the first parameter line). We can now access the variable "Param1" in our script. Type the following script: for(int i=0;i < result.Length;i++) { result[i] = cFunctions.Close[i] - Param1[i]; } This script will simply loop through each trading bar and returns the close price minus the value specified in the first parameter of our function. Note that the function will return the "result" vector. Click on "Save" to compile and save the function. Now, we can access it using the vector-based language. Close the form, create a new pane in a chart (Right Click -> Create a new pane), then edit the pane formula (Right Click -> Edit formula). Type the following formula to display our function results: a = test1(10); plot(a, "");
|
![]() |