Home

Ensign trading language

Add the Dollar Index to Ensign

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Version 2.48

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Version 2.47e

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Version 2.47

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Version 2.46

 

 

 

 

 

 

 

Version 2.45

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Version 2.44

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Version 2.43

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Version 2.42

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Version 2.41

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Version 2.40

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Define your strategy in Ensign and trade it with Futures-Trader

A bit of ESPL knowledge is needed to get things going. But in the weeks to come it will be easier, as I will provide for a ESPL script doing most of what is needed to get you going.

 

First you need to differentiate between the action to be performed and the ordertype.
Eg. Buy Limit. The action would be Buy, the ordertype a Limitorder
 
How is such a tradingsystem generated?
Simple.
You know the Studyalerts in Ensign?
 
Here you see a test for a CCI crossdown below a 21ema. If such a cross happens a star is put on the chart and an internal variable in Ensign (named IT) will, besides other information contain the value "Go short" as this is the Alert message.
 
 

In your ESPL program you just add a statement to watch for such Alerts and in case such an Alert happens
call a subroutine, which then specifically looks for such Messages contained in the IT variable
Your main program then looks like this:
 
begin
    ....
      AlertEvent(eAlerts,80);
      if ESPL = 80 then CheckTrade;
    .....
End;
 
And the routine "CheckTrade" called then looks like this:
 
Procedure CheckTrade;
var
    c:String;
 
begin
     c:=IT;
     //writeln(c);
     If pos('Go Short',c)> 0 then
          Begin
               writeln("Go Short order");
               ReverseShortatMarket;
           End;
     If pos('Go Long',c)> 0 then
          Begin
               writeln("Go Long order");
               ReverseLongatMarket;
           End;
        If pos('Cover if Profit',c)> 0 then
          Begin
               writeln("Cover If Profit order");
               CoverifProfitLimitJoin;
           End;
End; 
 
Which now closes the circle, as the above routine now calls the individual routines, which then send tradeorders to Futures-Trader.
 
As Action you can use in Ensign ESPL:
    Buyorder
    Sellorder
    Coverorder
    CoverPartialorder
    CoverIfProfitOrder
    ReverseLongorder
    ReverseShortorder
 
    CancelAllorder
 
    TakeLongTrades
    TakeShortTrades
 
    TestLink
 
As ordertype you can choose from
    Marketorder
    Limitorder
    LimitBid
    LimitAsk
    LimitJoin
    Stoporder
    StopLimitorder
 
    EnableTrades
    DisableTrades
 
 
Let's discuss the actiontypes first:
Buyorder and Sellorder are selfexplaining. But unfortunatly, for an automated tradingsystem, they are not very well suited. Because, if you are Short at the time a Buysignal is generated, you want to reverse instead of just going flat.
 
Therefore the ReverseLongorder and ReverseShortorder are the ones used in your Tradingsystems.
ReverseLongorder means, if you are Short go Long and if you are Flat go Long also, but in this case use no Reverseorder but a simple Sellorder.
ReverseShortorder means, if you are Long go Short and if you are Flat go Short also, but in this case use no Reverseorder but a simple Buyorder.
 
Coverorder is not interested whether you are long or short, it covers your trade. This would be used in the Tradingsystem, when an indicator alerts you that the trend is nearing it's end and it's time to take your profits.
Coverpartialorder needs the number of contracts to cover partial in case you have more contracts on, so you get something in the bank.
CoverifProfit is a Coverorder which is only executed, if you are in the green. Assume you have an early warning indicator, which can warn when a trend isa about to end. But unfortunatly they sometimes signal also during the trade. Instead of just going flat in such a case, this order makes sure, you go flat only if there is a profit in the bank. You might miss a part of the move, but atleast commissions are paid. And there will be better trades down the road as Woodie says.
 
CancelAllOrder means just that: Cancel all submitted orders
 
TakeLongTrades, TakeShortTrades. Actually it is a flag introduced because of the Alertsystem in Ensign allowing to test only for two variables.
Let's assume you want to trade only with the trend and then only when your CCI or stochastic indicator indicates a trend continuation.
Your tradesystem issues the orders TakeLongTrades, Enable and TakeShortTrades, Disable
Now Futures-Trader will only take Longtrades until your tradesystem tells Futures-Trader otherwise.
By default Long and Shorttrades are enabled
 
