Hi,
I have written an efs that works off sma crosovers and pivots through an external efs.
The pivot efs works fine on all charts as does the sma crossover (without the efs(external) and all consequential formulas) but when this efs is loaded in anything more then a 14day timetemplate it causes esignal to crash.
Any ideas as to what needs changing would be greatly appreciated.
Thanks in advance
Min
Code is as follows:
I have written an efs that works off sma crosovers and pivots through an external efs.
The pivot efs works fine on all charts as does the sma crossover (without the efs(external) and all consequential formulas) but when this efs is loaded in anything more then a 14day timetemplate it causes esignal to crash.
Any ideas as to what needs changing would be greatly appreciated.
Thanks in advance
Min
Code is as follows:
PHP Code:
var vSMA5 = new MAStudy(5, 0, "Close", MAStudy.SIMPLE);
var vSMA15 = new MAStudy(15, 0, "Close", MAStudy.SIMPLE);
var vUpTrend = null;
var vDownTrend = null;
var vValue = -1;
var Target = null;
var Stop = null;
x = null;
y = null;
var vTradeOk = false;
function preMain() {
//{{EFSWizard_PreMain
setPriceStudy(true);
setStudyTitle("Set Profit and Stop 24hr & Pivots");
setCursorLabelName("5MA", 14);
setCursorLabelName("15MA", 15);
setDefaultBarFgColor(Color.maroon, 14);
setDefaultBarFgColor(Color.teal, 15);
setPlotType(PLOTTYPE_LINE, 14);
setPlotType(PLOTTYPE_LINE, 15);
setDefaultBarStyle(PS_SOLID, 14);
setDefaultBarStyle(PS_SOLID, 15);
setDefaultBarThickness(2, 14);
setDefaultBarThickness(2, 15);
setComputeOnClose(true)
//}}EFSWizard_PreMain
}
debugClear()
function main() {
myVar = sma( 5 );
x = myVar + 2.5;
y = myVar -2.5;
var xExample = null;
var myR1 = null;
var myR2 = null;
var myR3 = null;
var myR4 = null;
var myPP = null;
var myS1 = null;
var myS2 = null;
var myS3 = null;
var myS4 = null;
var myPH = null;
var myPL = null;
var myGap = null;
var myTH = null;
var myTL = null;
var bInit = false;
if ( bInit == false ) {
xExample = efsExternal("Pivots.efs");
bInit = true;
}
if (xExample != null) {
if (myR4 == null) myR4 = getSeries(xExample, 0);
if (myR3 == null) myR3 = getSeries(xExample, 1);
if (myR2 == null) myR2 = getSeries(xExample, 2);
if (myR1 == null) myR1 = getSeries(xExample, 3);
if (myPP == null) myPP = getSeries(xExample, 4);
if (myS1 == null) myS1 = getSeries(xExample, 5);
if (myS2 == null) myS2 = getSeries(xExample, 6);
if (myS3 == null) myS3 = getSeries(xExample, 7);
if (myS4 == null) myS4 = getSeries(xExample, 8);
if (myPH == null) myPH = getSeries(xExample, 9);
if (myPL == null) myPL = getSeries(xExample, 10);
if (myGap == null) myGap = getSeries(xExample, 11);
if (myTH == null) myTH = getSeries(xExample, 12);
if (myTL == null) myTL = getSeries(xExample, 13);
}
if (vSMA5.getValue(MAStudy.MA) < vSMA15.getValue(MAStudy.MA) &&
(vValue != 1)) {
onAction3()
}
if (vSMA5.getValue(MAStudy.MA) > vSMA15.getValue(MAStudy.MA) &&
(vValue != 2)) {
onAction4()
}
if (getBarState()==BARSTATE_NEWBAR) {
if (myR4 < high(0) && myR4 > low(0) ||
myR3 < high(0) && myR3 > low(0) ||
myR2 < high(0) && myR2 > low(0) ||
myR1 < high(0) && myR1 > low(0) ||
myPP < high(0) && myPP > low(0) ||
myS1 < high(0) && myS1 > low(0) ||
myS2 < high(0) && myS2 > low(0) ||
myS3 < high(0) && myS3 > low(0) ||
myS4 < high(0) && myS4 > low(0) ||
myGap < high(0) && myGap > low(0) )
{vTradeOk = false;}
else {vTradeOk = true;} }
if (getBarState()==BARSTATE_NEWBAR) {
if (vSMA5.getValue(MAStudy.MA) < vSMA15.getValue(MAStudy.MA) &&
vSMA5.getValue(MAStudy.MA, -1) > vDownTrend &&
vSMA5.getValue(MAStudy.MA) < vDownTrend &&
vTradeOk == 1 &&
Strategy.isShort()==false) {
Alert.playSound("Money");
Target = close(0) -6
Stop = close(0) +6
Strategy.doShort("Short",Strategy.CLOSE,Strategy.THISBAR)
drawShapeRelative(0, high(-2), Shape.DOWNARROW, "", Color.blue, Shape.BOTTOM);
} }
if (Strategy.isShort()==true) {
if (low(0)<=Target) {
Strategy.doCover("Cover",Strategy.STOP,Strategy.THISBAR,null,Target);
}
if (high(0)>=Stop){
Strategy.doCover("Cover",Strategy.STOP,Strategy.THISBAR,null,Stop);
drawShapeRelative(0, high(-2), Shape.DOWNARROW, "", Color.black, Shape.BOTTOM);
} }
if (getBarState()==BARSTATE_NEWBAR) {
if (vSMA5.getValue(MAStudy.MA) > vSMA15.getValue(MAStudy.MA) &&
vSMA5.getValue(MAStudy.MA, -1) < vUpTrend &&
vSMA5.getValue(MAStudy.MA) > vUpTrend &&
vTradeOk == 1 &&
Strategy.isLong()==false) {
Alert.playSound("Money");
Target = close(0) +6
Stop = close(0) -6
Strategy.doLong("Long", Strategy.CLOSE, Strategy.THISBAR)
drawShapeRelative(0, low(-2), Shape.UPARROW, "", Color.purple, Shape.TOP);
} }
if (Strategy.isLong()==true) {
if (high(0)>=Target) {
Strategy.doSell("Sell",Strategy.STOP,Strategy.THISBAR,null,Target);
}
if (low(0)<=Stop) {
Strategy.doSell("Sell",Strategy.STOP,Strategy.THISBAR,null,Stop);
drawShapeRelative(0, low(-2), Shape.UPARROW, "", Color.black, Shape.TOP);
} }
return new Array(
myR4 ,myR3, myR2, myR1, myPP, myS1, myS2, myS3, myS4, myPH, myPL, myGap, myTH, myTL,
vSMA5.getValue(MAStudy.MA),
vSMA15.getValue(MAStudy.MA)
);
}
//{{Action_3
function onAction3() {
// drawShapeRelative(0, high(-2), Shape.DOWNARROW, "", Color.RGB(255,0,0), Shape.BOTTOM);
// debugPrintln("y= " + y);
Alert.playSound( "C:\Program Files\eSignal\Sounds\Warning" );
drawLineRelative(0, (y), +25, (y), PS_SOLID, 2, Color.red, getValue("RawTime") + "xdownpt");
vDownTrend = y;
// debugPrintln("DownTrend = " + vDownTrend);
vValue = 1;
}
//{{Action_4
function onAction4() {
// drawShapeRelative(0, low(-2), Shape.UPARROW, "", Color.RGB(0,255,0), Shape.TOP);
// debugPrintln("x= " + x);
Alert.playSound("C:\Program Files\eSignal\Sounds\Warning");
drawLineRelative(0, (x), +25, (x), PS_SOLID, 2, Color.green, getValue("RawTime") + "xuppt");
vUpTrend = x;
// debugPrintln("UpTrend = " + vUpTrend);
vValue = 2;
}
Comment