PureBytes Links
Trading Reference Links
|
Dear TradeStation users,
Recently I was looking for information on a TradeStation system (OddBall)
and somebody I don't know was a great help to me.
He directed me to the omega-list (even after programming tradestation for
many years I was not aware of the list).
I also found a complete searcheable archive of that list with much usefull
information (now just finding the time to sort and test it out).
Anyway, maybe I can do something back for the omega-list.
The following has been tested on TS2000i and TS6, I am looking for a copy of
TS4 to test it out (maybe it works?).
Once you get into more "advanced" EasyLanguage structures, I noticed that
there was a lot I could not do.
1. Testing a system against many indices (using a index to support buy or
sell).
2. Using data that was calculated in a different time frame (let's say I
have a daily signal/indicator but I want to see if I can improve on this
using
intraday data).
3. Using one signal to trade something else (for instance trade the QQQ or
NQ on a signal based on ND).
I am working with an investment manager to setup completely automated
trading using several systems.
As you (maybe) know, TS6 can currently not trade without supervision. You
still have to "interface" with the computer before it takes your trade.
Fortunately we were promissed that as of 11/30 there will be a fully
automated "mode", no more "accept" windows. Just keep an eye on your
computer so that it is not messing up (I once was short 10 e-mini's
because of an "automated" failure on 2 buy signals).
With this task in mind the tool "PUSHPOP" (a DLL writen in Clarion) was
designed that is basically very simple:
It has a data queue for each Reference Number that you can think off.
This data queue has almost unlimited storage space.
PushClean is used on "currentbar=1" to clean out the whole queue for this
RefNr.
Push(RefNr,Date,Time,Value) is how you add values to the queue (use time=0
for daily data)
Pop(RefNr,Date,Time) returns that value to any other window in tradestation!
PopLast(RefNr,Dat,Time) does the same but returns the most "recent" value if
an exact match on date/time can not be found.
Now from any indictor that you can think off you can "push" data into this
global "memory database" and it pops right back anywhere you like.
This is the limitation for historical testing:
Tradestation plots the graphs in a certain order. The "push" data
(historical) is only available AFTER the "push" windows have been drawn by
tradestation.
In real time (update tick-by-tick) this is less of a problem (except for
maybe a 1-2 tick delay in time).
Back to the three examples:
1. Testing a system against many indices (using a index to support buy or
sell).
I set up a workspace with 12 different indices and I open this workspace
first.
All indices push their daily close value into the global data (using refnrs
1001 trhough 1012).
My indicator has an input "refnr" which pops one of the indices to use their
close value as a reference. I can now run an optimization for Refnr=1001
through 1012 and see what index performs best.
Off course I could plot 13 datastreams (using from data2.... from data13) in
one window but that is quite cumbersome.
2. Using data that was calculated in a different time frame (let's say I
have a daily signal but I want to see if I can improve on this using
intraday data).
>From my larger time frame window I push the indicator and pop it back up in
my smaller time frame.
3. Using one signal to trade something else (for instance trade the QQQ or
NQ on a signal based on ND).
Let's do this one with a real code example (SpyPush works even if you can
not modify your tradingsignals =as in protected source=).
{ SPYPUSH indicator }
Inputs: ReferenceNr(1);
DefineDLLFunc: "PUSHPOP.DLL", VOID, "PUSH", LONG, LONG, LONG, DOUBLE;
DefineDLLFunc: "PUSHPOP.DLL", VOID, "PUSHCLEAN", LONG;
Vars:MP(0),CC(0);
If CurrentBar=1 Then Begin
PushClean(1);
PushClean(2);
End;
MP=I_MarketPosition;
CC=I_CurrentContracts;
If MP>0 Then Plot1(MP*CC,"Pos",Cyan);
If MP<0 Then Plot1(MP*CC,"Pos",Magenta);
If MP=0 Then Plot1(MP*CC,"Pos",White);
PUSH(ReferenceNr,DATE,TIME,MP);
PUSH(ReferenceNr+1,DATE,TIME,CC);
It basically plots you position and pushes that position into two
referenceglobalvars.
Keep in mind that with tick-by-tick update this position will change "on the
spot" and not only after the close of the bar.
SpyPOP basically plots the same position into a different barchart (other
timeframe and/or other symbol).
{ SPYPOP indicator }
Inputs: TraceBack(1);
DefineDLLFunc: "PUSHPOP.DLL", DOUBLE, "POPLAST", LONG, LONG, LONG;
DefineDLLFunc: "PUSHPOP.DLL", DOUBLE, "POP", LONG, LONG, LONG;
Vars:MP(0),CC(0);
If TRaceBack>0 Then Begin
MP=POPLAST(1,DATE,TIME);
CC=PopLAST(2,DATE,TIME);
End
Else Begin
MP=POP(1,DATE,TIME);
CC=Pop(2,DATE,TIME);
End;
If MP>0 Then Plot1(MP*CC,"Pos",Cyan);
If MP<0 Then Plot1(MP*CC,"Pos",Magenta);
If MP=0 Then Plot1(MP*CC,"Pos",White);
The following is the trade signal based on the same data. The factor is used
to go from one future contract to (for instance) 1000 stocks of QQQ.
Attention: this signal works different real time than historically.
The quickest buy/sell you can do is on the close of the bar. Therefore if
you plot identical charst (same symbol/timeframe) the spypop chart will
mimic the position from the original chart at the close.
It is designed to be running spypop in a tick chart, now real-time the MP
and CC values will change at the moment the buy/sell becomes a fact in the
original chart. By having Spypop as a tick chart it will (almost)
immediately issue a market order.
Your strategy statistics can not be trusted since they miss this "real time"
behaviour.
{ Signal SpyPOP }
Inputs: TraceBack(1), Factor(1000.0), PRefNr(10);
DefineDLLFunc: "PUSHPOP.DLL", DOUBLE, "POP", LONG, LONG, LONG;
DefineDLLFunc: "PUSHPOP.DLL", DOUBLE, "POPLAST", LONG, LONG, LONG;
Vars: MP(0),CC(0);
If TRaceBack>0 Then Begin
MP=POPLAST(PRefNr,DATE,TIME);
CC=PopLAST(PRefNr+1,DATE,TIME);
End
Else Begin
MP=POP(PRefNr,DATE,TIME);
CC=Pop(PRefNr+1,DATE,TIME);
End;
Vars: NewPos(0),OldPos(0);
OldPos=MarketPosition*CurrentContracts;
NewPos=MP*CC*Factor;
If OldPos<>NewPos Then Begin
If OldPos<=0 AND NewPos>0 Then
Buy NewPos contracts this bar at close
Else If OldPos>=0 AND NewPos<0 Then
Sell 0-NewPos contracts this bar at close
Else If NewPos>0 AND OldPos>0 AND NewPos<OldPos Then
ExitLong OldPos-NewPos contracts this bar at close
Else If NewPos<0 AND OldPos<0 AND NewPos>OldPos Then
ExitShort NewPos-OldPos contracts this bar at close
Else If NewPos=0 Then Begin
ExitShort;
ExitLong;
End;
End;
Be careful to double check results, the close of the day is only available
at 4pm but PUSHPOP could easily give you that info in advance (darn that
this does not work in the "real" world).
Being new to the omega-list I am not sure if I can attacht a zip file to
this email (the PUSHPOP.DLL) but send me an email if you would like a copy.
Thanks
Robert
ps. I am still looking for a 2 or more years of intraday
$ADV/$DECL/$ADVQ/$DECLQ data, anybody who can email me a txt file (or xpo).
===============================
Robert Linders
Orlando, FL
email: mugsnug@xxxxxxxxx
===============================
|