Traders Dynamic Index

Post Reply
DJ Trading

Traders Dynamic Index

Post by DJ Trading »

Hallo liebe Trader

Ich habe mal versucht den Traders Dynamic Index auf der FS zu programmieren. Dies ist mein erster Versuch :) Wäre cool wenn sich ein erfahrener Programmierer mal den Code anschauen könnte, da ich mir nicht sicher bin, dass er fehlerfrei ist.

Code: Select all

Express Traders_Dynamic_Index

Vars
Series
myRSI, PriceLine, SignalLine, Average, Bollinger, MA , SD, BBH, BBL;

Input
$span(1,100,13),
$priceline(1,100,2) ,
$signalline(1,100,7),
$average(1,100,34),
$bollinger(20,40,34);

Calculation
If IsFirstBar() then
begin
 RSI(close, myRSI, $span);
 MovingAverage(myRSI, PriceLine, $priceline);
 MovingAverage(myRSI, SignalLine, $signalline);
 MovingAverage(myRSI, Average, $average);
 MovingAverage(myRSI, MA, $bollinger);
 StdDev(myRSI, SD, 34);
end
BBH = MA + 1.62*SD;
BBL = MA - 1.62*SD;

Interpretation
begin
end

plot(PriceLine, green, 2);
plot(SignalLine, red, 2);
plot(Average, yellow, 2);
plot(BBL, blue, 2);
plot(BBH, blue, 2);
plotline(0, grey, 1);
plotline(20, grey, 1);
plotline(80, grey, 1);
plotline(100, grey, 1);
Danke und Gruss
DJTrading
Tibovwh
Posts: 24
Joined: 27 Aug 2015 22:36

Re: Traders Dynamic Index

Post by Tibovwh »

hi DJ Trading,

I have programmed my own TDI indicator. Please note that this is not entirely like the Synergy TDI that Dean Malone uses.

It's based on typical price and there is no volatility bands included.

Code: Select all

Express  TMS_TDI

Vars
series  line, line_hi, line_lo, mpl, msl, mbl, tp;
series   u, d, au, ad; 
numeric   dif, i, hi_baseline, lo_baseline;
input $period(1, 100, 10);
input $mpl(1,10,2);
input $msl(3,10,7);
input $mbl(20,40,34);

//-------function MMA--------
series res, res1;

Calculation

tp = (h + l + o + c) / 4;
hi_baseline = 68;
lo_baseline = 32;

if IsFirstBar() then
begin
  CalculateAtEveryTick(false);
  SetYscaleFormat(GetPriceFormat());
  u = 0;
  d = 0;
end
if CurrentBarIndex()  >= 1 then
begin
   dif = tp - tp[1];
   if dif > 0 then begin
      u[i] = dif;
      d[i] = 0;
   end 
   else
   begin
      u[i] = 0;
      d[i] = -dif;
   end
end

//---------------function MMA---------------
if CurrentBarIndex()  =  $period then
   res = u;
if CurrentBarIndex()  >  $period then
   res = res[1] + (u - res[1]) /$period;
au = res;

//---------------function MMA---------------
if CurrentBarIndex()  =  $period then
   res1 = d;
if CurrentBarIndex()  >  $period then
   res1 = res1[1] + (d - res1[1]) /$period;
ad = res1;

line = void;
line_hi = void;
line_lo = void;

if CurrentBarIndex()  >  $period then
   line = 100 * au / (au + ad);
line_hi = hi_baseline;
line_lo = lo_baseline;

if IsFinalBar() then
begin
Calculateateverytick(true);
ExpMovingAverage(line, mpl, $mpl);
MovingAverage(mpl, msl, $msl);
MovingAverage(mpl, mbl, $mbl);
end


Interpretation
begin
end


plot (mpl, 0,255,0, 2);
plot (msl, 255,0,0, 2);
plot (mbl, 255,192,0, 2);

Best,
Tibovwh
Posts: 24
Joined: 27 Aug 2015 22:36

Re: Traders Dynamic Index

Post by Tibovwh »

I'm having some trouble with my TDI indicator when I try to add the volatility bands. It only draws for the last bar. Seems like easy to fix but I can't find how.

See attachment: It calculates SD correctly for all bars but the VB bands are only calculated for final bar

Here's the code again:

Code: Select all

Express  TMS_TDI

Vars
series  line, line_hi, line_lo, mpl, msl, mbl, tp, sd, vbup, vbdown;
series   u, d, au, ad; 
numeric   dif, i, hi_baseline, lo_baseline;
input $period(1, 100, 10);
input $mpl(1,10,3);
input $msl(3,10,7);
input $mbl(20,40,34);

//-------function MMA--------
series res, res1;

Calculation

tp = (h + l + o + c) / 4;
hi_baseline = 68;
lo_baseline = 32;


if IsFirstBar() then
begin
  CalculateAtEveryTick(false);
  SetYscaleFormat(GetPriceFormat());
  u = 0;
  d = 0;
