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
2 registered members (Quad, aliswee), 835 guests, and 5 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 1 of 2 1 2
ISSUE: Recursive series() - Undeclared Identifier #472660
05/12/18 02:45
05/12/18 02:45
Joined: May 2018
Posts: 7
California, United States
orangutanical Offline OP
Newbie
orangutanical  Offline OP
Newbie

Joined: May 2018
Posts: 7
California, United States
Greetings!

How would one go about transcribing this piece of EasyLanguage code into Lite-C? I have tried a few things with series, however, I am getting an "Undeclared Identifier" error.

EasyLanguage:

Vars: MySeries(0);

MySeries = MySeries[1] + MySeries[2];


Lite-C Attempt:

vars MySeries = series(MySeries[1] + MySeries[2]);

This produces an error ^^

Last edited by orangutanical; 05/12/18 04:13.
Re: ISSUE: Recursive series() - Undeclared Identifier [Re: orangutanical] #472684
05/14/18 08:25
05/14/18 08:25
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
I don't think that this works in any language. If you want a series, first make up your mind what this series shall contain. Only when you know that, you can add up elements.

Re: ISSUE: Recursive series() - Undeclared Identifier [Re: jcl] #472687
05/14/18 12:19
05/14/18 12:19
Joined: Sep 2017
Posts: 235
H
Hredot Offline
Member
Hredot  Offline
Member
H

Joined: Sep 2017
Posts: 235
Try

vars MySeries = series(0.);
MySeries[0] = MySeries[1] + MySeries[2];

Re: ISSUE: Recursive series() - Undeclared Identifier [Re: Hredot] #472701
05/15/18 06:14
05/15/18 06:14
Joined: May 2018
Posts: 7
California, United States
orangutanical Offline OP
Newbie
orangutanical  Offline OP
Newbie

Joined: May 2018
Posts: 7
California, United States
I realized how to reframe my question. In Zorro, there are Finite Impulse Response (FIR) Filters. I want to find a way to write Infinite Impulse Response (IIR) Filters, or recursive filters. These types rely on their past outputs to calculate current values. Programmatically, I’ve seen this done in EasyLanguage. However, in terms of Lite-C, how would one go about writing a IIR Filter? I know JCL would probably know because this is a DSP question.

Thank you again for any assistance!

Also, thnx Hredot, that was one of the things I tried. I will try it again, maybe I made a mistake.

Last edited by orangutanical; 05/15/18 06:15.
Re: ISSUE: Recursive series() - Undeclared Identifier [Re: orangutanical] #472716
05/15/18 18:57
05/15/18 18:57
Joined: May 2018
Posts: 7
California, United States
orangutanical Offline OP
Newbie
orangutanical  Offline OP
Newbie

Joined: May 2018
Posts: 7
California, United States
Here is the program that I am trying to recreate, just so you can see that it is a program that should work and does in EasyLanguage.

This is the Lite-C attempt (see attachment), it causes the error: "Error 111: Crash in script: run()".


Attached Files
Code.jpg (12 downloads)
CyberCycle.c (11 downloads)
Last edited by orangutanical; 05/15/18 19:00.
Re: ISSUE: Recursive series() - Undeclared Identifier [Re: orangutanical] #472718
05/15/18 20:15
05/15/18 20:15
Joined: Feb 2017
Posts: 1,718
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,718
Chicago
Do not invoke series() from global.

http://zorro-trader.com/manual/en/series.htm
Quote:
An internal counter determines the pointer to be returned by a series() call. Therefore, series can only be created in the run function or in a function that is called from the run function; and they must be always created in the same order. Thus series calls must not depend on if or any other condition that can change from bar to bar (see example below). These requirements also apply to all functions that internally create series, such as some indicator or signal processing functions. Zorro detects wrong series calls and will display an error message in this case.


In fact, you are assigning two different series to the same vars. This is pointless.

Also, it's not really clear what you are trying to do.

Re: ISSUE: Recursive series() - Undeclared Identifier [Re: AndrewAMD] #472723
05/15/18 21:55
05/15/18 21:55
Joined: May 2018
Posts: 7
California, United States
orangutanical Offline OP
Newbie
orangutanical  Offline OP
Newbie

Joined: May 2018
Posts: 7
California, United States
If you are familiar with the work of John Ehlers, he tends to utilize IIR filters. I am simply trying to create an IIR filter, or a filter that has an output dependent upon past outputs. I know it kind of sounds like a paradox, however, I know it is a very common concept in DSP. Thank you for this advise, I will try this without a global series.

EDIT: Perhaps, to be ultra clear. Here is the literal code from the book in EasyLanguage format. I am not quite sure what to make of the "currentbar", I haven't wrapped my head around what would be similar in Lite-C. This code works as EasyLanguage in TradeStation 9.5. BTW, it is a really cool indicator, when it is working properly. It is able to detect the turning points in price quite quickly. (See attachment)

Attached Files
CyberCycle.txt (7 downloads)
Last edited by orangutanical; 05/15/18 22:20.
Re: ISSUE: Recursive series() - Undeclared Identifier [Re: orangutanical] #472724
05/15/18 22:59
05/15/18 22:59
Joined: Feb 2017
Posts: 1,718
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,718
Chicago
Originally Posted By: orangutanical
I know it kind of sounds like a paradox
Does this look like a paradox? wink
Code:
/*
 * John F. Ehlers
 * Cybernetic Analysis for Stocks & Futures
 * Chp. 4 ~ Fig. 4.2 ~ "Cyber Cycle"
 */

function main() {
	// Backtest Settings
	StartDate = 20180415;	
	EndDate = 20180515;	
	LookBack = 200;
}

function run() {
	vars Price = series((priceHigh() + priceLow()) / 2);
	vars Smooth = series((Price[0] + 2*Price[1] + 2*Price[2] + Price[3]) / 6);
	var alpha = 0.07;
	vars Cycle = series(0);
	Cycle[0] = 
		(1 - 0.5*alpha)*(1 - 0.5*alpha)*(Smooth[0] - 2*Smooth[1] + Smooth[2]) 
		+ 2*(1 - alpha)*Cycle[1] 
		- (1 - alpha)*(1 - alpha)*Cycle[2];
	// Plot Results
	set(PLOTNOW);
	plot("Cycle", Cycle[0], NEW, 0xcc0000);
	plot("Trigger", Cycle[1], 0, 0x0000cc);
}

Currentbar is probably just some form of lookback.

Re: ISSUE: Recursive series() - Undeclared Identifier [Re: AndrewAMD] #472726
05/16/18 00:19
05/16/18 00:19
Joined: May 2018
Posts: 7
California, United States
orangutanical Offline OP
Newbie
orangutanical  Offline OP
Newbie

Joined: May 2018
Posts: 7
California, United States
Nice, man! Thank you so much. This seems to be more like its behavior. The only thing it is lacking is that smoothing for the "currentbar < 7" rule, I think. Forgive the novice, eh? Also, enjoy! Note: Try playing with the alpha variable. A value of 0.5 makes it a bit more pointed.

Last edited by orangutanical; 05/16/18 00:24.
Re: ISSUE: Recursive series() - Undeclared Identifier [Re: orangutanical] #472727
05/16/18 00:40
05/16/18 00:40
Joined: Feb 2017
Posts: 1,718
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,718
Chicago
I can tell by reading it that it is designed for when you are at a super-low lookback period, as it does not account for alpha.

So you should ignore that since you already have 200 lookback.

I still have an Ehlers book on my shelf that I need to read. I will need all of its juicy context before I start playing around with these types of code.

Page 1 of 2 1 2

Moderated by  Petra 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1