| File Name: MACDx-over.efs
Description: This is an MACD crossover formula, which draws yellow arrows at the crossover points.
Formula Parameters: nFastLength: Default is 12. nSlowLength: Default is 26. nSmoothing: Default is 9. nPriceSource: Default is Close (valid inputs: Open, High, Low, Close, HL/2, HLC/3 and OHLC/4). nSimpleMA_TorF: Default is False (True = Simple Moving Average, False = Exponential Moving Average).
Notes: If used on an intra-day interval, the arrows will be drawn or removed intra-bar as the conditions change.
Download File: MACDx-over.efs

EFS Code:
/*********************************Provided By : eSignal. (c) Copyright 2003*********************************/function preMain() { setStudyTitle("MACD X-Over "); setDefaultBarFgColor(Color.magenta, 0); // hist setDefaultBarFgColor(Color.red, 1); // signal setDefaultBarFgColor(Color.blue, 2); // macd setPlotType(PLOTTYPE_HISTOGRAM, 0); setCursorLabelName("Hist", 0); setCursorLabelName("Signal", 1); setCursorLabelName("MACD", 2);}var study = null;var vMACD = null;var vMACD1 = null;var vSignal = null;var vSignal1 = null;var vAlert = false;var AlertCntr = 0;function main(nFastLength, nSlowLength, nSmoothing, nPriceSource, nSimpleMA_TorF) { var nState = getBarState(); if (study == null) { if (nFastLength == null) nFastLength = 12; if (nSlowLength == null) nSlowLength = 26; if (nSmoothing == null) nSmoothing = 9; if (nPriceSource == null) { nPriceSource = "Close"; } else if(nPriceSource == "C" || nPriceSource == "O" || nPriceSource == "H" || nPriceSource == "L") { nPriceSource = nPriceSource; } else if(nPriceSource == "Close" || nPriceSource == "Open" || nPriceSource == "High" || nPriceSource == "Low") { nPriceSource = nPriceSource; } else if(nPriceSource == "HL/2" || nPriceSource == "HLC/3" || nPriceSource == "OHLC/4") { nPriceSource = nPriceSource; } else { nPriceSource = "Close"; } if (nSimpleMA_TorF == null) { nSimpleMA_TorF = false; } else if (nSimpleMA_TorF == "T" || nSimpleMA_TorF == "t" || nSimpleMA_TorF == "true" || nSimpleMA_TorF == "True") { nSimpleMA_TorF = true; } else if (nSimpleMA_TorF == "F" || nSimpleMA_TorF == "f" || nSimpleMA_TorF == "false" || nSimpleMA_TorF == "False") { nSimpleMA_TorF = false; } else { nSimpleMA_TorF = false; } study = new MACDStudy(nFastLength, nSlowLength, nSmoothing, nPriceSource, eval(nSimpleMA_TorF)); } if (nState == BARSTATE_NEWBAR) { if (vMACD != null) vMACD1 = vMACD; if (vSignal != null) vSignal1 = vSignal; vAlert = false; } vMACD = study.getValue(MACDStudy.MACD); if (vMACD == null) return; vSignal = study.getValue(MACDStudy.SIGNAL); if (vSignal == null) return; var vHist = study.getValue(MACDStudy.HIST); if (vHist == null) return; if (vAlert == false) { if (vMACD1 < vSignal1 && vMACD >= vSignal) { // crossing up vAlert = true; AlertCntr += 1; drawShapeRelative(0, vSignal, Shape.UPARROW, null, Color.yellow, Shape.TOP | Shape.ONTOP, "Alert" + AlertCntr); } if (vMACD1 > vSignal1 && vMACD <= vSignal) { // crossing down vAlert = true; AlertCntr += 1; drawShapeRelative(0, vSignal, Shape.DOWNARROW, null, Color.yellow, Shape.BOTTOM | Shape.ONTOP, "Alert" + AlertCntr); } } else { if ((vMACD1 < vSignal1 && vMACD < vSignal) || (vMACD1 > vSignal1 && vMACD > vSignal)) { vAlert = false; removeShape("Alert" + AlertCntr); } } return new Array(vHist, vSignal, vMACD);} |
|