Hi,
I’ve searched everywhere for technicals on scanning scripts, but there’s nothing I can find to help me understand what’s gone wrong.
I have a working ‘show view’ script with the plots stripped out. Scanning wants a single logical at the end. So I chose
Ton[0]. This is the most recent value of the boolean variable of interest. I had to start somewhere.
Instead of getting any results I get the attached "Unknown Function (T2 = 0.00) etc etc "
Q1 What this is telling me? What do I do about it?
NOTE: Daily data evolution manually computes over the entire history of the stock contributes to the state of Ton. Restricting the scan to a single time/date or interval not possible. It may make the scan take a while, but that’s OK. In reality I want to pay attention to the state of Ton over the last 3 days and select stocks.
Clues anyone?
cheers
colin
// PARAMETERS
Pohlc = ma(BARS=1, CALC=OHLC);
// Reference price = (close() + open() + high() + low())/4.0
THISPRICE = Pohlc;
PREVPRICE = OFFSET(Pohlc, OFFSET=1);
T1 = 0.00;
// Threshold: % DPtot for Ton (buy)
T2 = 0.00;
// Threshold: % DPtot for Toff (sell)
T3 = 0.065;
// % upswing for reversal processing
T4 = -0.065;
// % downswing for reversal processing
T5 = 0.01;
// single price rise %Pohlc
T6 = -0.01;
// single price fall %Pohlc
T7 = -0.005;
// total %Pohlc drop over 2 successive days
T8 = +0.005;
// total %Pohlc rise over 2 successive days
//TRADING_PLOT_OFFSET = 0;
//SIGNAL_PLOT_OFFSET = 15;
//SIGNAL_PLOT_GAP = 3.0;
// ********** TRADING RULE SET 001 ********
DPco = open() - close(OFFSET=1);
DPoc = close() - open();
DPhh = high() - high(OFFSET=1);
DPll = low() - low(OFFSET=1);
DPhl = (high() - low()) * ( ((close() - low()) / (high() - low())) - 0.5);
// create the total change
Dptot = DPco + DPoc + DPhh + DPll + DPhl;
Dptot_PCT = Dptot/THISPRICE;
// compute the change compared to previous bar
D2P = DPtot - OFFSET(DPtot, OFFSET=1);
D2P_PCT = D2P/THISPRICE;
// Special plot placement to avoid optuma bug 1 May 2018
//plot1 = 100.0 * Dptot_PCT;
//plot2 = 100.0 * D2P_PCT;
//plot1 = Dptot;
//plot2 = D2P;
//plot1.Plotstyle = Step;
//plot1.LineWidth = 1;
//plot1.colour = green;
//plot2.Plotstyle = Histogram;
//plot2.Colour = Fuchsia;
//plot2.linewidth = 3;
c21 = ( (DPtot/THISPRICE) >= T1);
// DPtot BUY bigger than threshold
c22 = (OFFSET(D2P, OFFSET=1) > 0) and (D2P > 0);
// two +ve accelerations in a row
c23 = (OFFSET(DPtot, OFFSET=1) > 0);
// Last DPtot > 0
c24 = (OFFSET(D2P, OFFSET=1) < D2P);
// most recent acceleration larger
c25 = D2P > 0;
// N acceleration > 0
c26 = DPtot > 0;
// N velocity > 0
c27 = D2P < 0;
// N acceleration < 0
c28 = c21 and c22;
// main buy trigger
c30 = (D2P_PCT >= T3);
// + acceleration as percent of price is > Threshold
c31 = (D2P_PCT <= T4);
// - acceleration as percent of price is > Threshold
c32 = (OFFSET(c30, OFFSET=1) > 0);
// Previous D2P was upswing
c33 = (OFFSET(c31, OFFSET=1) > 0);
// Previous D2P was downswing
c34 = c30 and c33;
// UPWARDS reversal
c35 = c31 and c32;
// DOWNWARDS reversal
c41 = (OFFSET(D2P, OFFSET=1) <= 0) and (D2P <= 0);
// two -ve accelerations in a row
c42 = ( (DPtot/THISPRICE) <= T2);
// DPtot SELL lower than threshold
c43 = c41 and c42;
c50 = (Pohlc < OFFSET(Pohlc, OFFSET=1) );
// price N < price N-1
c51 = OFFSET(Pohlc, OFFSET=1) < OFFSET(Pohlc, OFFSET=2);
// price N-1 < price N-2
c53 = (Pohlc > OFFSET(Pohlc, OFFSET=1) );
// Price N > price N-1
c54 = OFFSET(Pohlc, OFFSET=1) > OFFSET(Pohlc, OFFSET=2);
// price N-1 > price N-2
c55 = ((Pohlc - Pohlc[2])/Pohlc) <= T7;
// Total price fall exceeds threshold
c56 = ((Pohlc - Pohlc[2])/Pohlc) >= T8;
// Total price rise exceeds threshold
c52 = c50 and c51 and c55;
//two price drops in a row
c57 = c53 and c54 and c56;
//two price rises in a row
c60 = ((Pohlc - Pohlc[1])/Pohlc) >= T5;
//single price rise > T5%
c61 = ((Pohlc - Pohlc[1])/Pohlc) <= T6;
//single price fall > T6%
BUY_TRIG = c28 or c60;
SELL_TRIG = c43 or c52 or c61;
// ******** END OF TRADING RULE SET **********
TRADING = SWITCH( BUY_TRIG , SELL_TRIG);
Ton = (TRADING > 0) and (OFFSET(TRADING, OFFSET=1) <= 0);
// Positive edge on TRADING
Toff = (TRADING <= 0) and (OFFSET(TRADING, OFFSET=1) > 0);
// Negative edge on TRADING
// SCAN RESULT
Ton
I put pre tags around your code in your post so we could see it a little easier. The pre stands for pre-formatted and it good to use in these cases.
The error you found turns out to be a problem with our comment parser. If you remove these comment lines from the script the script should scan without errors.
// Threshold: % DPtot for Ton (buy)
// Threshold: % DPtot for Toff (sell)
We will have a look at why those comment are causing errors and will update with a fix ASAP.
I would guess its because the comment has brackets that is causing the issue.
Hi Peter,
Thanks! I removed comments (although I’m not sure what you mean by a pre tag. If you can tell me what I do to format it, happy to do it).
The scans now seem to work with one problem:
Codes to scan: “C live Pool” has 216 codes (CSV attached)
Date Range: Last bar
Data Timeframe: 1 Day TEST 1 Ton 23 results Ton >= 1 23 results Ton <= 0 190 results
Total results = 213. TEST 2 Toff >= 1 35 results Toff <= 0 178 results
Total results = 213. TEST 3 TRADING 105 results TRADING <= 0 108 results
Total results = 213.
I’ve attached the C live Pool list as a .CSV. If you look you’ll see there are 216 codes in the list.
As you know, it’s impossible for a particular code to be other than 1 or zero.
Any insights as to what 3 codes are missed and why? I’m assuming I messed something up, but I can’t see what it is.
regards,
colin
// PARAMETERS
Pohlc = ma(BARS=1, CALC=OHLC);
THISPRICE = Pohlc;
PREVPRICE = OFFSET(Pohlc, OFFSET=1);
T1 = 0.00;
T2 = 0.00;
T3 = 0.065;
T4 = -0.065;
T5 = 0.0095;
T6 = -0.0095;
T7 = -0.005;
T8 = +0.005;
// ********** TRADING RULE SET 001 ********
DPco = open() - close(OFFSET=1);
DPoc = close() - open();
DPhh = high() - high(OFFSET=1);
DPll = low() - low(OFFSET=1);
DPhl = (high() - low()) * ( ((close() - low()) / (high() - low())) - 0.5);
// create the total change
Dptot = DPco + DPoc + DPhh + DPll + DPhl;
Dptot_PCT = Dptot/THISPRICE;
// compute the change compared to previous bar
D2P = DPtot - OFFSET(DPtot, OFFSET=1);
D2P_PCT = D2P/THISPRICE;
c21 = ( (DPtot/THISPRICE) >= T1);
// DPtot BUY bigger than threshold
c22 = (OFFSET(D2P, OFFSET=1) > 0) and (D2P > 0);
// two +ve accelerations in a row
c23 = (OFFSET(DPtot, OFFSET=1) > 0);
// Last DPtot > 0
c24 = (OFFSET(D2P, OFFSET=1) < D2P);
// most recent acceleration larger
c25 = D2P > 0;
// N acceleration > 0
c26 = DPtot > 0;
// N velocity > 0
c27 = D2P < 0;
// N acceleration < 0
c28 = c21 and c22;
// main buy trigger
c30 = (D2P_PCT >= T3);
// + acceleration as percent of price is > Threshold
c31 = (D2P_PCT <= T4);
// - acceleration as percent of price is > Threshold
c32 = (OFFSET(c30, OFFSET=1) > 0);
// Previous D2P was upswing
c33 = (OFFSET(c31, OFFSET=1) > 0);
// Previous D2P was downswing
c34 = c30 and c33;
// UPWARDS reversal
c35 = c31 and c32;
// DOWNWARDS reversal
c41 = (OFFSET(D2P, OFFSET=1) <= 0) and (D2P <= 0);
// two -ve accelerations in a row
c42 = ( (DPtot/THISPRICE) <= T2);
// DPtot SELL lower than threshold
c43 = c41 and c42;
c50 = (Pohlc < OFFSET(Pohlc, OFFSET=1) );
// price N < price N-1
c51 = OFFSET(Pohlc, OFFSET=1) < OFFSET(Pohlc, OFFSET=2);
// price N-1 < price N-2
c53 = (Pohlc > OFFSET(Pohlc, OFFSET=1) );
// Price N > price N-1
c54 = OFFSET(Pohlc, OFFSET=1) > OFFSET(Pohlc, OFFSET=2);
// price N-1 > price N-2
c55 = ((Pohlc - Pohlc[2])/Pohlc) <= T7;
// Total price fall exceeds threshold
c56 = ((Pohlc - Pohlc[2])/Pohlc) >= T8;
// Total price rise exceeds threshold
c52 = c50 and c51 and c55;
//two price drops in a row
c57 = c53 and c54 and c56;
//two price rises in a row
c60 = ((Pohlc - Pohlc[1])/Pohlc) >= T5;
//single price rise > T5%
c61 = ((Pohlc - Pohlc[1])/Pohlc) <= T6;
//single price fall > T6%
BUY_TRIG = c28 or c60;
SELL_TRIG = c43 or c52 or c61;
// ******** END OF TRADING RULE SET **********
TRADING = SWITCH( BUY_TRIG , SELL_TRIG);
Ton = (TRADING > 0) and (OFFSET(TRADING, OFFSET=1) <= 0);
// Positive edge on TRADING
Toff = (TRADING <= 0) and (OFFSET(TRADING, OFFSET=1) > 0);
// Negative edge on TRADING
// SCAN RESULT
TRADING
Looking at the list, i believe 3 codes are being missed as they do not have up to date data.
AIS - 29-05
CGS - 29-05
MAQ - 28-05
I’ve checked the data against the ASX and I can confirm these last bar date for these codes is correct, so they maybe in a temporary trading halt at the moment.
The system shows an alert for data if it is 4+ days older than the current date. This is done to prevent incorrect alerts that would occur from events such as long weekends.