Announcement

Collapse
No announcement yet.

+DM -DM price bars

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

  • +DM -DM price bars

    Hello could u please look and see what i'm missing in this code.
    I'm trying to get the price bars go green when +DM crosses up thru -DM and red price bars when the opposite occours.

    Your help would be much apprieciated.

    /************************************************** *******
    Alexis C. Montenegro © July 2003
    Use and/or modify this code freely. If you redistribute it
    please include this and/or any other comment blocks and a
    description of any changes you make.
    ************************************************** ********/

    var vADX = null

    function preMain() {
    setPriceStudy(false);
    setStudyTitle("ADXDM");
    setCursorLabelName("ADX", 0);
    setCursorLabelName("+DI", 1);
    setCursorLabelName("-DI", 2);
    setDefaultBarFgColor(Color.RGB(255, 0, 255), 0); //adx color
    setDefaultBarFgColor(Color.green, 1); //+DI color
    setDefaultBarFgColor(Color.red, 2); //-DI color
    setDefaultBarThickness(1,0); //ADX Line thickness
    setDefaultBarThickness(1,1); //+DI Line thickness
    setDefaultBarThickness(1,2); //-DI Line thickness
    setColorPriceBars(true);
    setDefaultPriceBarColor(Color.grey);

    var fp1 = new FunctionParameter("DILength", FunctionParameter.NUMBER);
    fp1.setLowerLimit(1);
    fp1.setDefault(14); //Edit this value to set a new default

    var fp2 = new FunctionParameter("ADXLength", FunctionParameter.NUMBER);
    fp2.setLowerLimit(1);
    fp2.setDefault(14); //Edit this value to set a new default

    }




    function main(DILength, ADXLength) {

    if (vADX == null) vADX = new ADXDMStudy(DILength, ADXLength);



    /************************************************** ****************
    Insert your code following this text block
    Use vADX.getValue(ADXDMStudy.ADX) and vADX.getValue(ADXDMStudy.PDI)
    and vADX.getValue(ADXDMStudy.NDI) for your code
    ************************************************** *****************/

    if(vADX.getValue(ADXDMStudy.PDI)<vADX.getValue(ADX DMStudy.NDI));
    setPriceBarColor(Color.red);

    if(vADX.getValue(ADXDMStudy.PDI)>vADX.getValue(ADX DMStudy.NDI));
    setPriceBarColor(Color.white);

    else if(1==1)
    setPriceBarColor(Color.yellow);

    return new Array(vADX.getValue(ADXDMStudy.ADX), vADX.getValue(ADXDMStudy.PDI), vADX.getValue(ADXDMStudy.NDI));

    }

  • #2
    abbers
    Replace the relevant code with the one enclosed below

    PHP Code:
    if(vADX.getValue(ADXDMStudy.PDI)<vADX.getValue(ADXDMStudy.NDI))
        
    setPriceBarColor(Color.red);
        
        else if(
    vADX.getValue(ADXDMStudy.PDI)>vADX.getValue(ADXDMStudy.NDI))
        
    setPriceBarColor(Color.green);
        
        else if(
    1==1)
        
    setPriceBarColor(Color.yellow); 
    Actually, since you do have a default color for the price bars defined in preMain() you can reduce the above code to the following

    PHP Code:
    if(vADX.getValue(ADXDMStudy.PDI)<vADX.getValue(ADXDMStudy.NDI))
        
    setPriceBarColor(Color.red);
        
        if(
    vADX.getValue(ADXDMStudy.PDI)>vADX.getValue(ADXDMStudy.NDI))
        
    setPriceBarColor(Color.green); 
    and skip the else if(1==1) etc
    Alex

    Comment


    • #3
      Thanks dude

      Comment

      Working...
      X