Announcement

Collapse
No announcement yet.

Alert arrows won't display on crossover

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

  • Alert arrows won't display on crossover

    I'm trying to develop an ADX study that shows an up arrow when the +DI crosses the -DI and the ADX is above or equal to a certain value (18 for example) or a down arrow when the reverse is true. As an example, at the last bar the +DI is less than the -DI and on the current bar the +DI is greater than the -DI, all while being above or equal to an ADX value of 18. Any help would be greatly appreciated.


    //{{EFSWizard_Description
    //
    // This formula was generated by the Alert Wizard
    //
    //}}EFSWizard_Description


    //{{EFSWizard_Declarations
    var vADXDM14_14 = new ADXDMStudy(14, 14);
    var vLastAlert = -1;
    //}}EFSWizard_Declarations


    function preMain() {
    /**
    * This function is called only once, before any of the bars are loaded.
    * Place any study or EFS configuration commands here.
    */
    //{{EFSWizard_PreMain
    setPriceStudy(false);
    setStudyTitle("ADX Crossover");
    setCursorLabelName("ADX", 0);
    setCursorLabelName("PDI", 1);
    setCursorLabelName("NDI", 2);
    setDefaultBarStyle(PS_SOLID, 0);
    setDefaultBarStyle(PS_SOLID, 1);
    setDefaultBarStyle(PS_SOLID, 2);
    setDefaultBarFgColor(Color.green, 0);
    setDefaultBarFgColor(Color.blue, 1);
    setDefaultBarFgColor(Color.red, 2);
    setDefaultBarThickness(2, 0);
    setDefaultBarThickness(1, 1);
    setDefaultBarThickness(1, 2);
    setPlotType(PLOTTYPE_LINE, 0);
    setPlotType(PLOTTYPE_LINE, 1);
    setPlotType(PLOTTYPE_LINE, 2);
    //}}EFSWizard_PreMain

    }

    function main() {
    /**
    * The main() function is called once per bar on all previous bars, once per
    * each incoming completed bar, and if you don't have 'setComputeOnClose(true)'
    * in your preMain(), it is also called on every tick.
    */

    //{{EFSWizard_Expressions
    //{{EFSWizard_Expression_1
    if (
    vADXDM14_14.getValue(ADXDMStudy.PDI) > vADXDM14_14.getValue(ADXDMStudy.NDI) &&
    vADXDM14_14.getValue(ADXDMStudy.PDI, -1) < vADXDM14_14.getValue(ADXDMStudy.NDI, -1) &&
    vADXDM14_14.getValue(ADXDMStudy.PDI) >= vADXDM14_14.getValue(ADXDMStudy.ADX) &&
    vADXDM14_14.getValue(ADXDMStudy.ADX) >= 18
    ) onAction1()
    //}}EFSWizard_Expression_1

    //{{EFSWizard_Expression_2
    else if (
    vADXDM14_14.getValue(ADXDMStudy.NDI) > vADXDM14_14.getValue(ADXDMStudy.PDI) &&
    vADXDM14_14.getValue(ADXDMStudy.NDI, -1) < vADXDM14_14.getValue(ADXDMStudy.PDI, -1) &&
    vADXDM14_14.getValue(ADXDMStudy.NDI) >= vADXDM14_14.getValue(ADXDMStudy.ADX) &&
    vADXDM14_14.getValue(ADXDMStudy.ADX) >= 18
    ) onAction2();
    //}}EFSWizard_Expression_2

    //}}EFSWizard_Expressions


    //{{EFSWizard_Return
    return new Array(
    vADXDM14_14.getValue(ADXDMStudy.ADX),
    vADXDM14_14.getValue(ADXDMStudy.PDI),
    vADXDM14_14.getValue(ADXDMStudy.NDI)
    );
    //}}EFSWizard_Return

    }

    function postMain() {
    /**
    * The postMain() function is called only once, when the EFS is no longer used for
    * the current symbol (ie, symbol change, chart closing, or application shutdown).
    */
    }

    //{{EFSWizard_Actions
    //{{EFSWizard_Action_1
    function onAction1() {
    drawShapeRelative(0, close(), Shape.UPARROW, "", Color.RGB(0,128,0), Shape.TOP);
    vLastAlert = 1;
    }
    //}}EFSWizard_Action_1

    //{{EFSWizard_Action_2
    function onAction2() {
    drawShapeAbsolute(0, close(), Shape.DOWNARROW, "", Color.RGB(255,0,0), Shape.TOP);
    vLastAlert = 2;
    }
    //}}EFSWizard_Action_2

    //}}EFSWizard_Actions
    Last edited by atxtrader; 10-01-2008, 01:20 PM.

  • #2
    Re: Alert arrows won't display on crossover

    atxtrader
    If you are trying to draw those arrows in the price pane then you need to be aware that an efs only outputs to the same pane in which it is running (it can however color the price bars even if running in a different pane)
    If instead you want draw the arrows in the indicator pane then you need to replace the yValue that you used in the drawShapeRelative() command ie close() with one of the ADX values such as for example vADXDM14_14.getValue(ADXDMStudy.PDI) so that the shape will be drawn at a value that is within the scale of the indicator
    Note also that in Set2 you used the drawShapeAbsolute() function instead of drawShapeRelative().
    Lastly you need to add a tagName that is unique to each graphic object and to each bar so that you do not get multiple arrows on the same bar. In the example shown in the enclosed screenshot I am using "dnarrow"+getCurrentBarCount()
    Once you make these changes you should see the arrows drawn in the indicator pane in correspondence to the locations where your conditions are met
    Alex




    Originally posted by atxtrader
    I'm trying to develop an ADX study that shows an up arrow when the +DI crosses the -DI and the ADX is above or equal to a certain value (18 for example) or a down arrow when the reverse is true. As an example, at the last bar the +DI is less than the -DI and on the current bar the +DI is greater than the -DI, all while being above or equal to an ADX value of 18. Any help would be greatly appreciated.


    //{{EFSWizard_Description
    //
    // This formula was generated by the Alert Wizard
    //
    //}}EFSWizard_Description


    //{{EFSWizard_Declarations
    var vADXDM14_14 = new ADXDMStudy(14, 14);
    var vLastAlert = -1;
    //}}EFSWizard_Declarations


    function preMain() {
    /**
    * This function is called only once, before any of the bars are loaded.
    * Place any study or EFS configuration commands here.
    */
    //{{EFSWizard_PreMain
    setPriceStudy(false);
    setStudyTitle("ADX Crossover");
    setCursorLabelName("ADX", 0);
    setCursorLabelName("PDI", 1);
    setCursorLabelName("NDI", 2);
    setDefaultBarStyle(PS_SOLID, 0);
    setDefaultBarStyle(PS_SOLID, 1);
    setDefaultBarStyle(PS_SOLID, 2);
    setDefaultBarFgColor(Color.green, 0);
    setDefaultBarFgColor(Color.blue, 1);
    setDefaultBarFgColor(Color.red, 2);
    setDefaultBarThickness(2, 0);
    setDefaultBarThickness(1, 1);
    setDefaultBarThickness(1, 2);
    setPlotType(PLOTTYPE_LINE, 0);
    setPlotType(PLOTTYPE_LINE, 1);
    setPlotType(PLOTTYPE_LINE, 2);
    //}}EFSWizard_PreMain

    }

    function main() {
    /**
    * The main() function is called once per bar on all previous bars, once per
    * each incoming completed bar, and if you don't have 'setComputeOnClose(true)'
    * in your preMain(), it is also called on every tick.
    */

    //{{EFSWizard_Expressions
    //{{EFSWizard_Expression_1
    if (
    vADXDM14_14.getValue(ADXDMStudy.PDI) > vADXDM14_14.getValue(ADXDMStudy.NDI) &&
    vADXDM14_14.getValue(ADXDMStudy.PDI, -1) < vADXDM14_14.getValue(ADXDMStudy.NDI, -1) &&
    vADXDM14_14.getValue(ADXDMStudy.PDI) >= vADXDM14_14.getValue(ADXDMStudy.ADX) &&
    vADXDM14_14.getValue(ADXDMStudy.ADX) >= 18
    ) onAction1()
    //}}EFSWizard_Expression_1

    //{{EFSWizard_Expression_2
    else if (
    vADXDM14_14.getValue(ADXDMStudy.NDI) > vADXDM14_14.getValue(ADXDMStudy.PDI) &&
    vADXDM14_14.getValue(ADXDMStudy.NDI, -1) < vADXDM14_14.getValue(ADXDMStudy.PDI, -1) &&
    vADXDM14_14.getValue(ADXDMStudy.NDI) >= vADXDM14_14.getValue(ADXDMStudy.ADX) &&
    vADXDM14_14.getValue(ADXDMStudy.ADX) >= 18
    ) onAction2();
    //}}EFSWizard_Expression_2

    //}}EFSWizard_Expressions


    //{{EFSWizard_Return
    return new Array(
    vADXDM14_14.getValue(ADXDMStudy.ADX),
    vADXDM14_14.getValue(ADXDMStudy.PDI),
    vADXDM14_14.getValue(ADXDMStudy.NDI)
    );
    //}}EFSWizard_Return

    }

    function postMain() {
    /**
    * The postMain() function is called only once, when the EFS is no longer used for
    * the current symbol (ie, symbol change, chart closing, or application shutdown).
    */
    }

    //{{EFSWizard_Actions
    //{{EFSWizard_Action_1
    function onAction1() {
    drawShapeRelative(0, close(), Shape.UPARROW, "", Color.RGB(0,128,0), Shape.TOP);
    vLastAlert = 1;
    }
    //}}EFSWizard_Action_1

    //{{EFSWizard_Action_2
    function onAction2() {
    drawShapeAbsolute(0, close(), Shape.DOWNARROW, "", Color.RGB(255,0,0), Shape.TOP);
    vLastAlert = 2;
    }
    //}}EFSWizard_Action_2

    //}}EFSWizard_Actions

    Comment


    • #3
      After trying to solve this on my own for two days, that's exactly what I needed, it's working perfectly now. Thank you SO MUCH for your help.

      ATXT

      Comment


      • #4
        ATXT
        You are most welcome
        Alex


        Originally posted by atxtrader
        After trying to solve this on my own for two days, that's exactly what I needed, it's working perfectly now. Thank you SO MUCH for your help.

        ATXT

        Comment


        • #5
          did anyone follow up on this thread, in regards to the alerts?

          Comment

          Working...
          X