VirtualServer Trademaid Automation on 4>= cores +Alertmon Monito





Trademaid now has a more powerful and reliable replacement for Tradestation Strategy Automation.

Better fills can also be obtained, especially for market on close orders. Symbol substation can also be done. IE have a chart with @ES.D but trade @MESH22

and great execution reliability can be achieved.

Fill tracking of TS actual fill and hypothetical fill can also be done.


Warning. 

This documentation must be read in great detail. There are some things you must get right. People may forgive you but markets may not.

For example, if you try and send a market on close order when a market has just closed, your order will fail. You also want to understand the software before you are out of sync, or need to do a rollover on a system that holds trades overnight,

rather then get all stressed and make mistakes when your live.









Also the error below that occurs with TS automation is resolved in TM Automation.



To begin, open up the workspace TM_Automation.

You will need to click on Open windows with Items enabled.


All these steps will have already been done as they are saved in the workspace. We will however assume this was not done to show the process how to setup Automation.



Make sure Tradestation is in Simulation mode, not live trading mode.

First import the TM_automation.eld file. This will be supplied via email. There is no download link.

Open a workspace, with the correct symbol and session time.

IE @ES with default session time.


Insert the system you want to trade. We could use @MES OR @MEH22. The advantage of @MES is real time execution is a little better. I have had a number of big winning trades that occurred on @ES.D but NOT on '@ES.D.{MMYY}

The advantage of @MEH22 is we will see the orders on the chart. For demonstration purposes, the last open will be used.

It is important to know, we are not trading the chart symbol, but the symbol in the inputs of TM_Automation. (see below)

This means we can do symbol substitution.



We are using Order_test strategy. This buys and sells every few bars. It is not designed to make profitable trades, just show trading in a simulation environment.


Important. The traditional TS automation must be turned OFF on all charts with the same symbol as TM Automation.

Having them both will cause execution errors.

TM automation will support systems that go long and short on the same symbol, even at the same time on the same symbol.

You can use TM automation for say ES, and TS legacy automation for say MES. This is because the symbols are different.

We want at least 30 days of data on each chart. One of the reasons is we need a fair bit of historical data for Alertmon to figure out the active session times for each market.

When Alertmon sees data not updating inside a valid session time, alarms are sent to the user.




Next add TrademaidTSautomation on the chart.



Input descriptions and your account number.


StrategyName. This is what you the user call system system. IE Sys1

Symbol to trade. We will key of the symbol on the chart, but trade the symbol to trade.

This allows you to key of say @CL but trade @QMH22 for example.

Account to trade. Enter your sim or live account number.

Use peg orders. This gives the option of getting a limit price of the best of the bid/ask or close.  If this doesn't fill then the order turns into a market order.

Peg orders should not be used with limit orders from TS.

Use limit orders. This gives the option of getting a limit price when a limit order is sent from TS. If this doesn't fill then the order turns into a market order.

You can use peg or limit orders or neither, but not peg and limit at the same time. If a limit order is sent from TS, then a limit order, or market order can be used. (Peg and limit set to false) A limit order from TS will not work with peg orders- it will just go to market.

UseCloseOrBestOfBidAsk A 1 uses close price for limit orders, a 2 used best of bid ask.

after TimeOutToMktOrderSeconds. Peg / limit order will turn to market orders if not filled after TimeOutToMktOrderSeconds seconds have elapsed. I suspect peg orders are best for very liquid markets. If you have a semi liquid market like gold where many orders trade

after the close of a 30 minute bar at the exact time, I suspect market order will be better.

DoPrintLog. This is needed only if issues need to be diagnosed.

CreateAmonSampleFile. This is needed by alertmon to auto detect session time information. If true, this may take some time each time a chart is opened,

but will not be slower once a chart is open.

False is the default. An Alermon sample file will be created the first time a chart is opened regardless of this setting. This will take a longer time to open only the first time the chart is opened. If you have a system that may change time due to a change in time zone, day light savings on the chart then leave this to true.

IE you have a Dax contract on local time, you are in USA  and Germany changes daylight savings time.

This will cause the session time for alertmon to change. If this was false, alermon would be monitoring the wrong session times. If it is true, then Alertmon will auto detect change in time zones.

Note also that if your trading server is in a non USA time, and you trade USA markets, then CreateAmonSampleFile must be set to true. This is because USA vs non USA country will change relative time zones 4 times per year. It is recommend your trading server be on a USA time zone if USA markets are the primary ones you trade.


MaxDisconnectSeconds.

If TS data server or trading server disconnects for more than this amount of seconds, and alarm will be triggered. Alermon must be configured via the trigger function to do this.

