Jump to content

Welcome to the new Traders Laboratory! Please bear with us as we finish the migration over the next few days. If you find any issues, want to leave feedback, get in touch with us, or offer suggestions please post to the Support forum here.

  • Welcome Guests

    Welcome. You are currently viewing the forum as a guest which does not give you access to all the great features at Traders Laboratory such as interacting with members, access to all forums, downloading attachments, and eligibility to win free giveaways. Registration is fast, simple and absolutely free. Create a FREE Traders Laboratory account here.

Frank

ADX Easylanguage Code Without Calling a Function

Recommended Posts

I don't really understand programming enough to know why my Open Ecry can't call the right function to calculate ADX -- so I am copying this code that imbeds the needed function calls into the indicator --- because this works for me.

 

 

inputs:

Length(14);

 

vars:

Counter(0),

TRange(0), MyRange(Length),

PlusDM(0),MinusDM(0),

Plus14(0),

Minus14(0),

DMIup(0),DMIdn(0),

DMI_(0),

CummDMI(0), Return(0),

ADX_(0);

 

{ZZZZZZZZZZZZ...DMIup/DMIdn...ZZZZZZZZZZZZZ}

 

if CurrentBar = 1 then begin

 

MyRange = Length;

DMIup = 0;

Plus14 = 0;

Minus14 = 0;

TRange = 0;

 

for Counter = 0 to MyRange-1 begin

 

if (High[Counter] - High[Counter+1] < 0) then PlusDM = 0

else

PlusDM = High[Counter] - High[Counter+1];

 

if (Low [Counter+1] - Low [Counter] < 0) then MinusDM = 0

else

MinusDM = Low [Counter+1] - Low [Counter];

 

if MinusDM >= PlusDM then PlusDM = 0;

if PlusDM >= MinusDM then MinusDM = 0;

 

TRange= TRange + TrueRange[Counter] ;

 

Plus14 = Plus14 + PlusDM ;

Minus14 = Minus14 + MinusDM ;

 

end;{...counter=0 to myrange-1}

 

if TRange <> 0 then begin

DMIup = 100 * Plus14 / TRange;

DMIdn = 100 * Minus14 / TRange;

end

else begin

DMIup = 0 ;

DMIdn = 0;

end;

 

end{...currentbar=1}

 

else if CurrentBar > 1 then begin

 

if High[0]-High[1] < 0 then PlusDM = 0

else

PlusDM = High[0]-High[1];

 

if Low [1]-Low [0] < 0 then MinusDM = 0

else

MinusDM = Low [1]-Low [0];

 

if MinusDM >= PlusDM then PlusDM = 0;

if PlusDM >= MinusDM then MinusDM = 0;

 

if MyRange > 0 then begin

TRange = TRange[1] - (TRange[1] / MyRange) + TrueRange;

Plus14 = Plus14[1] - (Plus14[1] / MyRange) + PlusDM;

Minus14 = Minus14[1] - (Minus14[1] / MyRange) + MinusDM;

end;

 

if TRange<>0 then begin

DMIup = 100 * Plus14 / TRange;

DMIdn = 100 * Minus14 / TRange;

end

else begin

DMIup = 0;

DMIdn = 0;

end;

 

end;{...currentbar>1}

 

 

{ZZZZZZZZZZZZZZZ...DMI_...ZZZZZZZZZZZZZZZZ}

 

if DMIup + DMIdn= 0 then DMI_ = 0

else

DMI_ = 100 * AbsValue(DMIup - DMIdn)

/ (DMIup + DMIdn);

 

 

{ZZZZZZZZZZZ...ADX_...ZZZZZZZZZZZZZ}

 

Return = 0 ;

 

if CurrentBar >= 1 and Length > 0 then begin

 

if CurrentBar < Length then begin

CummDMI = 0 ;

for Counter = 0 to CurrentBar - 1 begin

CummDMI = CummDMI + DMI_[Counter] ;

end ;

Return = CummDMI / CurrentBar ;

end

else

Return = (ADX_[1] * (Length - 1) + DMI_) / Length ;

 

end ;

 

ADX_ = Return ;

 

 

{ZZZZZZZZZZZZ...Plot...ZZZZZZZZZZZZZ}

 

 

plot1(adx_,"adx");

Share this post


Link to post
Share on other sites

That seems like a lot of work. If OEC doesnt have the right function, there is a simple way to do it:

 

1) Find function you need. This can be done via google pretty easy.

Highlight function, select copy.

Go Back to your code in OEC:

2) Right Click in Code

3) Select, "Insert Function"

4) Type in Name of function that OEC Is looking for. ( a lot of the times it does this automatically, but wont hurt to double check)

 

That should add the function you need, and assuming no other errors, should compile.

 

Here's is what an ADX indicator's code looks like when you use the function:

 

inputs: 
Length( 14 ); 
ADXTrend( 25 ) ; 

variables: 
oDMIPlus( 0 ), 
oDMIMinus( 0 ), 
oDMI( 0 ), 
oADX( 0 ), 
oADXR( 0 ), 
oVolty( 0 ) ;

Value1 = DirMovement( H, L, C, Length, oDMIPlus, oDMIMinus, oDMI, oADX, oADXR, 
oVolty ) ;

Plot1( oDMIPlus, "DMI+" ) ;
Plot2( oDMIMinus, "DMI-" ) ;
Plot3( oADX, "ADX" ) ;




#function ADX
inputs: 
Length( numericsimple ) ; { this input assumed to be a constant >= 1 }

variables:
oDMIPlus( 0 ), 
oDMIMinus( 0 ), 
oDMI( 0 ), 
oADX( 0 ), 
oADXR( 0 ), 
oVolty( 0 ) ;

Value1 = DirMovement( H, L, C, Length, oDMIPlus, oDMIMinus, oDMI, oADX, oADXR, 
oVolty ) ;

ADX = oADX ;

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.