home *** CD-ROM | disk | FTP | other *** search
- #MAX_QUOTES 200
- #OUTPUT_FILE 'SELECT.LST'
- {
- SHOW_ALL equal to zero if you only want to show BUY/SELL SIGNALS
- }
- SHOW_ALL = 1;
-
- {
- --------------------- STUDY1.scr ---------------------------
- This script contains the "Achelis Binary Wave(tm)" calculation
- shown in the Metastock(*) 2.0 distribution system. It has been
- modified to include the following indicators as well:
- BUY SELL
- Chaikin's Oscillator > 0 < 0
- Commodity Channel Index > 100 < -100
- It is here to give an example of the kind of analysis
- available with the TAS Script language.
- The Metastock manual discusses this binary wave system on
- page 187 of the User's Manual.
- The script will put out a message if the value of the binary
- wave changes from yesterday to today (the terms 'today' and
- 'yesterday' are used loosely, but meant to be the 'latest day'
- and the 'day before', respectively).
- Two variables are defined and updated as each of the four
- individual binary wave formulas are checked.
- They are:
- "t_bwave" which is today's binary wave value (-6 to +6)
- and
- "y_bwave" which is yesterday's binary wave value (-6 to +6)
- What we are looking for is a TRANSITION from yesterday to
- today. If the stock moved to +6 today and it was lower yesterday,
- perhaps this is a buying opportunity. If the stock moved to -6
- perhaps it is a short sell.
- }
- y_total : number; { yesterday's total bwave }
- t_total : number; { today's total bwave value }
- c_total : number; { total changed bwave values}
- tick_total : number; { ticker count }
- sell_count : number; { total SELL's given }
- buy_count : number; { total BUY's given }
- MACD_ARRAY : ARRAY; { Place to put values for TODAY }
- MACDTRIG_ARRAY : ARRAY;
- MA20 : ARRAY;
- ROC12 : ARRAY; { PLACE TO PUT RATE OF CHANGE }
- STOCH53 : ARRAY; { PLACE TO PUT STOCH(5,3) VALUES }
- CO_ARRAY : ARRAY;
- CCI14 : ARRAY; { PLACE TO PUT CCI(14) VALUES }
- y_bwave := 0; { this is our 'score' yesterday}
- t_bwave := 0; { this is our 'score' today}
- alert := ' ';
- if FIRST_TICKER then
- begin
- good_date = date; { check's for files not current }
- writeln(' --BINARY WAVE-- ');
- writeln('TICKER FULLNAME PRIOR CURR CHNG ALERT CLOSE');
- y_total = 0; { yesterday's total bwave }
- t_total = 0; { today's total bwave value }
- c_total = 0; { total changed bwave values}
- tick_total = 0; { ticker count }
- sell_count = 0; { SELL count }
- buy_count = 0; { BUY count }
- end;
- { SKIP any tickers which are not 'up-to-date'}
- if good_date = date then
- BEGIN
- {
- First compute MACD Binary Wave for yesterday and today
- Note that MACD() computes the 12 day EMA - 26 day EMA and places
- the result in the array MACD_ARRAY. The 9 day EMA is computed
- and placed in the result array MACDTRIG_ARRAY
- }
- MACD_ARRAY = MACD();
- MACDTRIG_ARRAY = MACDTRIGGER();
- {
- Now compute 20-MA B-Wave
- }
- MA20 := mov(c,20,'E'); { Compute 20 unit EMA of close }
- {
- Now compute 12-ROC B-Wave
- }
- ROC12 := roc(c,12,'%');
- {
- Now compute 5-3 stochastic B-wave
- }
- STOCH53 := stoch(5,3); { compute stoch(%K period, %K slow) }
- {
- check if Chaikin's AD oscillator is above or below 0
- }
- CO_ARRAY := CO(); { PLACE CHAIKIN'S OSCILLATOR IN CO_ARRAY}
- {
- check if CCI(14) above +100 or below -100
- }
- CCI14 := cci(14);
-
- { All arrays are calculated. Now do the checking of change }
- IF MACD_ARRAY[0] > MACDTRIG_ARRAY[0] THEN
- t_bwave := t_bwave + 1 { macd greater than trigger }
- else
- t_bwave := t_bwave - 1; { macd less than trigger }
- if MACD_ARRAY[-1] > MACDTRIG_ARRAY[-1] then
- y_bwave := y_bwave + 1 { macd greater than trigger }
- else
- y_bwave := y_bwave - 1; { macd less than trigger }
- if c[0] > MA20 then { compare today's close to today's ema}
- t_bwave := t_bwave + 1 { ema greater than close }
- else
- t_bwave := t_bwave - 1; { ema less than close }
- if c[-1] > MA20[-1] then { compare yesterday's close to today's ema}
- y_bwave := y_bwave + 1 { ema greater than close }
- else
- y_bwave := y_bwave - 1; { ema less than close }
- if ROC12 > 0 then
- t_bwave := t_bwave + 1 { roc greater than 0 }
- else
- t_bwave := t_bwave - 1; { roc less than 0 }
- if ROC12[-1] > 0 then
- y_bwave := y_bwave + 1 { roc greater than 0 }
- else
- y_bwave := y_bwave - 1; { roc less than 0 }
- if STOCH53[0] > 50 then
- t_bwave := t_bwave + 1 { stoch greater than 50 }
- else
- t_bwave := t_bwave - 1; { stoch less than 50 }
- if STOCH53[-1] > 50 then
- y_bwave := y_bwave + 1 { stoch greater than 50 }
- else
- y_bwave := y_bwave - 1; { stoch less than 50 }
- IF CO_ARRAY[0] > 0 THEN
- t_bwave := t_bwave + 1
- else
- t_bwave := t_bwave - 1;
- IF CO_ARRAY[-1] > 0 THEN
- y_bwave := y_bwave + 1
- else
- y_bwave := y_bwave - 1;
- if CCI14[0] < -100 then
- t_bwave := t_bwave - 1
- else
- if CCI14[0] > 100 then
- t_bwave := t_bwave + 1;
- if CCI14[-1] < -100 then
- y_bwave := y_bwave - 1
- else
- if CCI14[-1] > 100 then
- y_bwave := y_bwave + 1;
- {
- Okay, here we are at the end of the script. We have boiled
- the formulas down to two values:
- "t_bwave" which is today's binary wave value (-6 to +6)
- and
- "y_bwave" which is yesterday's binary wave value (-6 to +6)
- }
- {
- First, let's check if the wave moved to +6..if so, let's print
- out it's value then and now
- }
- y_bwave := INT(y_bwave); { make y_bwave into an INTEGER }
- t_bwave := INT(t_bwave); { make t_bwave into an INTEGER }
- diff := INT(t_bwave-y_bwave);
- tick_total = tick_total + 1; { add to count of tickers }
- y_total = y_total + y_bwave; { add yesterday's bwave to total}
- t_total = t_total + t_bwave; { add today's bwave to total}
- c_total = c_total + diff; { add diff in bwave to total}
- buy_flag = 0;
- sell_flag = 0;
- alert = ' ';
- if ((y_bwave < 6) and (t_bwave = 6)) then
- begin
- buy_flag = 1;
- alert = ' BUY ';
- buy_count = buy_count + 1;
- end
- {
- Now, let's check if the wave moved to -6..if so, let's print
- out it's value then and now
- }
- else
- if ((y_bwave > -6) and (t_bwave = -6)) then
- begin
- sell_flag = 1;
- alert = ' SELL ';
- sell_count = sell_count + 1;
- end;
- if (show_all = 1) or (buy_flag = 1) or (sell_flag = 1) then
- begin
- { Write out the line with the current alert }
- write(TICKER,fullname,' ');
- write(y_bwave,t_bwave,diff);
- writeln(alert,c);
- end;
- END; { of if good_date = date }
- if last_ticker then
- begin
- writeln('\t\t\n\n------------- SUMMARY--------------------');
- writeln('\tTickers Processed ',INT(tick_total));
- writeln('\tYesterday Binary Wave Average ',y_total/tick_total);
- writeln('\tToday Binary Wave Average ',t_total/tick_total);
- writeln('\tAverage Change in Binary Wave ',c_total/tick_total);
- writeln('\t',INT(buy_count),' BUY Signals');
- writeln('\t',INT(sell_count),' SELL Signals');
- end;
-
-