TS automation is not very tolerant to disconnection, but TM automation is. Note TS do disconnect for short periods, so 60 seconds was chosen to avoid false alarms.

OffalertSeconds

If the automation is turned off for more than MaxDisconnectSeconds, and alert will be sent from alertmon. Alermon must be configured via the trigger function to do this. This is to avoid human error of turning a strategy off, and forgetting about it leading to an execution error.

WeekendMaxDisconnectSesssion

The timer to 3600 seconds to avoid false alarms when TS servers are restarted after hours.

AllowTradeatSessionEndTIme.

Keep allowTradeatSessionEndtime to true.

Always leave on true, unless the market is closed at end of TS session time.

Example1. S&P500 futures systems where session time is 8:30 to 15:00, but actual market close is 15:15:00

An order sent at the session close of 15:00:00 will execute ok even if it arrives at 15:00:01

If this is set to false, and TM automation market on close exit was not used, the market on close order will fail!


Example2 Dax futures

Keep allowTradeatSessionEndtime to false.

session (exchange time) 9:00:00 to 22:00:00

A order sent at 22:00:00 will fail as the market closes at 22:00:00, and if the order is sent a fraction of  a second late, it will fail.

We do not want this order to be sent at 22:00:00, as a TS dialogue box with yes / no will come up on your screen.

You should use market on close exit with tolerance for extra time to get out. For example of your computer clock is one minute slow (extreme example)

at exit on the Dax at 21:59:00 will fail as its sent at 22:00:00






with the exception of trading systems that send in order when Tradestation Session time says the market is closed, but the actual market is open.

Example SwingDax system, or a S&P 500 futures system that has a session time say 830 to 1500, but the system enters or exits at 1500.(the session end time)

The purpose of this option is to NOT send orders when a market is closed, and to send orders when a market is still open.

NumOfOrderRejectsToTurnOff

if you have in-sufficient credit in your account, or trade a expired symbol, TM Automation will retry the order until this number is reached.

Default

You can click on default, to set these a default. This will save you entering in your Account number each time.

What is critical that every UniqueappName is unique for each chart. Clicking default will set the system name to strat1 every time you add the indicator to a chart, and you must make sure you always change this input to avoid duplicate strategy names.


TrademaidTSAutomationHelper .

This must also be added to the strategy you trade. The UniqueAppName MUST match whats on the TM_Automation indicator.

This applies only to systems that could exit in the last bar on the day. (normally only day trading systems)

Add the TrademaidTSAutomationHelper strategy on the chart. This is needed primary to over come human error that's combined with a TS bug.

If a chart is opened when a system exits on the last bar of the session, and MOC time is not set correctly,

TM automation is going to take the position as if the trade is not closed. Adding TrademaidTSAutomationHelper will fix this issue. The early users of TM automation made this mistake

several times, so its best to add the TrademaidTSAutomationHelper. Also the MOC time could be set incorrectly when daylight savings occurs and your trading server time zone has shifted relative to exchange time (which might be in a different country)

The system name on the helper must be the same as in the automation indicator which will match whats on the chart. Note however on the TM user interface, the symbol is also added at the end of the strategy name. Do NOT add the symbol name in the TrademaidTSAutomationHelper system name.


This will now give this screen.


CONNECTED. This means we are connected to the TS trade server.

ON. Click this and you will be live. The current trade position on the chart will be adopted, regardless if the entry is new or stale.

OFF. This turns automation off.

Wait. This will go live after the next real time signal. Use this if there is a stale trade and you want to enter the next new trade.

UnqiueAppName. This is the name you call the system. It is CRITICAL this is unique.

Strategy position. This is the theoretical position on the Tradestation chart.

Account position. This is the actual position in the Tradestation brokerage account.

AccountAverageCost. This is the average price of your position.

OpenPL. This is the open position profit of your trade.

What to do when you enter a trade that you are in previously using TS Automation.

This is what the Adjust AccountPosition is for.

Say you are long 1 contract in your live TS account previously using TS Automation.

Click the box on Adjust AccountPostion, and enter your position (1) and the entry price. Say 4707

UnClick the box on Adjust AccountPostion. This position will now be seen in account position.


MANUAL TRADE

Quantity. This will trade Quantity contracts when Mkt Buy / Sell is done.

Mkt Buy / Sell / Force flat.

This will adjust the live position count, but not the theoretical position. Note alertmon will not alarm if you are out of sync by sending a mkt buy / sell / flat.

To adjust the theoretical position use  Adjust AccountPostion


Max# Trades Contracts.

