Announcement

Collapse
No announcement yet.

MACD crossover

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

  • MACD crossover

    please create a MACD crossover scripts for a 60min. time frame that can be used with your alert service. thank you!

    MACD fast line crosses over or below MACD slow line for (60min chart)

    Im very new to this concept, I guess what im looking for is a formula that allows me to enter an equity symbol I guess into the script and be notified via E-mail whenever there is a MACD crossover, above or below the slow line in the 60min time frame. Is that possible?
    Last edited by bgreenberg; 10-02-2003, 05:20 PM.

  • #2
    Hi,

    Please see the code below and let me know how it works.

    Regards,
    Andy

    var macd = null;

    function preMain() {
    setPriceStudy(true);
    setColorPriceBars(true);
    setDefaultPriceBarColor(Color.grey);
    setStudyTitle("MACD Strategy");
    }

    function main(Slow,Fast) {
    if(Slow == null)
    Slow = 26;
    if(Fast == null)
    Fast = 12;
    if(macd == null)
    macd = new MACDStudy(Fast, Slow, 9, "Close", false);

    var vHL = high() - low();
    var vVar = vHL * 0.25;
    var vAddVar = vVar * 0.35;

    if( macd.getValue(MACDStudy.MACD) > macd.getValue(MACDStudy.SIGNAL) && !Strategy.isLong()){
    Strategy.doLong("Long", Strategy.MARKET, Strategy.NEXTBAR);
    drawShapeRelative(0, low() - vVar, Shape.UPARROW, "", Color.lime, null, "buyShp" + getValue("time"));
    drawTextRelative(-1, low() - (vVar + vAddVar), "Buy", Color.black, Color.lime, Text.BOLD | Text.ONTOP, null, null, "buyTxt" + getValue("time"));
    }

    if( macd.getValue(MACDStudy.MACD) < macd.getValue(MACDStudy.SIGNAL) && !Strategy.isShort()){
    Strategy.doShort("Short", Strategy.MARKET, Strategy.NEXTBAR);
    drawShapeRelative(0, high() + vVar, Shape.DOWNARROW, "", Color.red, null, "sellShp" + getValue("time"));
    drawTextRelative(-1, high() + (vVar + vAddVar), "Sell", Color.black, Color.red, Text.BOTTOM | Text.BOLD | Text.ONTOP, null, null, "buyTxt" + getValue("time"));
    }

    if(Strategy.isLong())
    setPriceBarColor(Color.lime);
    else if(Strategy.isShort())
    setPriceBarColor(Color.red);
    return;
    }

    Comment

    Working...
    X