Ever since I've been using/writing EFS studies I've been having the problem of
the chart menu options "Remove Study, Reload Study" disappearing from the right click menu? (right click on any portion of the chart and remove/reaload options are gone).
My code runs fine and back tests fine. Is there something I'm supposed to be doing upon script exit to 'clear' the state back to normal.
It pretty much always does it with this study loaded. (sorry for the messy code, starting making this one in Wizard then moved to the EFS editor)
the chart menu options "Remove Study, Reload Study" disappearing from the right click menu? (right click on any portion of the chart and remove/reaload options are gone).
My code runs fine and back tests fine. Is there something I'm supposed to be doing upon script exit to 'clear' the state back to normal.
It pretty much always does it with this study loaded. (sorry for the messy code, starting making this one in Wizard then moved to the EFS editor)
PHP Code:
var vEMA8 = new MAStudy(50, 0, "Close", MAStudy.EXPONENTIAL);
var vEMA21 = new MAStudy(130, 0, "Close", MAStudy.EXPONENTIAL);
var vLastAlert = -1;
function preMain() {
//Code_PreMain_setPriceBarColor
setColorPriceBars(true);
//Code_PreMain_setPriceBarColor
/**
* This function is called only once, before any of the bars are loaded.
* Place any study or EFS configuration commands here.
*/
setPriceStudy(true);
setStudyTitle("Base Strategy BETA 1.1");
setCursorLabelName("fast", 0);
setCursorLabelName("slow", 1);
setDefaultBarStyle(PS_SOLID, 0);
setDefaultBarStyle(PS_SOLID, 1);
setDefaultBarFgColor(Color.red, 0);
setDefaultBarFgColor(Color.white, 1);
setDefaultBarThickness(1, 0);
setDefaultBarThickness(1, 1);
setPlotType(PLOTTYPE_LINE, 0);
setPlotType(PLOTTYPE_LINE, 1);
AllowTrading = true;
daynow = new Date();
size = 100;
// size = Strategy.getDefaultLotSize(); (doesnt pass from backtester for some reason
// Below are variables passed from the edit studies configure menu.
gStop = new FunctionParameter("gStop", FunctionParameter.NUMBER);
gStop.setDefault(20);
gStop.setName("Hard Stop"); // NOT IMPLIMENTD YET
gParam2 = new FunctionParameter("gParam2", FunctionParameter.NUMBER);
gParam2.setDefault( 100 );
gParam2.setName("Parameter 2"); // FUTURE
gParam3 = new FunctionParameter("gParam3", FunctionParameter.NUMBER);
gParam3.setDefault( 100 );
gParam3.setName("Parameter 3"); // FUTURE
}
function main(gStop, gParam2, gParam3) {
/**
* 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.
*/
// Geoff Get Time
var Time = (hour(0)*100)+minute(0);
AllowTrading = true;
// debugPrintln(Time);
// EXIT TRADES AT BEGINNING OF DZ
if(Time == 1200 && Strategy.isInTrade() && Strategy.isShort() ) {
AllowTrading = false;
Strategy.doCover( "DZ Exit Short", Strategy.CLOSE, Strategy.THISBAR, Strategy.ALL ); }
else if (Time == 1200 && Strategy.isInTrade() && Strategy.isLong() ) {
AllowTrading = false;
Strategy.doSell( "DZ Exit Long", Strategy.CLOSE, Strategy.THISBAR, Strategy.ALL); }
// END DZ EXIT CODE
// EXIT TRADES AT EOD
if(Time == 1559 && Strategy.isInTrade() && Strategy.isShort() ) {
AllowTrading = false;
Strategy.doCover( "EOD Short Signal", Strategy.CLOSE, Strategy.THISBAR, Strategy.ALL ); }
else if (Time == 1559 && Strategy.isInTrade() && Strategy.isLong() ) {
AllowTrading = false;
Strategy.doSell( "EOD Long Signal", Strategy.CLOSE, Strategy.THISBAR, Strategy.ALL); }
// END EOD EXIT CODE
//{{Test for dead zone. If found goto Action1
if (
Time >= 1200 &&
Time < 1415
) onAction1()
//}}END DZ TEST
//{{Check to see if it's Friday and go lighter shares
if (
daynow.getDay() == 5
) onAction3()
//}}END FRIDAY CHECK
//{{STRATEGY CODE -------REPLACE THIS WITH SOMETHING GOOD
if (
vEMA8.getValue(MAStudy.MA) <= vEMA21.getValue(MAStudy.MA) &&
AllowTrading == true
) onAction4()
//}}
//{{
else if (
vEMA8.getValue(MAStudy.MA) >= vEMA21.getValue(MAStudy.MA) &&
AllowTrading == true
) onAction5()
//{{Return Values for MAS for graphic plotting
return new Array(
vEMA8.getValue(MAStudy.MA),
vEMA21.getValue(MAStudy.MA)
);
//}}END ARRARY RETURN
//}}END STRATEGY CODE ----------------------------------------------
}
//{{Actions
//{{Action_1
function onAction1() {
AllowTrading = false;
vLastAlert = 1;
}
//}}END Action_1
//{{Action_3
function onAction3() {
// if (vLastAlert != 3) size = (size / 2);
// vLastAlert = 3;
}
//}}END Action_3
//{{Action_4
function onAction4() {
setPriceBarColor(Color.red);
if (vLastAlert != 5) Strategy.clearStop();
if (vLastAlert != 4) Strategy.doShort("Short Entry", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
// if (vLastAlert != 5) Strategy.setStop( close(0)+gStop );
vLastAlert = 4;
}
//}}END Action_4
//{{Action_5
function onAction5() {
setPriceBarColor(Color.blue);
if (vLastAlert != 5) Strategy.clearStop();
if (vLastAlert != 5) Strategy.doLong("Long Entry", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
// if (vLastAlert != 5) Strategy.setStop( close(0)-gStop );
vLastAlert = 5;
}
//}}END Action_5
}
Comment