Hi Johnathan and Forum,

I don’t think this is a solution for scripting a Dow Swing however, it may be of interest to you.

The MetaStock Advanced Formula Writing – Formula Primer II seems to cover identification of peaks and troughs as done by the Optuma scripting functions for Gann Swing.

The document can be found here:

https://www.metastock.com/customer/resources/formulas/Formula_Primer_II.pdf

Chapter 7 covers Pivots. Page 50 headed “Highs & Lows” which seems to describe Dow Swings.

The text works through various algorithms to identify peaks and troughs.

I have made translations from MetaStock Formula Language to Optuma Scripting Language. My formulas complete without error but do not work.

I have tried some in MetaStock and they produce a binary wave which lines up correctly with peaks. I attempted to apply the formulas to the MetaStock Expert without success. I am not well versed with MetaStock as I find Optuma is a way more friendly and capable charting package to use.

Here are my various translations:

Page 51 under heading “Step3: The Final Formula”

HIGH() > VALUEWHEN(HIGHESTHIGH(BARS=40), -1) and HIGH() > VALUEWHEN(HIGH(), +1)

Page 53 under heading “Step3: The Final Formula”

bar1 = VALUEWHEN(high(OFFSET=-2)) > HIGHESTHIGH(BARS=2) and

VALUEWHEN(high(OFFSET=-2)) > VALUEWHEN(HIGHESTHIGH(BARS=2),-3);

bar2 = VALUEWHEN(high(OFFSET=-2)) > HIGHESTHIGH(BARS=2) and

VALUEWHEN(high(OFFSET=-2)) = VALUEWHEN(high(OFFSET=-3)) and

VALUEWHEN(high(OFFSET=-2)) > VALUEWHEN(HIGHESTHIGH(BARS=2), -4);

bar3 = VALUEWHEN(high(OFFSET=-2)) > HIGHESTHIGH(BARS=2) and

VALUEWHEN(high(OFFSET=-2)) = VALUEWHEN(high(OFFSET=-3)) and

VALUEWHEN(high(OFFSET=-2)) = VALUEWHEN(HIGHESTHIGH(BARS=2), -5);

bar2nc = VALUEWHEN(high(OFFSET=-2)) > HIGHESTHIGH(BARS=2) and

VALUEWHEN(high(OFFSET=-2)) = VALUEWHEN(high(OFFSET=-3)) and

VALUEWHEN(high(OFFSET=-2)) = VALUEWHEN(HIGHESTHIGH(BARS=2), -5);

bar3nc = VALUEWHEN(high(OFFSET=-2)) > HIGHESTHIGH(BARS=2) and

VALUEWHEN(high(OFFSET=-2)) = VALUEWHEN(high(OFFSET=-4)) and

VALUEWHEN(high(OFFSET=-2)) = VALUEWHEN(high(OFFSET=-6)) and

VALUEWHEN(high(OFFSET=-2)) = VALUEWHEN(high(OFFSET=-3)) and

VALUEWHEN(high(OFFSET=-2)) = VALUEWHEN(high(OFFSET=-5)) and

VALUEWHEN(high(OFFSET=-2)) = VALUEWHEN(HIGHESTHIGH(BARS=2), -7);

bar1 or ba3 or bar3nc or bar2nc or bar3nc

Page 56 under heading “Step3: The Final Formula”

mu= HIGH() > MAX(high(OFFSET=-1), high(OFFSET=1));

p2 = mu and HIGH() > VALUEWHEN() (2, mu, HIGH());

p3 = mu and HIGH() < VALUEWHEN()(2, mu, HIGH()) and VALUEWHEN(2, mu, p2);

time = LAST(MAX(VALUEWHEN(1, p3, BARCOUNT(p2))));

x = VALUEWHEN(1, p3, ACC(RANGE=Look Back Period, BARS=1) - BARCOUNT(p2));

mju = ACC(RANGE=Look Back Period, BARS=1) == VALUEWHEN(x, time);

pj2 = mju and HIGH() > VALUEWHEN(2, mju, high());

pj3 = mju and HIGH() < VALUEWHEN(2, mju, high()) and VALUEWHEN(2, mju, pj2);

timej = LAST(MAX(VALUEWHEN(1, p3, BARCOUNT(pj2))));

xj = VALUEWHEN(1, pj3, ACC(RANGE=Look Back Period, BARS=1) - BARCOUNT(pj2));

ACC(RANGE=Look Back Period, BARS=1) == VALUEWHEN(x, time) or ACC(RANGE=Look Back Period, BARS=1) == VALUEWHEN(xj, timej)

Cheers, Lester