Scan Code Error

I'm learning Optima script and I've made a scanner code. As far as I can tell, I followed all the syntax rules; but I'm getting an error that its not a valid script.

1. In calculating "Y" for the slope of the signal line, the second MA has to be "X" bars back from the first MA. I notated that close as "close[X]" to mean the close of the bar 5 bars in the past. Is this the correct syntax?

2. As for the rest of the code, I don't know what could be wrong with it. Can anyone see an error with it?

// Wavy Tunnel Breakout #1 Scanner //==================================================================================
// ==================================
// Raghee Wave
// ==================================
EMA34H = MA(BARS=34, STYLE=Exponential, CALC=High);
EMA34C = MA(BARS=34, STYLE=Exponential, CALC=Close);
EMA34L = MA(BARS=34, STYLE=Exponential, CALC=Low);
// ==================================
// Vegas Tunnel
// ==================================
EMA12 = MA(BARS=12, STYLE=Exponential, CALC=Close); //Signal Line
EMA144 = MA(BARS=144, STYLE=Exponential, CALC=Close);
EMA169 = MA(BARS=169, STYLE=Exponential, CALC=Close);
// =========================================
// Slope Of Signal Line
// =========================================
X = 5;
Y = MA(STYLE=Exponential, BARS=12, CALC=Close) - MA(STYLE=Exponential, BARS=12, CALC=Close[X]) ;
MA1 = MA(BARS=8, CALC=HLC/3);
MA2 = MA(BARS=8, CALC=Close);
// =========================================
// Buying Criteria
// =========================================
Criteria1 = ArcTan(Y/X) * 180 / Pi >= 1;
Criteria2 = EMA12 Crosses Above Max(EMA144,EMA169);
Criteria3 = EMA12 Crosses Above Max(EMA34H,EMA34L);
Criteria4 = Max(EMA34H,EMA34L) Crosses Above Max(EMA34H,EMA34L);
Criteria5 = Max(EMA34H,EMA34L) Crosses Above Max(EMA144,EMA169);

Criteria1 And (Criteria2 Or Criteria3 Or Criteria5); // Scan Output

Wavy-Tunnel-BO-1-Scan-OGT-1.txt (1.35 KB)

Hi David,

Looking at your script it looks like the syntax used to setup the bar variables X and Y are incorrect.

For information on how to set up bar variables in Optuma’s scripting please refer to the following article:

https://help.optuma.com/kb/faq.php?id=964

Thanks for your reply,

I changed my X and Y variables to the following, but I still have the same error.

