Cape Town
Posts: 6 since Mar 2012
Thanks Given: 4
Thanks Received: 0
|
Hi guys and gals I need to convert this DMI Metastock indicator to Multicharts.
I tried, but cant get the loop right that needs to take the place of the Sum function as in Metastock!!
Hope anyone can help me!!!! Thanx a trillioN!!
The metastock indicator:
N:= 14;
TR := SUM(MAX(MAX(HIGH-LOW,ABS(HIGH-REF(CLOSE,1))),ABS(LOW-REF(CLOSE,1))),N);
HD := HIGH-REF(HIGH,1);
LD := REF(LOW,1)-LOW;
DMP:= SUM(IF(HD>0 & HD>LD,HD,0),N); //here lies the problem to get these 2 lines to tradestation
DMM:= SUM(IF(LD>0 & LD>HD,LD,0),N);
PDI:= DMP*100/TR;
MDI:= DMM*100/TR;
ADX:= MA(ABS(MDI-PDI)/(MDI+PDI)*100,N);
The build in DMI function in multicharts does not produce the same results as the above indicator I used in my system in Metastock.
Here is what I got so far as to the conversion to Multicharts, but cant get the same data produced with this as in Metastock:
i.e. this is the function I call into my system to calculate the DMI levels::
Inputs:
PriceH( numericseries ),
PriceL( numericseries ),
PriceC( numericseries ),
Len( numericsimple ),
cDMIPlus( numericref ),
cDMIMinus( numericref ),
cADX(numericref);
variables: TR (0),HD(0), LD(0), DMP(0),DMM(0), PDI(0), MDI (0);
//////////////////-----1------//////////////////
for Value1 = 0 to 13 begin
TR = Sum (maxlist(maxlist(PriceH[Value1]-PriceL[Value1], AbsValue(PriceH[Value1]-PriceC[Value1 +1])),
AbsValue(PriceL[Value1]-PriceC[Value1 +1])),Len);
end;
/////////////////------2------//////////////////
for Value1 = 0 to Len -1
begin
HD = PriceH - PriceH[1];
LD = PriceL[1] - PriceL;
if HD>0 and HD>LD then begin
DMP = DMP + HD;
end
else begin
DMP = DMP + 0;
end;
if LD>0 and LD>HD then begin
DMM = DMM + LD;
end
else begin
DMM = DMM+ 0;
end;
end;
///////////////-------3-----//////////////////
cDMIPlus = DMP*100/TR;
cDMIMinus = DMM*100/TR;
cADX = Average(AbsValue(cDMIMinus-cDMIPlus)/(cDMIMinus+cDMIPlus)*100,Len);
MyADX = 1;
Hope you can assist me on this have really been struggeling to get this code to work and give similar result as in metastock, but in multicharts!
I also looked at all the Multicharts DMI functions and infdicators, but can't seem to find any help there.
|