Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/28/24 09:55
basik85278
by basik85278. 04/28/24 08:56
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (blaurock), 750 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 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,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
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