<pr>
// =========================================
// Slope Of Signal Line
// =========================================
#$X = 5;
#$Y = MA(STYLE=Exponential, BARS=12, CALC=Close) - MA(STYLE=Exponential, BARS=17, CALC=Close) ;
// =========================================
// Buying Criteria
// =========================================
Criteria1 = ArcTan(#$Y/#$X) * 180 / Pi >= 1;
</pr>

 

Hi David,

There’s a few issues with the Syntax remaining:

  • There is no function in Optuma scripting for Pi
  • HLC/3 is not a valid calc style of the MA() function
  • The variable for ARCTAN() needed to be setup differently.
The following is adjusted code which takes out these items, it may not be exactly what you're after but should give you a good base to work off:
// Wavy Tunnel Breakout #1 Scanner //==================================================================================
// ==================================
// Raghee Wave
// ==================================
EMA34H = MA(BARS=34, STYLE=Exponential, CALC=High);
EMA34C = MA(BARS=34, STYLE=Exponential, CALC=Close);
EMA34L = MA(BARS=34, STYLE=Exponential, CALC=Low);
// ==================================
// Vegas Tunnel
// ==================================
EMA12 = MA(BARS=12, STYLE=Exponential, CALC=Close); //Signal Line
EMA144 = MA(BARS=144, STYLE=Exponential, CALC=Close);
EMA169 = MA(BARS=169, STYLE=Exponential, CALC=Close);
// =========================================
// Slope Of Signal Line
// =========================================
$X = 5;
X1 = 5;
Y = EMA12 - OFFSET(EMA12, OFFSET=$X);
MA1 = MA(BARS=8, CALC=HLC);
MA2 = MA(BARS=8, CALC=Close);

// =========================================
// Buying Criteria
// =========================================
Criteria1 = ArcTan(Y/X1) * 180 / 3.141596 >= 1;
Criteria2 = EMA12 CrossesAbove Max(EMA144,EMA169);
Criteria3 = EMA12 CrossesAbove Max(EMA34H,EMA34L);
Criteria4 = Max(EMA34H,EMA34L) CrossesAbove Max(EMA34H,EMA34L);
Criteria5 = Max(EMA34H,EMA34L) CrossesAbove Max(EMA144,EMA169);

Criteria1 And (Criteria2 Or Criteria3 Or Criteria5); // Scan Output


 

Thank you for your help. There are no errors now.

I’ve added a few more criteria to my scanner and I’m in need to add a fundamental to one more of them. Although I have a number of technical criteria, I also need to be sure that the companies I’m search have strength by including market capitalization. I have access to US fundamental data, but I don’t know how to access the parameters to include in my script. I need the screener to include market cap greater than $250,000. How do I access the fundamental to place into my script?

// Wavy Tunnel Breakout #1 Scanner 
//==================================================================================
// ==================================
// Raghee Wave
// ================================== 
EMA34H = MA(BARS=34, STYLE=Exponential, CALC=High);
EMA34C = MA(BARS=34, STYLE=Exponential, CALC=Close);
EMA34L = MA(BARS=34, STYLE=Exponential, CALC=Low);
// ==================================
// Vegas Tunnel
// ==================================
EMA12 = MA(BARS=12, STYLE=Exponential, CALC=Close);  //Signal Line
EMA144 = MA(BARS=144, STYLE=Exponential, CALC=Close);
EMA169 = MA(BARS=169, STYLE=Exponential, CALC=Close);
// =========================================
// Slope Of Signal Line
// =========================================
$X = 5;
Y = EMA12 - OFFSET(EMA12, OFFSET=$X);
// =========================================
// Buying Criteria
// =========================================
Criteria1 = ArcTan(Y/X1) * 180 / 3.141596 >= 1;
Criteria2 = EMA12 CrossesAbove Max(EMA144,EMA169);
Criteria3 = EMA12 CrossesAbove Max(EMA34H,EMA34L);
Criteria4 = Max(EMA34H,EMA34L) CrossesAbove Max(EMA34H,EMA34L);
Criteria5 = Max(EMA34H,EMA34L) CrossesAbove Max(EMA144,EMA169);
Criteria6 = MA(Volume(), BARS=30, CALC=Close) >= 250000;
Criteria7 = Close() > 2.0;

Criteria1 and Criteria6 and Criteria7 and (Criteria2 Or Criteria3 Or Criteria5); // Scan Output

Hi David,

You can use the DataField() function to reference fundamental values like Market Cap.

As a quick example:

DATAFIELD(FEED=FD, FIELD=MarketCapitalization) > 7000

This script would identify codes that had a Market Cap greater than 7 Billion dollars.

Ex1

Thanks Mathew,
This has no errors.

// Wavy Tunnel Breakout #1 Scanner 
//==================================================================================
// ==================================
// Raghee Wave
// ================================== 
EMA34H = MA(BARS=34, STYLE=Exponential, CALC=High);
EMA34C = MA(BARS=34, STYLE=Exponential, CALC=Close);
EMA34L = MA(BARS=34, STYLE=Exponential, CALC=Low);
// ==================================
// Vegas Tunnel
// ==================================
EMA12  = MA(BARS=12, STYLE=Exponential, CALC=Close);  //Signal Line
EMA144 = MA(BARS=144, STYLE=Exponential, CALC=Close);
EMA169 = MA(BARS=169, STYLE=Exponential, CALC=Close);
// =========================================
// Slope Of Signal Line
// =========================================
$X = 5;
Y = EMA12 - OFFSET(EMA12, OFFSET=$X);
// =========================================
// Buying Criteria
// =========================================
Criteria1 = ArcTan(Y/X1) * 180 / 3.141596 >= 1;
Criteria2 = EMA12 CrossesAbove Max(EMA144,EMA169);
Criteria3 = EMA12 CrossesAbove Max(EMA34H,EMA34L);
Criteria4 = Max(EMA34H,EMA34L) CrossesAbove Max(EMA34H,EMA34L);
Criteria5 = Max(EMA34H,EMA34L) CrossesAbove Max(EMA144,EMA169);
Criteria6 = MA(Volume(), BARS=30, CALC=Close) >= 250000;
Criteria7 = Close() > 2.0;  // Price Criteria
Criteria8 = DATAFIELD(FEED=FD, FIELD=MarketCapitalization) > 250000;
// =========================================
//            Scan Output
// =========================================
Criteria1 and Criteria6 and Criteria7 and Criteria8 and (Criteria2 Or Criteria3 Or Criteria5);

Hi David,

One thing to keep in mind is that the Market Cap value is returned in units of 1 million, so in my example of 7000 this is looking for market caps greater than 7 Billion dollars. Looking at your example script you have setup 250 Billion as the minimum market cap, just wanted to make sure you were aware of the unit measurement.