Hi hope someone can figure this out.
this strategy was built using the formula wizard by selecting the built-in macd study and conditions for buy and sell signals for backtesting purposes. however when backtesting no backtesting results are produced.
i have been sucessfully backtesting other strategies containing built-in and custom studies so i have some experience with backtesting.
apologies if the code post is difficult to read i couldnt get that top line of html or whatever it is to wrap into a better width.
this strategy was built using the formula wizard by selecting the built-in macd study and conditions for buy and sell signals for backtesting purposes. however when backtesting no backtesting results are produced.
i have been sucessfully backtesting other strategies containing built-in and custom studies so i have some experience with backtesting.
apologies if the code post is difficult to read i couldnt get that top line of html or whatever it is to wrap into a better width.
PHP Code:
[CODE]//{{EFSWizard_Description
//
// This formula was generated by the Alert Wizard
//
//}}EFSWizard_Description
//{{EFSWizard_Declarations
var vMACD12_24 = new MACDStudy(12, 24, 9, "Close", false);
var vLastAlert = -1;
//}}EFSWizard_Declarations
function preMain() {
/**
* This function is called only once, before any of the bars are loaded.
* Place any study or EFS configuration commands here.
*/
//{{EFSWizard_PreMain
setPriceStudy(true);
setStudyTitle("CL_MYMACD_");
//}}EFSWizard_PreMain
}
function main() {
/**
* 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.
*/
//{{EFSWizard_Expressions
//{{EFSWizard_Expression_1
if (
Strategy.isShort(-1) == false &&
vMACD12_24.getValue(MACDStudy.MACD, -1) == vMACD12_24.getValue(MACDStudy.SIGNAL) &&
vMACD12_24.getValue(MACDStudy.MACD, -2) > vMACD12_24.getValue(MACDStudy.SIGNAL)
) onAction1()
//}}EFSWizard_Expression_1
//{{EFSWizard_Expression_2
else if (
Strategy.isLong(-1) == false &&
vMACD12_24.getValue(MACDStudy.MACD, -1) == vMACD12_24.getValue(MACDStudy.SIGNAL) &&
vMACD12_24.getValue(MACDStudy.MACD, -2) < vMACD12_24.getValue(MACDStudy.SIGNAL)
) onAction2();
//}}EFSWizard_Expression_2
//}}EFSWizard_Expressions
//{{EFSWizard_Return
return null;
//}}EFSWizard_Return
}
function postMain() {
/**
* The postMain() function is called only once, when the EFS is no longer used for
* the current symbol (ie, symbol change, chart closing, or application shutdown).
*/
}
//{{EFSWizard_Actions
//{{EFSWizard_Action_1
function onAction1() {
if (vLastAlert != 1) Strategy.doShort("SS1", Strategy.MARKET, Strategy.NEXTBAR, Strategy.DEFAULT, 0);
vLastAlert = 1;
}
//}}EFSWizard_Action_1
//{{EFSWizard_Action_2
function onAction2() {
if (vLastAlert != 2) Strategy.doLong("L1", Strategy.MARKET, Strategy.NEXTBAR, Strategy.DEFAULT, 0);
vLastAlert = 2;
}
//}}EFSWizard_Action_2
//}}EFSWizard_Actions
[/CODE]
Comment