If this number is reached in a trading day, the system will be turned off. This was introduced as a safety measure should a user have two different strategies with the same uniqueAppName. (very bad should you make this mistake. Systems will be fighting each other to stay in sync till they turn off when max # of trades is hit.

Number on the right side is the amount of trades that has occurred for the day.


Sess.End Time.

This must be set exactly to the market on close time on the chart. Failure to get this time correct will cause smart MOC exits to not work and can cause an execution issue if a chart is opened and the system exited on the last bar of the chart. Beware that if your server is in Europe time zone for example, you will get 4 day light savings changes per year relative to USA markets. This means this field would have to be updated which is very problematic. You would be better of having your server set to a USA time zone.

There is a TM_AutomationHelper strategy that can be added to a chart to fix the possible execution issue, but this will not fix the need to change the Session end time.

Market On Close Exit.

If you want TM Execution to over wide TS exit, then use these options. (recommend)

This is very useful for instruments like stocks or the Dax futures where a Market on close order will fail - as the market is closed a second earlier.

MOC EXIT

This will do a MOC exit at x seconds before the close. You can only use MOC Exit or Moc Exit Price improvement, but not both at the same time.


POST MOC EXIT

New in version 1.59

This will do a MOC exit immediately after the close, at close + x ticks better price. If not filled, it will go to market after x seconds.

The advantage of this exit is you are more likely to get close to the TS exit price. Exits before close will give significantly better and worse fills than the TS exit price.

You can only use MOC Exit or Moc Exit Price improvement or post MOC exit, but not both at the same time.

No one method will work best on every exit. You can try numerous methods and track the long term slippage of all fills.



Fills tracking

New in version 1.59. Your fills will be in log files here. Format is accountNumber.Systemname.txt

You can see here the TS fill price and the actual fill price are shown. Version 1.65 has increased detail compared to below. exact entry / exit settings are recorded as well.

This enables you to track long term what your best exit method is. To test this rather than trade two contracts on one chart, you could trade 1 contract on 2 charts, and use different entry/exit methods. Note however that a few trades are not significant, its a larger sample that will make clear what is the best exit.


MOC EXIT Price improvement.

This will aim to get x ticks price improvement y seconds before the close.

If not filled, it will go to the next level of price improvement.

If still not filled, then market order Z seconds before Session end time.

It is highly recommend to use this to improve exit fills and liquidity.


Alerts

Alertmon can be configured to alarm when any of these situations occur.

You will need to enter in the expected margin for the instrument you are trading.

If in doubt, its fine to leave margin deficiency off.


Disconnected. This will alarm when TS data or Trade server disconnect.

Alertmon trigger function must be configured for this alert to work.


OutOfSync.

This will alarm if your live and market position are not in sync.

Alertmon match2 tab must be configured for these alerts to be send.


Margin deficiency. 

There should be no great need to use this option.

This will send an alarm if not enough margin is in the account to trade, but the order will still be sent.

Req Margin. Used for margin deficiency alarm.

DayTrade / Overnight. Use night margin if you trade overnight.

OFF

An alarm will be sent if the TM Automation is turned off. (see above) If this is not ticked, no alarm will be sent.





How to do a rollover.

When TS has the Data corrections symbol up the top right, click apply to chart (or all charts)

Do a manual trade force flat command.

Under inputs, update the symbol to be traded say from mesH22 to mesM22

set the position quantity and then press buy for long, or sell for short.




How to add TrademaidTSAutomation to a chart.

Enable Order placements. (The equivalent of turning the TS automation on.)

If this is not done, no trades will occur.





These settings below MUST be changed. Trading will fail without doing this.


How to configure Alertmon for TM Automation.


Go to the Match2 field in Alertmon. (Later versions of Alertmon will only have Match)



Click on the [...]

Click on Add


Click on (1) live position, then (2), (3).



Click OK



You should now see a screen something like this. Enter your email and mobile phone number.



Another example is with more systems shown. Note how we are long and short the same contract.



See also TrademaidTSAutomationHelper above.


Optional.

If you have symbols traded manually of by TS automation, enter them in here. This is to stop alarms showing you have a position stray.






Alertmon Triggers

All these alarms must be configured via alertmon trigger.

When these evens occur, audio/email/sms will be sent.


Alerts on orange are optional. Green are critical. You can select them all buy clicking on the first item, hold down shift, and click on the last item. (Alertmon 20220201 or later needed)

The alertmon documentation on this is very thin, and assumes you have configured email / sms / audio correctly.



Alertmon System alarms

Alermon will now tell you when a chart is not updating when the market is open, AND if a chart is not functioning (ChartOpen) even when the market is closed.

This is really useful as you will find out about errors before the market is open.



Now add the system "SYS1.MES" Into alertmon.(s1.mes shown)

This will alarm if the system

i) chart not open

