I wrote this (borrowed parts of other people's code) and am wondering what I did wrong.
The EFS doesn't always update the chart or pop up a message. If applied to a chart of past data, it works fine. It does not always update on a live chart. Sometimes it will and sometimes it won't.
Thanks for the help.
The EFS doesn't always update the chart or pop up a message. If applied to a chart of past data, it works fine. It does not always update on a live chart. Sometimes it will and sometimes it won't.
Thanks for the help.
Code:
var vADXDM = new ADXDMStudy(14); var vLastAlert = -1; function preMain() { setPriceStudy(true); setStudyTitle("thEdge"); setShowCursorLabel(false); } function main() { if (getBarState() != BARSTATE_NEWBAR) return; if ( vADXDM.getValue(ADXDMStudy.PDI, -1) < vADXDM.getValue(ADXDMStudy.NDI, -1) && vADXDM.getValue(ADXDMStudy.PDI) > vADXDM.getValue(ADXDMStudy.NDI) ) onAction1(); else if ( vADXDM.getValue(ADXDMStudy.PDI, -1) > vADXDM.getValue(ADXDMStudy.NDI, -1) && vADXDM.getValue(ADXDMStudy.PDI) < vADXDM.getValue(ADXDMStudy.NDI) ) onAction2(); return ; } function onAction1() { setBarBgColor(Color.green); Alert.addToList(getSymbol(), "BUY", Color.black, Color.green); Alert.playSound("C:\\PROGRAM FILES\\ESIGNAL\\Sounds\\Ding.wav"); Strategy.doLong("", Strategy.MARKET, Strategy.THISBAR, Strategy.DEFAULT, 0); if (vLastAlert != 1) Strategy.doCover("", Strategy.CLOSE, Strategy.THISBAR, Strategy.ALL, 0); vLastAlert = 1; } function onAction2() { setBarBgColor(Color.red); Alert.addToList(getSymbol(), "SELL", Color.black, Color.red); Alert.playSound("C:\\PROGRAM FILES\\ESIGNAL\\Sounds\\Ding.wav"); Strategy.doShort("", Strategy.MARKET, Strategy.THISBAR, Strategy.DEFAULT, 0); if (vLastAlert != 2) Strategy.doSell("", Strategy.CLOSE, Strategy.THISBAR, Strategy.ALL, 0); vLastAlert = 2; }
Comment