AFL Code Error Problem

Short = (Sequence == 132) OR
(Sequence == 332) OR
(Sequence == 232) OR
(Sequence == 231) OR
(Sequence == 221) OR
(Sequence == 322) OR
(Sequence == 333) OR
(Sequence == 133) OR
(Sequence == 122);
Cover = BarsSince(Short) >= 1;
/
/

// 15% Cutoff -- strongest sequences
Buy = (Sequence == 111) OR

This section of code come from page 175 in Quantitative Trading Systems. According to the AFL Editor the */ syntax is wrong. However this is exactly how it is listed in the book. Any thoughts?

Just delete those front slash characters.

1 Like

If he deletes the double //, he may end up uncommenting some lines.

instead, change the / to //, its code to comment out a line so the AFL doesnt interpret it as code.

the line // 15%.... is an example of a comment.

1 Like

@Floridafan if you post some code WITHOUT using the REQUIRED code tags what is displayed may be different from the original code1 so that readers may not be able to understand your request correctly.
(Please, review the Enter the AFL code properly section)

The original @howardbandy code is as follow:

//==============================================
//	----Block of code in use when testing as a trading system
//	When testing, uncomment one set of sequences.
//	Buy the strong patterns,
//	short the weak patterns.
/*
//	33% Cutoff -- Strongest sequences
Buy = (Sequence == 111) OR
		(Sequence == 223) OR
		(Sequence == 323) OR
		(Sequence == 311) OR
		(Sequence == 313) OR
		(Sequence == 213) OR
		(Sequence == 131) OR
		(Sequence == 331) OR
		(Sequence == 113);
Sell = BarsSince(Buy) >= 1;
//	33% Cutoff -- Weakest sequences
Short = (Sequence == 132) OR
		(Sequence == 332) OR
		(Sequence == 232) OR
		(Sequence == 231) OR
		(Sequence == 221) OR
		(Sequence == 322) OR
		(Sequence == 333) OR
		(Sequence == 133) OR
		(Sequence == 122);
Cover = BarsSince(Short) >= 1;
*/
/*
//	15% Cutoff -- strongest sequences
Buy = (Sequence == 111) OR
		(Sequence == 211) OR
		(Sequence == 311) OR
		(Sequence == 121) OR
		(Sequence == 112) OR
		(Sequence == 223) OR
		(Sequence == 131) OR
		(Sequence == 113) OR
		(Sequence == 221);
Sell = BarsSince(Buy) >= 1;
//	15% Cutoff -- weakest sequences
Short = (Sequence == 333) OR
		(Sequence == 331) OR
		(Sequence == 332) OR
		(Sequence == 132) OR
		(Sequence == 232) OR
		(Sequence == 133) OR
		(Sequence == 233) OR
		(Sequence == 123) OR
		(Sequence == 313);
Cover = BarsSince(Short) >= 1;
*/
/*
//	Long only -- strongest single sequence
Buy = (Sequence == 111);
Sell = BarsSince(Buy) >= 1;
*/

As clearly stated in the comment, at the top, you are supposed to UNCOMMENT one of the section when testing the entire formula as a trading system.

This means to remove the /* at the beginning of a commented area of code and the corresponding */ at the end of it.

So if you want to use a 15% cutoff, you'll change the block of code as:

//==============================================
//	----Block of code in use when testing as a trading system
//	When testing, uncomment one set of sequences.
//	Buy the strong patterns,
//	short the weak patterns.
/*
//	33% Cutoff -- Strongest sequences
Buy = (Sequence == 111) OR
		(Sequence == 223) OR
		(Sequence == 323) OR
		(Sequence == 311) OR
		(Sequence == 313) OR
		(Sequence == 213) OR
		(Sequence == 131) OR
		(Sequence == 331) OR
		(Sequence == 113);
Sell = BarsSince(Buy) >= 1;
//	33% Cutoff -- Weakest sequences
Short = (Sequence == 132) OR
		(Sequence == 332) OR
		(Sequence == 232) OR
		(Sequence == 231) OR
		(Sequence == 221) OR
		(Sequence == 322) OR
		(Sequence == 333) OR
		(Sequence == 133) OR
		(Sequence == 122);
Cover = BarsSince(Short) >= 1;
*/

//	15% Cutoff -- strongest sequences
Buy = (Sequence == 111) OR
		(Sequence == 211) OR
		(Sequence == 311) OR
		(Sequence == 121) OR
		(Sequence == 112) OR
		(Sequence == 223) OR
		(Sequence == 131) OR
		(Sequence == 113) OR
		(Sequence == 221);
Sell = BarsSince(Buy) >= 1;
//	15% Cutoff -- weakest sequences
Short = (Sequence == 333) OR
		(Sequence == 331) OR
		(Sequence == 332) OR
		(Sequence == 132) OR
		(Sequence == 232) OR
		(Sequence == 133) OR
		(Sequence == 233) OR
		(Sequence == 123) OR
		(Sequence == 313);
Cover = BarsSince(Short) >= 1;

/*
//	Long only -- strongest single sequence
Buy = (Sequence == 111);
Sell = BarsSince(Buy) >= 1;
*/

From the AFL Reference Manual:

Comments

Comments are pieces of text used to annotate a program. Comments are for the programmer's use only; they are stripped from the source code before parsing. The are two ways to delineate comments: C-like comments and C++ like comments. A C-like comment is any sequence of characters placed after the symbol pair /*. The comment terminates at the first occurrence of the pair / following the initial /. The entire sequence, including the four comment-delimiter symbols, is replaced by one space. A C++ like comments are single-line comments that start by using two adjacent slashes (//) in any position within the line and extend until the next new line.

AFL does not allow nested comments.

I want to thank here @howardbandy who kindly provides the source code of his very useful books, so I did not have to retype anything!
(The above code "brief quotation" is under Copyright © 2007, 2011 by Howard B. Bandy).


1) The absence of the code tags, in combination with particular characters sequences (commonly found in a piece of source code), could result in a "rendered" text where some characters are missing.

4 Likes

Thank you! That was very helpful. I actually had not attempted to run the code yet, I was utilizing the AFL Check to make sure I had no typo errors in the code. So when the error appeared I did not corelate the issue to the code running as a Program, just that I had a typo.
I believe that the consensus is that the error code is due to not "un-commenting" a portion of the code, and not an error in my actual code entry.

Greetings --

The code posted is the result of a study that was done ten years ago. Two points are important.

  1. Read the description of the study and replicate it using current data.
  2. Be aware that systems based on patterns such as these are easily overfit. Be sure to save some data for out-of-sample validation testing. The OOS data should be more recent than the in-sample data that was used to determine the patterns, and it should be used sparingly. Every iteration of "fit followed by OOS test followed by refit" contaminates the value of the out-of-sampleness and reduces the likelihood that future results will be similar to the OOS results.

Best, Howard

3 Likes