You are on page 1of 3

// Copyright Fipertec

// Version 1.5

Express Commodity_Selection

Vars
series line, swingline, senti(50);
series res, res1, res2, res3, res4;
numeric pdm, mdm, Minus_DI, Plus_DI, Dirmov_DX;
series adx;
numeric k, tmp, tmp1, sm, atr, adxr;
input $period (1,100,14);
input $margin (1,10000,2500);
input $commission (1,100,25);
input $point (1,1000,100);
input $spanLeft(1,10,1);
input $spanRight(1,10,1);
input $MessageBox("No;Yes",0);
input $PlaySound("No;Yes",0);
input $SendEmail("No;Yes",0);

//-------function TrueRange----------------
series r;
numeric truehigh, truelow;

Calculation

if IsFirstBar() then
begin
CalculateAtEveryTick(false);
SetYscaleFormat(GetPriceFormat());
end

//------------function TrueRange------------
if CurrentBarIndex() = 0 then
r = high - low;
if CurrentBarIndex() >= 1 then
begin
truehigh = close[1];
if truehigh < high then
truehigh = high;
truelow = close[1];
if truelow > low then
truelow = low;
r = truehigh - truelow;
end

if (CurrentBarIndex() < $period) then


begin
sm = sm + r;
atr = void;
end
else
begin
sm = sm + r - r[$period];
atr = sm/$period;
end
//==========================================
// function PlusDI
//==========================================
if CurrentBarIndex() >= 1 then
begin
tmp = high - high[1];
if tmp < 0 then
tmp = 0;
pdm = tmp;
end
// ------------- function MMA---------------
if CurrentBarIndex() = $period then
res = pdm ;
if CurrentBarIndex() > $period then
res = res[1] + (pdm - res[1]) /$period;
// ------------- function MMA---------------
if CurrentBarIndex() = $period then
res1 = r;
if CurrentBarIndex() > $period then
res1 = res1[1] + (r - res1[1]) /$period;
//------------------------------------------
if IsNonZero(res1) then Plus_DI = 100 * res /res1;
//==========================================
// function MinusDI
//==========================================
if CurrentBarIndex() >= 1 then
begin
tmp1 = low[1] - low;
if tmp1 < 0 then
tmp1 = 0;
mdm = tmp1;
end
//------------- function MMA-----------------
if CurrentBarIndex() = $period then
res2 = mdm ;
if CurrentBarIndex() > $period then
res2 = res2[1] + (mdm - res2[1]) /$period;
// ------------- function MMA----------------
if CurrentBarIndex() = $period then
res3 = r;
if CurrentBarIndex() > $period then
res3 = res3[1] + (r - res3[1]) /$period;
//-------------------------------------------
if IsNonZero(res3) then Minus_DI = 100 * res2 /res3;
//==========================================
// Dirmov DX
//==========================================
if IsNonZero(Plus_DI + Minus_DI) then
Dirmov_DX = 100 * AbsValue(Plus_DI - Minus_DI) / (Plus_DI + Minus_DI);
//==========================================
// ADX
//==========================================
// ------------- function MMA---------------
if CurrentBarIndex() = $period then
res4 = Dirmov_DX;
if CurrentBarIndex() > $period then
res4 = res4[1] + (Dirmov_DX - res4[1]) /$period;
ADX = res4;
//------------------------------------------
ADXR = (ADX + ADX[$period]) / 2;
k = 100 *$point / SquareRoot ($margin) / (150 + $commission);
line = k * ADXR * atr;

if CurrentBarIndex() <= $period then


line = void;

//------------------------------------------

swingline = line[1];

if (line[1] < swingline[1]) and (line > swingline) then


begin
senti = 100;
if ($SendEmail = 1) then SendEmail("Buy signal","Buy signal Commodity_Selection:
" + SymbolName());
if ($PlaySound = 1) then Playsound("ring");
if ($MessageBox = 1) then MessageBox("Buy signal Commodity_Selection: " +
SymbolName());
end

if (line[1] > swingline[1]) and (line < swingline) then


begin
senti = 0;
if ($SendEmail = 1) then SendEmail("Sell signal","Sell signal
Commodity_Selection: " + SymbolName());
if ($PlaySound = 1) then Playsound("ring");
if ($MessageBox = 1) then MessageBox("Sell signal Commodity_Selection: " +
SymbolName());
end

interpretation

begin
sentiment = senti;
end

plot (line, "lightblue", 1);//@@@cs:1486300-4028886-1174149_cs@@@

You might also like