Professional Documents
Culture Documents
// Version 1.5
Express Dynamic_Momentum
Vars
series line, senti(50), swingline;
series price;
series dev, adev;
numeric period, j, i, up, dn, dif;
input $Price("Open;Close;High;Low",1);
input $MessageBox("No;Yes",0);
input $PlaySound("No;Yes",0);
input $SendEmail("No;Yes",0);
Calculation
if IsFirstBar() then
begin
CalculateAtEveryTick(false);
SetYscaleFormat(GetPriceFormat());
for i = 0 to FinalBarIndex()
begin
if $Price = 3 then price[-i] = l[-i];
else
if $Price = 2 then price[-i] = h[-i];
else
if $Price = 1 then price[-i] = c[-i];
else
if $Price = 0 then price[-i] = o[-i];
end
StdDev (price, dev, 5);
MovingAverage(dev, adev, 10 );
period = 30;
end
line = void;
if IsNonZero(dev) then
begin
period = Floor(14 * adev / dev);
if period < 5 then period = 3;
if period > 30 then period = 30;
end
up = 0;
dn = 0;
dif = Close - Close[1];
for j = 0 to period -1
begin
dif = Close[j] - Close[j + 1];
if dif > 0 then
up = up + (dif- up) / period;
else
dn = dn + ((-1 * dif) - dn) / period;
end
swingline = line[1];
if (line[1] < swingline[1]) and (line > swingline) then
begin
senti = 100;
if ($SendEmail = 1) then SendEmail("Buy signal","Buy signal Dynamic_Momentum: " +
SymbolName());
if ($PlaySound = 1) then Playsound("ring");
if ($MessageBox = 1) then MessageBox("Buy signal Dynamic_Momentum: " +
SymbolName());
end
interpretation
begin
sentiment = senti;
end