Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
0 registered members (), 666 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, 11honza11, ccorrea, sakolin, rajesh7827
19046 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Strange problem with a global int #476391
02/22/19 03:37
02/22/19 03:37
Joined: Jan 2019
Posts: 73
berlin
L
laz Offline OP
Junior Member
laz  Offline OP
Junior Member
L

Joined: Jan 2019
Posts: 73
berlin
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:

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?

Attached Files
input-array-crash000.c (23 downloads)
input-array-crash001.c (31 downloads)
Last edited by laz; 02/22/19 04:20.
Re: Strange problem with a global int [Re: laz] #476394
02/22/19 07:48
02/22/19 07:48
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
That's indeed a strange problem. Maybe some internal variable has the same name. We'll look into it.

- It was a bug in NEURAL_LEARN. Had nothing to do with the variable name. This will be fixed in the next update. Workaround: Increase the input array by 1 element, because NEURAL_LEARN stores the objective at the end.

var myINP[4];
...


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1