I had a problem with my Multicharts script, as it kept entering limit orders on crude oil (CLH3) after the market/session was closed. The script worked fine during the trading day, but did not stop entering orders after the session was closed.
The error in the log was
Time 4:16:27 PM. CLH3.NYMEX;Order may not be entered while the market is closed.
I have added the CLH3 instrument via Rithmic and default settings in my Multicharts 8.0, build 5620. I have attached the instrument setup form QuoteManager in Multicharts. As you can see, it does not specify to use the Exchange ECN session. Should I make any changes to that?
I am using the Optimus virtual servers in Chicago, and the clock on the machine seem to be in sync and OK.
Regards
Steinar Eriksen
The actual script:
[IntrabarOrderGeneration = false]
inputs: Length( 1 ) ,
UseAdapFilter (false),UseHmaFilter (false),HmaLength1(10),HmaLength2(20),
AdapMovAvgEffRatioLength( 10 ),
AdapMovAvgFastAvgLength( 2),
AdapMovAvgSlowAvgLength( 20 );
vars:movAdapVal(0),hmaVal(0),hmaVal2(0);
hmaVal=0;
if UseHmaFilter and barssinceentry>2 then
hmaVal=jthma( c, HmaLength1);
hmaVal2=0;
if UseHmaFilter and barssinceentry>2 then
hmaVal2=jthma( c, HmaLength2);
movAdapVal=0;
if UseAdapFilter then
movAdapVal= AdaptiveMovAvg( (c+o)/2, AdapMovAvgEffRatioLength, AdapMovAvgFastAvgLength, AdapMovAvgSlowAvgLength);
condition1 = High > Highest( High, Length )[1] and Close < Close[1] ;
if condition1 then begin
if movAdapVal<=movAdapVal[1] then
Sell Short ( “KeyRevSE” ) next bar at Close - 1 point Limit
else
sell next bar at close -1 point limit;
end;
condition2 = Low < Lowest( Low, Length )[1] and Close > Close[1];
if condition2 then begin
if movAdapVal>=movAdapVal[1] then
Buy ( “KeyRevLE” ) next bar at Close + 1 point Limit
else
buytocover next bar at Close + 1 point limit;
end;
if marketposition=1 and hmaVal<hmaVal2 then
Sell next bar at market;
if marketposition=-1 and hmaVal>hmaVal2 then
Buytocover next bar at market;