Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
5 registered members (AndrewAMD, monk12, TipmyPip, Quad, aliswee), 1,029 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: Different result in main() and run() [Re: DisplayName] #487360
03/23/23 02:51
03/23/23 02:51
Joined: Mar 2023
Posts: 11
D
DisplayName Offline OP
Newbie
DisplayName  Offline OP
Newbie
D

Joined: Mar 2023
Posts: 11
In the end I want to have a call function which loads the external data and this should called only once and not in every run. That's why the (count!=1) part.
Here's my simple plan:
1) load the external data
2) Store it in an array
3) run the time series and compare the dates
4) build an indicator for the whole time period
5) plot it

So, ist there a way to get no.3 done?

Can anyone explain, why I am losing one array entry per run?

Code
int count;
int cnt;
vars MySeriesArrayX; 
vars MySeriesArrayY;
function run()
{
	MySeriesArrayX=series(); 
	MySeriesArrayY=series(); 
	int date;
	int x;
	if (cnt<7){
		if (count!=1){
			if (!Init){
				
				for(x=0; x<5; x++) {
					MySeriesArrayX[x] = 20220101+x;
					MySeriesArrayY[x] = x+0.1;
				}	
				count=1;
			}
		}
		if(count==1){
			int i;
			for(i=0; i<5; i++){				
				date = MySeriesArrayX[i];
				printf("\n date: %d",date);
				printf("\n number: %f",MySeriesArrayY[i]);
			}
		}
		cnt++;
	}
}


Last edited by DisplayName; 03/23/23 11:31.
Re: Different result in main() and run() [Re: DisplayName] #487363
03/23/23 12:48
03/23/23 12:48
Joined: Feb 2017
Posts: 1,718
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,718
Chicago
What kind
Originally Posted by DisplayName
In the end I want to have a call function which loads the external data and this should called only once and not in every run.

What exactly is this data? Is it price data? Is it just an indicator? Is it saved to disk? Is it a timeseries? Do you simply need the latest value in the timeseries relative to the timestamp of the current bar?

The answers to these questions will affect my recommendation. There's a 90% chance your approach is sub-optimal in the first place.

Re: Different result in main() and run() [Re: AndrewAMD] #487364
03/23/23 13:32
03/23/23 13:32
Joined: Mar 2023
Posts: 11
D
DisplayName Offline OP
Newbie
DisplayName  Offline OP
Newbie
D

Joined: Mar 2023
Posts: 11
I collect montly data from the web.
This already works. I have the date and the published data. I don't want to make a new web request with every run.
For example for 2022 I have an array with 12 * date information and an array with 12 * published data.

Then I have the daily stock time series.

My indicator should start with 0 and when the daily time stamp equals the montly time stamp the indicator gets the value of the published data from this day until the next dates match.

Last edited by DisplayName; 03/23/23 14:49.
Re: Different result in main() and run() [Re: DisplayName] #487365
03/23/23 15:01
03/23/23 15:01
Joined: Feb 2017
Posts: 1,718
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,718
Chicago
The Zorro way:

1) In a separate script, download and convert the historical data to a dataset, and save it to t1 or t6 file. This goes in your History folder.
2) Then make an asset list with the stock data you downloaded and the asset you plan on trading.
3) In your trading script: load your asset list and call the stock asset to get its data. Then when you're ready to trade, change to the trading asset.

Re: Different result in main() and run() [Re: DisplayName] #487366
03/23/23 15:37
03/23/23 15:37
Joined: Mar 2023
Posts: 11
D
DisplayName Offline OP
Newbie
DisplayName  Offline OP
Newbie
D

Joined: Mar 2023
Posts: 11
Ok, thank you this is worth a try. But, sorry I don't get it.

For example if I want to trade daily SPY and download montly unemployed data.
Then I store this data in a mud.t6 file.

My asset list contains "SPY" and "MUD"??

Asset("SPY");

I do not understand how to call the 'MUD'-Asset or the mud.t6 file.

Last edited by DisplayName; 03/23/23 16:43.
Re: Different result in main() and run() [Re: DisplayName] #487374
03/24/23 16:07
03/24/23 16:07
Joined: Mar 2023
Posts: 11
D
DisplayName Offline OP
Newbie
DisplayName  Offline OP
Newbie
D

Joined: Mar 2023
Posts: 11
Now I am at this specific point.

First try, I wrote an extra mud.t6 file which I wish to import additionally with the asset file.
Is this possible?

Second try, I created an new asset with my data in the 'Vol'-column.
Is this what you meant?
Unfortunately for this zorro s is required.

So is there a way to import additional data or only as Val or Vol with zorro s subscription?

Re: Different result in main() and run() [Re: DisplayName] #487376
03/24/23 17:19
03/24/23 17:19
Joined: Apr 2008
Posts: 585
Austria
Petra Offline
Support
Petra  Offline
Support

Joined: Apr 2008
Posts: 585
Austria
Store the data in a dataset. Its file name is not relevant. You need no Zorro S for handling data.

For unemployment data, I think you need a dataset with only 2 fields, one for the date and one for the data.

https://zorro-project.com/manual/en/data.htm

Re: Different result in main() and run() [Re: DisplayName] #487380
03/24/23 20:16
03/24/23 20:16
Joined: Mar 2023
Posts: 11
D
DisplayName Offline OP
Newbie
DisplayName  Offline OP
Newbie
D

Joined: Mar 2023
Posts: 11
This was exactly the part of the manual I used for downloading, but for some reason I missed dataSave and dataLoad, these are the commands I needed.
I think it's going to work now.

1000 times thank you AndrewAMD and Petra.

Page 2 of 2 1 2

Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1