MultiCharts Automated Trading Script

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;

I should add that the chart was a Renko chart with brick size 0.08.

What do you mean by this line:

Sell Short ( “KeyRevSE” ) next bar at Close - 1 point Limit

What do you expect to happen upon execution of this command?

Well, actually I would expect the order to hit as long as the market has not jumped away from that level. If you run the ready made scripts “Key Reversal LE” and “Key Reversal SE” on a Renko chart, it will look wonerful in backtest, but slippage will kill you in live market. My script does a bit of te same with Limit orders rather than Market orders, which proves much better on a test account at least. I combine it with a Stop Loss script, since I may be in a position, and the reersal may not be hit since it is a Limit order.

What I did see on a Renko chart a while back was that it strted alternating between positive and negative bars at the end of the session. That may have happened to my script when it started generating multiple orders after closing time. It behaved perfectly well earlier during the opening hours of thEuropean and US session.

I can see two main problems here.

  1. The command “sell short next bar at close - 1 point limit” must be executed immediately upon the close of the current bar as the order price is (theoretically) below the current price and you use a limit order. If your renko bar closes exactly at the last minute then it’s possible that MC will be sending orders over and over, receiving rejects and sending again. I had similar problems when I tried to liquidate positions precisely at the closing bell at CME.

  2. The problem with renko itself. The point is that their equal-size bars are just an illusion that causes many issues. I’d suggest to refer to this recording https://multicharts.webex.com/ec0606l/eventcenter/recording/recordAction.do?siteurl=multicharts&theAction=poprecord&ecFlag=true&recordID=5903072 where I cover major problems of working with exotic charts including renko.

Thanks for the comments. I appreciate your input, and will look through the recording.

Thanks again. The webinar was useful indeed. I actually did something similar last year when testing Heikin Ashi (inserting a regular timechart as Data1 and implementing my strategy against Data2 and 3). At that time I tried something similar with Renko but got an error so I did not think it was possible to combine a time based chart with renko, but obviously it works fine.

I do have a related question that you may have some thoughts on. Is the Parabolic SAR indicator compatible with multiple Data feeds in a chart? The image attached shows 2 Renko charts (0.6 size boxes with 1 Minute resolution) and Parabolic SARs with 0.001/0.1 settings. One of the charts has a regular 1 minute chart as Data1 and the Renko chart as Data2 (in this case obviously the Parabolic SAR has been set to use Data2)

I would expect the chart to be skewed somewhat since the minute chart takes up space along the X Axis. I have tried to decrease the spacing to make them look similar in the image.

What I do notice however is that the Parabolic SAR behaves differently and plots below prices in one chart whereas it does not so in the other on the same Renko bar. Do you think this is a Par SAR issue that makes it impossible to use on Data2 with the same behavior as on Data1? Or is there a workaround that I am missing?