end
if CurrentBarIndex()  >= 1 then
begin
   dif = tp - tp[1];
   if dif > 0 then begin
      u[i] = dif;
      d[i] = 0;
   end 
   else
   begin
      u[i] = 0;
      d[i] = -dif;
   end
end

//---------------function MMA---------------
if CurrentBarIndex()  =  $period then
   res = u;
if CurrentBarIndex()  >  $period then
   res = res[1] + (u - res[1]) /$period;
au = res;

//---------------function MMA---------------
if CurrentBarIndex()  =  $period then
   res1 = d;
if CurrentBarIndex()  >  $period then
   res1 = res1[1] + (d - res1[1]) /$period;
ad = res1;

line = void;
line_hi = void;
line_lo = void;

if CurrentBarIndex()  >  $period then
   line = 100 * au / (au + ad);
line_hi = hi_baseline;
line_lo = lo_baseline;

if IsFinalBar() then
begin
Calculateateverytick(true);
ExpMovingAverage(line, mpl, $mpl);
MovingAverage(line, msl, $msl);
MovingAverage(line, mbl, $mbl);
StdDev(mbl, sd, $mbl);
vbup = mbl + sd;
vbdown = mbl - sd;
end




Interpretation
begin
end


plot (mpl, 0,255,0, 2);
plot (msl, 255,0,0, 2);
plot (mbl, 255,192,0, 2);
plotline (lo_baseline, black, 1);
plotline (hi_baseline, black, 1);
plot (sd, blue,2);
plot (vbup, blue, 2);
plot (vbdown, blue, 2);
You do not have the required permissions to view the files attached to this post.
mpcdmu
Posts: 19
Joined: 29 Jun 2013 00:11

Re: Traders Dynamic Index

Post by mpcdmu »

Bonjour Tibovwh,

Tu peux essayer de voir à partir de ce code :

Cordialement.

Code: Select all

Express  TMS_TDI

Vars
series  line, line_hi, line_lo, mpl, msl, mbl, tp, sd, vbup, vbdown;
series   u, d, au, ad, mbl2, EcartType; 
numeric   dif, i, hi_baseline, lo_baseline;
Numeric Periode_mbl2, somme, compteur, Diffrentiel, carre, Total;
input $period(1, 100, 10);
input $mpl(1,10,3);
input $msl(3,10,7);
input $mbl(20,40,34);

//-------function MMA--------
series res, res1;

Calculation

tp = (h + l + o + c) / 4;
hi_baseline = 68;
lo_baseline = 32;

if IsFirstBar() then
begin
  CalculateAtEveryTick(false);
  SetYscaleFormat(GetPriceFormat());
  u = 0;
  d = 0;
end
if CurrentBarIndex()  >= 1 then
begin
   dif = tp - tp[1];
   if dif > 0 then begin
      u[i] = dif;
      d[i] = 0;
   end 
   else
   begin
      u[i] = 0;
      d[i] = -dif;
   end
end

//---------------function MMA---------------
if CurrentBarIndex()  =  $period then
   res = u;
if CurrentBarIndex()  >  $period then
   res = res[1] + (u - res[1]) /$period;
au = res;

//---------------function MMA---------------
if CurrentBarIndex()  =  $period then
   res1 = d;
if CurrentBarIndex()  >  $period then
   res1 = res1[1] + (d - res1[1]) /$period;
ad = res1;

line = void;
line_hi = void;
line_lo = void;

if CurrentBarIndex()  >  $period then
   line = 100 * au / (au + ad);
line_hi = hi_baseline;
line_lo = lo_baseline;

if IsFinalBar() then
begin
Calculateateverytick(true);
ExpMovingAverage(line, mpl, $mpl);
MovingAverage(line, msl, $msl);
MovingAverage(line, mbl, $mbl);
StdDev(mbl, sd, $mbl);
End

Periode_mbl2= 34;
Somme = Sum(line,Periode_mbl2);
Mbl2 = somme / Periode_mbl2;

Somme = 0;
For compteur = 0 to (Periode_mbl2-1)
Begin
Diffrentiel = line[compteur] - mbl2;
Carre = power(Diffrentiel,2) ;
Somme = Somme + Carre ;
End

Total = somme / Periode_mbl2 ;
EcartType = SquareRoot(Total) ;

vbup = mbl2 + EcartType;
vbdown = mbl2 - EcartType;

Interpretation
begin
end

plot (mpl, 0,255,0, 2);
plot (msl, 255,0,0, 2);
plot (mbl, 255,192,0, 2);
plotline (lo_baseline, black, 1);
plotline (hi_baseline, black, 1);
plot (sd, blue,2);
plot (vbup, blue, 2);
plot (vbdown, blue, 2);
plot (EcartType, black,2);
You do not have the required permissions to view the files attached to this post.
Tibovwh
Posts: 24
Joined: 27 Aug 2015 22:36

Re: Traders Dynamic Index

Post by Tibovwh »

Je ne comprends pas vraiment ce que vous avez faites mais ça marches donc, merci ! :D

Cordialement,
Post Reply

Return to “WHS NANOTRADER - EXPRESS PROGRAMMING”