Posted By: laz
Strange problem with a global int - 02/22/19 03:37
I was just about to outsource my inputs to an external function, then I noticed something weird.
I define a global array + an int with the length of the array:
Something sets the global variable (IN TRAIN) to 0 after the LookBack period?
Removing the obL & obS solves the problem:
BUT renaming "myINP" to "INPUT" also solves the problem!?
The funny thing is, also renaming "myIPL" to "UHHHH" solves the problem!?
But what is the problem here?
I define a global array + an int with the length of the array:
Code:
//-------------------------------------------------------------------------------------------- #include <r.h> //-------------------------------------------------------------------------------------------- var myINP[3]; int myIPL = 3; //-------------------------------------------------------------------------------------------- int loadINP() { ////////////////////////////////////////////////// myINP[0] = 0; myINP[1] = 0; myINP[2] = 0; ////////////////////////////////////////////////// return(myIPL); ////////////////////////////////////////////////// } //-------------------------------------------------------------------------------------------- function run() { ////////////////////////////////////////////////// set(RULES); ////////////////////////////////////////////////// StartDate = 2015; EndDate = 2017; BarPeriod = 60; LookBack = 200; LifeTime = 3; Script = "DeepLearn"; // DeepLearn.r needed ////////////////////////////////////////////////// while(asset(loop("EURUSD"))) while(algo(loop("DeepLearn"))) { ////////////////////////////////////////////////// var obL = -1.0; var obS = -1.0; ////////////////////////////////////////////////// int ipc = loadINP(); if(Bar>=LookBack-5) watch("bar",Bar,"| myIPL",myIPL,"| ipc",ipc); ////////////////////////////////////////////////// var avL = adviseLong (NEURAL,obL,myINP,3); var avS = adviseShort(NEURAL,obS,myINP,3); ////////////////////////////////////////////////// if(Bar>=LookBack+5) quit(); ////////////////////////////////////////////////// } ////////////////////////////////////////////////// }
Something sets the global variable (IN TRAIN) to 0 after the LookBack period?
Code:
bar 195 | myIPL 3 | ipc 3 bar 196 | myIPL 3 | ipc 3 bar 197 | myIPL 3 | ipc 3 bar 198 | myIPL 3 | ipc 3 bar 199 | myIPL 3 | ipc 3 bar 200 | myIPL 3 | ipc 3 bar 201 | myIPL 0 | ipc 0 bar 202 | myIPL 0 | ipc 0 bar 203 | myIPL 0 | ipc 0 bar 204 | myIPL 0 | ipc 0 bar 205 | myIPL 0 | ipc 0 Quit
Removing the obL & obS solves the problem:
Code:
var avL = adviseLong (NEURAL,0,myINP,3); var avS = adviseShort(NEURAL,0,myINP,3); bar 195 | myIPL 3 | ipc 3 bar 196 | myIPL 3 | ipc 3 bar 197 | myIPL 3 | ipc 3 bar 198 | myIPL 3 | ipc 3 bar 199 | myIPL 3 | ipc 3 bar 200 | myIPL 3 | ipc 3 bar 201 | myIPL 3 | ipc 3 bar 202 | myIPL 3 | ipc 3 bar 203 | myIPL 3 | ipc 3 bar 204 | myIPL 3 | ipc 3 bar 205 | myIPL 3 | ipc 3 Quit
BUT renaming "myINP" to "INPUT" also solves the problem!?
The funny thing is, also renaming "myIPL" to "UHHHH" solves the problem!?
But what is the problem here?