Testorder just tests the connection to Futures-Trader and confirms everything is working.
 
 
The ordertypes:
Marketorder and Limitorder are clear.
If you don't submit a Limitprice, Futures-Trader will use the current Ask to go Long and the current Bid to go Short
LimitBid, LimitAsk specify which price you want to use. Futures-Trader then uses the current Bid or Askprice
Limitjoin means go Long at the Bid or go Short at the Ask
 
Stoporder is a Stopmarket order
StopLimitorder is such that, a StopLimitorder.
Stoporders need to submit the Stopprice and Limitprice, in case of the StopLimitorder
 
The structure of an order in Ensign ESPL procedure looks like this:
 
Procedure BuyatMarket;
var
     sSymbol:String;
     DLLfunction:Integer;
 
Begin
      DLLfunction:=5;
      sSymbol:=getVariable(eSymbol);
      DLL(sSymbol,DLLfunction,Buyorder,Marketorder,zero,zero,zero,zero,zero); 
End;
 
The structure of the DLL call is always the same:
      DLL(sSymbol,DLLfunction,action,ordertype,contracts,Price,Auxprice,zero,zero); 
 
If you don't use a part of the order, eg don't provide a price, it's replaced with zero.
You always have to submit the action and (with the exception of the Testorder) also the ordertype.
 
Even if the Symbol is submitted, it is not tested for in Futures-Trader. At the moment you can trade over the link only the currently as trading symbol selected contract in Futures-Trader. You have to make sure, that your Ensignsymbol, which generates the tradesignals and Futures-Trader match.
 
 
 
Ensign Playback files:
 
Futures-Trader writes in the Ensign Playback folder Playback files from the IB ticks received during the day.
Sure, these are not real ticks, but they are good enough to test a system with the symbol you are usually trading. And as I'm trading currencies, I want to test my system on currencies not on ES, NQ or YM, which are available for download.
 
These playback files have not been fully tested yet, as the IB demosystem does not deliver enough tradeticks over the weekend. So there might be changes necessary to get them running. Look at them as a Beta-Version and a feature to come in the nearest future.
 
 
 
Please let me know, if you have ideas to add to the language.
Actually it's no problem to integrate most of the functions of Futures-Trader also in the language, as long as it makes sense for a tradingsystem.

 

Link to Ensign running on another computer
I added a new small program to your installation, which basically does nothing but connecting your Ensign running on one computer to FT running on another computerof your network and forwarding the Playback-feed and the tradesignals .
You need to update the ESPL.dll file in the Ensign folder with the one found in the Futures-Trader folder after doing the full installation. (It's also part of the zip-file update)
 
At the moment this program is "just for me". So it has no features like saving it's settings and so on. And it will remain so, unless I hear back, that you are interested in such a connection over your LAN.
 
enter in the IP field the IPnumber of the computer running FT, then start FT on the other comuter
 
After startup, you need to manually select File/start server
(It's not yet automatically started.)
 
Now click Connect and it will turn green
(If you forget to start the server, you get a messagebox telling you, that you forgot to start it.)
 
Enabling FT for trading EnsignTradesignals is a 2-Step process:
First you need to enable FT to Listen to Ensign commands.
 
 
And then you Enable Ensign Order entry.
This Menuitem actually can also be toggled On/Off on the Tower or the Tradedesk.
On the tradedesk you have in addition the choice to enable/disable long or short trades, forcing FT to take only the trendtrade or the countertrend trade signal.
   
 
The last menuitem (Reset after each Ensign Signal) is for those (like me) who still like to decide alone, which signal is a valid one and which will be passed for any reason whatsoever.
I use the system in semiautomatic mode.
Meaning: I decide I will take the next signal and then I click the "Take next signal" button on the Tradedesk. Once I'm out, I need to set the button again. This in effect uses my Ensign Chartsignal to finetune my entry. When I get the signal I'm in. But I'm still deciding which signal I take and which I pass.
(Maybe in a year I will think, you idiot, you should have trusted your system and played golf, while the system does what it is designed to do. But today the trust is not there.)
 

 

Christian Czirnich 2002, contact me at: croc1964@web.de or look for me in Paltalk under my nick: croc1964