kimosabe
Actually it is not the program being confused but the conditions not being set/reset appropriately.
The enclosed revision of your script includes all 4 conditions and does not trigger any signals when loaded (or reloaded). Notice also that because condition3 and condition4 are now being reset they are never both true at the same time.
You can see this difference in the returns of the Formula Output Window. The bottom line is a reload of your original efs (which triggered the alert) while the top line is a reload in the same instant of the modified efs (which did not trigger the alert)
Alex
Actually it is not the program being confused but the conditions not being set/reset appropriately.
The enclosed revision of your script includes all 4 conditions and does not trigger any signals when loaded (or reloaded). Notice also that because condition3 and condition4 are now being reset they are never both true at the same time.
You can see this difference in the returns of the Formula Output Window. The bottom line is a reload of your original efs (which triggered the alert) while the top line is a reload in the same instant of the modified efs (which did not trigger the alert)
Alex
PHP Code:
var fast = new MAStudy(1, 0, "Close", MAStudy.SIMPLE);
var slow = new MAStudy(55, 0, "Close", MAStudy.SIMPLE);
//var SignalDLL = new DLL ("C:/TestFiles/SignalDll.dll");
var StrategyisLong = false;
var StrategyisShort = false;
var condition1;
var condition2;
var condition3;
var condition4;
function preMain() {
setPriceStudy(true);
//SignalDLL.addFunction ("Signal" , DLL.INT, DLL.STDCALL, "?Signal@@YGHH@Z", DLL.INT);
setStudyTitle("MA1Min");
setComputeOnClose(true);
}
function main() {
var f = fast.getValue(MAStudy.MA);
var s = slow.getValue(MAStudy.MA);
if(f == null || s == null)
return;
if(f > s && getMostRecentTrade() > s)
condition1 = 1;
else//added by ACM
condition1 = 0;//added by ACM
if(f < s && getMostRecentTrade() < s)
condition2 = -1;
else//added by ACM
condition2 = 0;//added by ACM
if(getCurrentBarIndex() == -1) {
debugPrintln("barIndex="+getCurrentBarIndex()+" cond1="+condition1+" cond2="+condition2+
" cond3="+condition3+" cond4="+condition4+" trade="+getMostRecentTrade()+" s="+s.toFixed(2)+
" long="+StrategyisLong+" short="+StrategyisShort);
if((condition1 == 1) && (condition4 == -1) && (!StrategyisLong)) {
//SignalDLL.call("Signal" ,1);
condition4 = 0;
StrategyisLong = true;
StrategyisShort = false;//added by ACM
Alert.playSound( "c:\\program files\\eSignal\\Sounds\\pow.wav" );
}
if((condition2 == -1) && (condition3 == 1) && (!StrategyisShort)) {
//SignalDLL.call("Signal" ,-1);
condition3 = 0;
StrategyisShort = true;
StrategyisLong = false;//added by ACM
Alert.playSound( "c:\\program files\\eSignal\\Sounds\\pow.wav" );
}
}
if(f > s && getMostRecentTrade() > s)
condition3 = 1;
else//added by ACM
condition3 = 0;//added by ACM
if(f < s && getMostRecentTrade() < s)
condition4 = -1;
else//added by ACM
condition4 = 0;//added by ACM
//condition1 = 0;//commented out by ACM
//condition2 = 0; //commented out by ACM
return new Array(f,s);
}
Comment