ii) Indicator not connected

ii) Chart is not updating during market hours.

Note the session time is auto detected by alertmon.


Known bugs / issues.

Fixed: Chart open alarms will give false alarms Saturday at 12:20 am and Sunday morning 1am. Fixed in Alermon 20220131 onward's for trigger alarms to be Monday to Friday only, and not early morning Saturday / Sunday. This is a cover up for a TS issue that cant be fixed on the TS side.

Fixed. A chart opened with a stale trade that went flat (not real time) trade on the last bar may be out of sync until the open of the next bar. An alert will show in this case that you are out of sync. This is not an issue for a real time trading or when Trademaid Automation MOC exit / moc exit Price Improvement is used. There is an additional strategy to be added to a chart if you think this unlikely situation will occur. See TrademaidTSAutomationHelper for details.

TS will crash if you edit your strategy code and the TM automation is on the chart. The fix is close any workspace's that have an eld that you are editing or turn TM automation eld status to off.


Change log

Version 1.65 Made maxnumber of trades if triggered still allow you go got flat. Logging of trades including the fills, and exact method and settings of exits.

Made internal unique app id so TMA is more tolerant of identical system names on multiple charts. (they still should be unique as alertmon requires unique names.)

Version 1.43

stripped symbols so "@MGCJ22=102NC+GJMQZ"  = MGC, Stripped @ and space at end beginning on symbol

do not allow an order to be sent when session is closed

Fixed a alertmon bug when @ was used in front of symbol.

Made WeekendMaxDisconnectSesssion timer to 3600 seconds to avoid false alarms when TS servers are restarted after hours.

Fixing out of sync issues

1) Market position on Alertmon and TM automation is correct, but live position is not correct.

Go to the TS order bar and fix market position.

2) Alertmon is out of sync.

A) TM automation also out of sync.

i)  Tm automation showing out of sync. If account position not correct then correct this situation by doing a market buy / sell / flat with the correct amount of contracts.

ii) If the account position is not correct, click adjust AcctPosition tick box. Enter the position and price, then click  adjust AcctPosition tick box.

B) TM Automation is in sync, but alertmon is not in sync.

This could happen when a contract is being rolled over on an overnight system. (This example needs refinement and I will do so at next rollover)

You can right click a row (the expired contract MESH22) and delete the row.



Editing alertmon match to fix issues.



Click here




You can edit all fields below. Add / remove a system, change position contracts / symbols. When done click on the updated field and enter in the date / time.

(date / time field will be removed in later build and we will just use current data and time)



Tips

If you want to close a position, do not do it with the TS order bar unless there is no other option.

TMA will not know your order is linked to a specific system, and so may exit the trade as if you had not done an order with the TS order bar.

You should use the TMA force flat button.


Getting the correct Session end time.

One of the most common human errors on TMA is to use exchange time on a chart as the session end time when exchange time <> local time.

Here is an example of how to check your chart. This chart below is on exchange time and the last bar of the day shows 1:30 pm



The chart below is in LOCAL time. the last bar is now 12:30. This local time should go in TMA session end time REGARDLESS IF YOU CHART IS ON LOCAL OR EXCHANGE TIME.



TS should be allowed to run on all computers.

The reason is if you get a VM / TS crash and we need a new VM, you cant run TS until you contact TS support.


What to do if you do a control R on TS

Should you do control R on your TS chart to refresh it, Turn TM automation to off. If this is not done a trade may be entered and exited if the system is in the market.



To see open orders

In order to see open orders, change these settings. (Right click your chart)

Note you can only see the open orders on the symbol you are trading.

So if you have a chart with @ES.D and you are trading MESH22 then you need a MESH22 chart to see the orders.

It is recommend to key off (this is what symbol is used in the chart) the Emini continuous contract (IE @ES.D), NOT key off the micros and or continuous with contract month on it.

IE Don't key of @ESM22.D OR @MESM22.D). What is critical is that the symbol you trade is updated for each futures contract rollover. (Assuming you are trading futures)

Sometimes different results occur and I feel the continuous Emini is best.






While its recommend for live trading to use continuous symbols, you will not see open orders on the chart if this is done. To learn / watch / experiment with TM automation, it would be best to have the chart being the symbol you are trading. IE @MESH22, NOT @MES


Tradestation Alerts

Tradestation alerts can also be used for error states etc.

If enabled you will see the A in the opt of the TS chart.


If you want to see a demo, I can give you anydesk.com remote access to a trading server on a TS simulator account.



To purchase, click here.

Video on TS automation  see here.

Video on Alertmon see here.