Announcement

Collapse
No announcement yet.

Color coded ADX

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Color coded ADX

    The following code was written in Easy Language for Tradestation. Can I get this rewritten in EFS ?
    Thanks


    This Indicator plots the ADX (Average Directional
    Movement Index)with color bands to indicate levels.

    ************************************************** **

    Inputs: Length(14),LowestLevel(10),LowLevel(20),MedLevel(3 0),HighLevel(40),
    LowestColor(DarkRed),LowColor(Red),MedColor(Blue), HighColor(Green),HighestColor(White);

    If CurrentBar >= Length Then Begin
    If ADX(Length) <= LowestLevel then Plot1(ADX(Length) ,"ADX", LowestColor, Default);
    If ADX(Length) <= LowLevel and ADX(Length) > LowestLevel then Plot1(ADX(Length) ,"ADX", LowColor, Default);
    If ADX(Length) <= MedLevel and ADX(Length) > LowLevel then Plot1(ADX(Length) ,"ADX", MedColor, Default);
    If ADX(Length) > MedLevel and ADX(Length) < HighLevel then Plot1(ADX(Length) ,"ADX", HighColor, Default);
    If ADX(Length) >= HighLevel then Plot1(ADX(Length) ,"ADX", HighestColor, Default);

  • #2
    cereus,

    Attached you will find a translation for this study into EFS, and below is the code.

    PHP Code:
    /************************
    Copyright © eSignal, 2003
    *************************

    Description: This is a color coded ADX study.

    Inputs:

    nDILength - Length of DI (default is 14)
    nADXSmooth - Smoothing of ADX (default is 14)
    nLowestLevel - Lowest Color Level (default is 10)
    nLowLevel - Low Color Level (default is 20)
    nMedLevel - Medium Color Level (default is 30)
    nHighLevel - High Color Level (default is 40)
    nLowestColor - Lowest Color (default is Dark Red)
    nLowColor - Low Color (default is Red)
    nMedColor - Medium Color (default is Blue)
    nHighColor - High Color (default is Green)
    nHighestColor - Highest Color (default is White)

    */

    //var study = new ADXDMStudy(14, 14);
    var study null;
    var 
    vColor null;

    function 
    preMain() {

        
    setStudyTitle("ADX Color");
        
    setCursorLabelName("ADX");
        
    setDefaultBarThickness(2);
    }

    function 
    main(  nDILength,
                    
    nADXSmooth,
                    
    nLowestLevel,
                    
    nLowLevel,
                    
    nMedLevel,
                    
    nHighLevel,
                    
    nLowestColor,
                    
    nLowColor,
                    
    nMedColor,
                    
    nHighColor,
                    
    nHighestColor) {

        
    // check inputs and set defaults
        
    if (nDILength == null) {
            
    nDILength 14;
        } else {
            
    nDILength Math.round(nDILength);
        }
            
        if (
    nADXSmooth == null) {
            
    nADXSmooth 14;
        } else {
            
    nADXSmooth Math.round(nADXSmooth);
        }
            
        if (
    nLowestLevel == nullnLowestLevel 10;
        if (
    nLowLevel == nullnLowLevel 20;
        if (
    nMedLevel == nullnMedLevel 30;
        if (
    nHighLevel == nullnHighLevel 40;
            
        
    /***   Valid Colors  ***
                aqua, black, blue, brown, cyan, darkgreen,
                darkgrey, fushcia, green, grey, khaki,
                lightgrey, lightyellow, lime, magenta,
                maroon, navy, olive, paleyellow, purple,
                red, teal, white, yellow
        ************************/
            
        
    if (nLowestColor == null) {
            
    nLowestColor Color.maroon;
        } else {
            
    nLowestColor = eval("Color."+nLowestColor);
        }
            
        if (
    nLowColor == null) {
            
    nLowColor Color.red;
        } else {
            
    nLowColor = eval("Color."+nLowColor);
        }
           
        if (
    nMedColor == null) {
            
    nMedColor Color.blue;
        } else {
            
    nMedColor = eval("Color."+nMedColor);
        }
            
        if (
    nHighColor == null) {
            
    nHighColor Color.green;
        } else {
            
    nHighColor = eval("Color."+nHighColor);
        }
            
        if (
    nHighestColor == null) {
            
    nHighestColor Color.white;
        } else {
            
    nHighestColor = eval("Color."+nHighestColor);
        }
            
        if (
    study == nullstudy = new ADXDMStudy(nDILength,nADXSmooth);
        
        var 
    vADX study.getValue(ADXDMStudy.ADX);
        if (
    vADX == null) return;
        
        
    // set color
        
    if (vADX <= nLowestLevel) {
            
    vColor nLowestColor;
            
        } else if (
    vADX <= nLowLevel) {
            
    vColor nLowColor;
            
        } else if (
    vADX <= nMedLevel) {
            
    vColor nMedColor;
            
        } else if (
    vADX <= nHighLevel) {
            
    vColor nHighColor;
            
        } else {
            
    vColor nHighestColor;
        }
        
        if (
    vColor != nullsetBarFgColor (vColor);
        
        return 
    vADX;

    Attached Files
    Regards,
    Jay F.
    Product Manager
    _____________________________________
    Have a suggestion to improve our products?
    Click Support --> Request a Feature in eSignal 11

    Comment


    • #3
      ADX color code

      Thank you Jay F !I really appreciate your effort

      Comment

      Working...
      X