Announcement

Collapse
No announcement yet.

Need Help with Plot Circle on MACD

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

  • Need Help with Plot Circle on MACD

    I've been trying to make a study that plots a circle below the price bars on the Chart, when the 2 lines cross on MACD, not when MACD crosses the "0" line.

    On a 233t chart at roughly 1:31pm today (6-16-08) MACD crossed to the downside but I got no circle on the chart.

    Also, it doesn't always do it in real time. Sometimes it will work in real time sometimes it won't.

    Anyone know the answer to these 2 problems?

    Thanks,
    Jeremiah


    Here is the code -

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


    //{{EFSWizard_Declarations
    var vMACD12_26 = new MACDStudy(13, 21, 8, "close", false);
    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(true);
    setStudyTitle("MACD Dot")
    setComputeOnClose();
    //}}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 (
    vMACD12_26.getValue(MACDStudy.MACD) > vMACD12_26.getValue(MACDStudy.SIGNAL)
    ) onAction1()
    //}}EFSWizard_Expression_1

    //{{EFSWizard_Expression_2
    else if (
    vMACD12_26.getValue(MACDStudy.SIGNAL) > vMACD12_26.getValue(MACDStudy.MACD)
    ) onAction2();
    //}}EFSWizard_Expression_2

    //}}EFSWizard_Expressions


    //{{EFSWizard_Return
    return null;
    //}}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() {
    if (vLastAlert != 1) drawShapeRelative(0, high(0)+.25, Shape.CIRCLE, "", Color.RGB(0,255,255), Shape.TOP);
    vLastAlert = 1;
    }
    //}}EFSWizard_Action_1

    //{{EFSWizard_Action_2
    function onAction2() {
    if (vLastAlert != 2) drawShapeRelative(0, low(0)-.1, Shape.CIRCLE, "", Color.RGB(255,255,0), Shape.BOTTOM);
    vLastAlert = 2;
    }
    //}}EFSWizard_Action_2

    //}}EFSWizard_Actions
    Last edited by jphillips9; 06-16-2008, 11:52 AM.

  • #2
    Re: Need Help with Plot Circle on MACD

    Jeremiah
    After running the script in both real time and Tick Replay and comparing the signals to a plot of the MACD the formula appears to be working fine. When running your tests make sure that the MACD indicator is set up exactly the same as the one in the formula.
    If you are still seeing some discrepancies post an image of a chart in which you are running your formula and a MACD indicator so that I or someone else can try to replicate it
    Alex


    Originally posted by jphillips9
    I've been trying to make a study that plots a circle below the price bars on the Chart, when the 2 lines cross on MACD, not when MACD crosses the "0" line.

    On a 233t chart at roughly 1:31pm today (6-16-08) MACD crossed to the downside but I got no circle on the chart.

    Also, it doesn't always do it in real time. Sometimes it will work in real time sometimes it won't.

    Anyone know the answer to these 2 problems?

    Thanks,
    Jeremiah


    Here is the code -

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


    //{{EFSWizard_Declarations
    var vMACD12_26 = new MACDStudy(13, 21, 8, "close", false);
    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(true);
    setStudyTitle("MACD Dot")
    setComputeOnClose();
    //}}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 (
    vMACD12_26.getValue(MACDStudy.MACD) > vMACD12_26.getValue(MACDStudy.SIGNAL)
    ) onAction1()
    //}}EFSWizard_Expression_1

    //{{EFSWizard_Expression_2
    else if (
    vMACD12_26.getValue(MACDStudy.SIGNAL) > vMACD12_26.getValue(MACDStudy.MACD)
    ) onAction2();
    //}}EFSWizard_Expression_2

    //}}EFSWizard_Expressions


    //{{EFSWizard_Return
    return null;
    //}}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() {
    if (vLastAlert != 1) drawShapeRelative(0, high(0)+.25, Shape.CIRCLE, "", Color.RGB(0,255,255), Shape.TOP);
    vLastAlert = 1;
    }
    //}}EFSWizard_Action_1

    //{{EFSWizard_Action_2
    function onAction2() {
    if (vLastAlert != 2) drawShapeRelative(0, low(0)-.1, Shape.CIRCLE, "", Color.RGB(255,255,0), Shape.BOTTOM);
    vLastAlert = 2;
    }
    //}}EFSWizard_Action_2

    //}}EFSWizard_Actions

    Comment


    • #3
      Thanks Alex,

      The ones I couldn't see were being covered up by another study.

      I should have known to remove all the other studies.

      Jeremiah

      Comment


      • #4
        Jeremiah
        You are most welcome and I am glad to hear you resolved the problem
        Alex


        Originally posted by jphillips9
        Thanks Alex,

        The ones I couldn't see were being covered up by another study.

        I should have known to remove all the other studies.

        Jeremiah

        Comment

        Working...
        X