I do not understand why does the action 2 but directly the action 3
Thank daniru
//{{EFSWizard_Description
//
// This formula was generated by the Alert Wizard
//
//}}EFSWizard_Description
//{{EFSWizard_Declarations
var vSMA3 = new MAStudy(3, 1, "Close", MAStudy.SIMPLE);
var vMACD12_26 = new MACDStudy(12, 26, 9, "Close", false);
var vStoch5_1 = new StochStudy(5, 1, 3);
var vBollinger9 = new BollingerStudy(9, "Close", 2);
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("BT TTE LONG trealing ");
//}}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 (
high() < high(-1) &&
high(-1) > high(-2) &&
high(-2) > high(-3) &&
high(1) > high() &&
vSMA3.getValue(MAStudy.MA) < close() &&
vMACD12_26.getValue(MACDStudy.SIGNAL) < vMACD12_26.getValue(MACDStudy.MACD) &&
vMACD12_26.getValue(MACDStudy.MACD) > vMACD12_26.getValue(MACDStudy.HIST) &&
vStoch5_1.getValue(StochStudy.FAST) > vStoch5_1.getValue(StochStudy.SLOW) &&
vBollinger9.getValue(BollingerStudy.BASIS) < close()
) onAction1()
//}}EFSWizard_Expression_1
//{{EFSWizard_Expression_2
else if (
Strategy.isLong() &&
high(2) > high()+0.10
) onAction2()
//}}EFSWizard_Expression_2
//{{EFSWizard_Expression_3
else if (
low(1) < low()
) onAction3();
//}}EFSWizard_Expression_3
//}}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.doLong("", Strategy.LIMIT, Strategy.NEXTBAR, Strategy.DEFAULT, high()+0.01);
vLastAlert = 1;
}
//}}EFSWizard_Action_1
//{{EFSWizard_Action_2
function onAction2() {
if (vLastAlert != 2) Strategy.doSell("", Strategy.LIMIT, Strategy.NEXTBAR, Strategy.DEFAULT, high(2)-0.02);
vLastAlert = 2;
}
//}}EFSWizard_Action_2
//{{EFSWizard_Action_3
function onAction3() {
if (vLastAlert != 3) Strategy.doSell("", Strategy.LIMIT, Strategy.NEXTBAR, Strategy.DEFAULT, low()-0.01);
vLastAlert = 3;
}
//}}EFSWizard_Action_3
//}}EFSWizard_Actions
Thank daniru
//{{EFSWizard_Description
//
// This formula was generated by the Alert Wizard
//
//}}EFSWizard_Description
//{{EFSWizard_Declarations
var vSMA3 = new MAStudy(3, 1, "Close", MAStudy.SIMPLE);
var vMACD12_26 = new MACDStudy(12, 26, 9, "Close", false);
var vStoch5_1 = new StochStudy(5, 1, 3);
var vBollinger9 = new BollingerStudy(9, "Close", 2);
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("BT TTE LONG trealing ");
//}}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 (
high() < high(-1) &&
high(-1) > high(-2) &&
high(-2) > high(-3) &&
high(1) > high() &&
vSMA3.getValue(MAStudy.MA) < close() &&
vMACD12_26.getValue(MACDStudy.SIGNAL) < vMACD12_26.getValue(MACDStudy.MACD) &&
vMACD12_26.getValue(MACDStudy.MACD) > vMACD12_26.getValue(MACDStudy.HIST) &&
vStoch5_1.getValue(StochStudy.FAST) > vStoch5_1.getValue(StochStudy.SLOW) &&
vBollinger9.getValue(BollingerStudy.BASIS) < close()
) onAction1()
//}}EFSWizard_Expression_1
//{{EFSWizard_Expression_2
else if (
Strategy.isLong() &&
high(2) > high()+0.10
) onAction2()
//}}EFSWizard_Expression_2
//{{EFSWizard_Expression_3
else if (
low(1) < low()
) onAction3();
//}}EFSWizard_Expression_3
//}}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.doLong("", Strategy.LIMIT, Strategy.NEXTBAR, Strategy.DEFAULT, high()+0.01);
vLastAlert = 1;
}
//}}EFSWizard_Action_1
//{{EFSWizard_Action_2
function onAction2() {
if (vLastAlert != 2) Strategy.doSell("", Strategy.LIMIT, Strategy.NEXTBAR, Strategy.DEFAULT, high(2)-0.02);
vLastAlert = 2;
}
//}}EFSWizard_Action_2
//{{EFSWizard_Action_3
function onAction3() {
if (vLastAlert != 3) Strategy.doSell("", Strategy.LIMIT, Strategy.NEXTBAR, Strategy.DEFAULT, low()-0.01);
vLastAlert = 3;
}
//}}EFSWizard_Action_3
//}}EFSWizard_Actions
Comment