Below I've attached an abbreviated EFS that was first created with the Wizard then modified with the editor. The problem I am having occurs intra bar. Often times I will get an intrabar signal (which is what I want and why I used strategy.CLOSE of THISBAR) but the problem is when the signal is false the background color does not change back to neutral grey. I think it occurs when it first mets my BUY/SELL condition but then the conditions change but not enough to meet my EXIT conditions, so I'm stuck inbetween signals? I'm neither in a trade nor my exit conditions have not been met either. Unless I refresh the EFS by reloading it or the chart the background stays the same. Am I making any sense?
function preMain() {
setPriceStudy(true);
setStudyTitle("Signal 7 - large time frame");
}
function main() {
var vState = getBarState();
//Expression_1_ENTRY_LONG
if (
ENTRY CONDITION
) onAction1()
//Expression_2_ENTRY_SHORT
if(
SHORT CONDITION
) onAction2()
//Expression_3_EXIT_LONG
if (
Strategy.isLong() &&
EXIT LONG CONDITION
) onAction3()
//Expression_4_EXIT_SHORT
if (
Strategy.isShort()&&
EXIT SHORT CONDITION
) onAction4();
//background colors
if (
Strategy.isLong()){
setBarBgColor(Color.RGB(233,255,233));
}
if (
Strategy.isShort()){
setBarBgColor(Color.RGB(255,233,233));
}
else if (
!Strategy.isInTrade()){
setBarBgColor(Color.RGB(192,192,192));
}
//alerts for NEWBAR
if (
Strategy.isLong() &&
(getHour()*100)+getMinute() > vt1 &&
vState == (BARSTATE_NEWBAR))
{
Alert.playSound("C:\\Program Files\\eSignal\\Sounds\\Ding.wav");
Alert.addToList(getSymbol(), "Buy Signal large time frame", Color.RGB(0,0,0), Color.RGB(0,255,0));
}
if (
Strategy.isShort() &&
(getHour()*100)+getMinute() > vt1 &&
vState == (BARSTATE_NEWBAR))
{
Alert.playSound("C:\\Program Files\\eSignal\\Sounds\\Ding.wav");
Alert.addToList(getSymbol(), "Sell Signal large time frame", Color.RGB(0,0,0), Color.RGB(195,0,0));
}
else if (
(!Strategy.isInTrade()) &&
(getHour()*100)+getMinute() > vt1 &&
vState == (BARSTATE_NEWBAR))
{
Alert.playSound("C:\\Program Files\\eSignal\\Sounds\\Ding.wav");
Alert.addToList(getSymbol(), "Exit all trades large time frame", Color.RGB(0,0,0), Color.RGB(195,0,0));
}
//{{_Return
return null;
//}}_Return 2256
}
function postMain() {
}
//{{Action_1
function onAction1() {
if (vLastAlert != 1) Strategy.doLong("", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
vLastAlert = 1;
}
//{{Action_2!
function onAction2() {
if (vLastAlert != 2) Strategy.doShort("", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
vLastAlert = 2;
}
//{{Action_3_EXIT_LONG
function onAction3() {
if (vLastAlert != 3) Strategy.doSell("", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
vLastAlert = 3;
}
//{{Action_4_EXIT_SHORT
function onAction4() {
if (vLastAlert != 4) Strategy.doCover("", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
vLastAlert = 4;
}
I think it has something to do with the vLastAlert system, is there a different way to do this? I want the background color to indicate whether or not I'm long/short or neutral and update tick by tick.
thanks
morph
function preMain() {
setPriceStudy(true);
setStudyTitle("Signal 7 - large time frame");
}
function main() {
var vState = getBarState();
//Expression_1_ENTRY_LONG
if (
ENTRY CONDITION
) onAction1()
//Expression_2_ENTRY_SHORT
if(
SHORT CONDITION
) onAction2()
//Expression_3_EXIT_LONG
if (
Strategy.isLong() &&
EXIT LONG CONDITION
) onAction3()
//Expression_4_EXIT_SHORT
if (
Strategy.isShort()&&
EXIT SHORT CONDITION
) onAction4();
//background colors
if (
Strategy.isLong()){
setBarBgColor(Color.RGB(233,255,233));
}
if (
Strategy.isShort()){
setBarBgColor(Color.RGB(255,233,233));
}
else if (
!Strategy.isInTrade()){
setBarBgColor(Color.RGB(192,192,192));
}
//alerts for NEWBAR
if (
Strategy.isLong() &&
(getHour()*100)+getMinute() > vt1 &&
vState == (BARSTATE_NEWBAR))
{
Alert.playSound("C:\\Program Files\\eSignal\\Sounds\\Ding.wav");
Alert.addToList(getSymbol(), "Buy Signal large time frame", Color.RGB(0,0,0), Color.RGB(0,255,0));
}
if (
Strategy.isShort() &&
(getHour()*100)+getMinute() > vt1 &&
vState == (BARSTATE_NEWBAR))
{
Alert.playSound("C:\\Program Files\\eSignal\\Sounds\\Ding.wav");
Alert.addToList(getSymbol(), "Sell Signal large time frame", Color.RGB(0,0,0), Color.RGB(195,0,0));
}
else if (
(!Strategy.isInTrade()) &&
(getHour()*100)+getMinute() > vt1 &&
vState == (BARSTATE_NEWBAR))
{
Alert.playSound("C:\\Program Files\\eSignal\\Sounds\\Ding.wav");
Alert.addToList(getSymbol(), "Exit all trades large time frame", Color.RGB(0,0,0), Color.RGB(195,0,0));
}
//{{_Return
return null;
//}}_Return 2256
}
function postMain() {
}
//{{Action_1
function onAction1() {
if (vLastAlert != 1) Strategy.doLong("", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
vLastAlert = 1;
}
//{{Action_2!
function onAction2() {
if (vLastAlert != 2) Strategy.doShort("", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
vLastAlert = 2;
}
//{{Action_3_EXIT_LONG
function onAction3() {
if (vLastAlert != 3) Strategy.doSell("", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
vLastAlert = 3;
}
//{{Action_4_EXIT_SHORT
function onAction4() {
if (vLastAlert != 4) Strategy.doCover("", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
vLastAlert = 4;
}
I think it has something to do with the vLastAlert system, is there a different way to do this? I want the background color to indicate whether or not I'm long/short or neutral and update tick by tick.
thanks
morph
Comment