GSB Forums

Not logged in [Login - Register]

Futures and forex trading contains substantial risk and is not for every investor. An investor could
potentially lose all or more than the initial investment. Risk capital is money that can be lost without
jeopardizing ones’ financial security or life style. Only risk capital should be used for trading and only
those with sufficient risk capital should consider trading. Past performance is not necessarily indicative of
future results
Go To Bottom

Printable Version  
Author: Subject: Speeding Up TS code, and guidelines for submitting code for Trading to www.halifaxonline.co.nz
admin
Super Administrator
*********




Posts: 5069
Registered: 7-4-2017
Member Is Offline

Mood: No Mood

[*] posted on 19-6-2018 at 08:57 PM
Speeding Up TS code, and guidelines for submitting code for Trading to www.halifaxonline.co.nz


When optimizing code, you may want to make these changes to make things faster.
In a few occasions, some of these changes will not work. ie if on tick data.
I'm not sure if setexitonclose will work for markets like the dax that have a close at 1500 central USA time, unlike es where its 1515 so a setexitonclose at 1500 will work fine.
I might be fussy, but I tend to lean my code down to make load on TS as light as possible. For the few users who still use EWFO and TS to walk forward code, this will also help speed. Entriestoday(date) is also very slow TS function,
Here are changes made. Red code removed. Orange optional. Green is added
You should verify your performance report before and after to check nothing has changed. If data >begin date may cause a change if the contract date is before this date. For live trading I reduce the amount of bars to 200 or so days. However I got caught recently, in that 200 days changed the performance later on. If in doubt check for this.

speedupcode2.png - 81kB


View user's profile View All Posts By User
admin
Super Administrator
*********




Posts: 5069
Registered: 7-4-2017
Member Is Offline

Mood: No Mood

[*] posted on 19-6-2018 at 10:00 PM


Halifaxonline.co.nz can also execute TS code at their re-badged Interactivebrokers $14 round turn for eminis.
(Non USA & Non Canada residents for now)
To speed this process up.
Send Workspace in ts 9.5 update 24. (else you can set them up via a teamviewer.com session
Include your cst files. (Custom session times) if you use custom sessions. Session times are NOT saved in your workspace.
They are in C:\Program Files (x86)\TradeStation 9.5\Templates\Sessions,
Otherwise cut and past the code into notepad and export as .txt
Not essential, but best to label your signals so when we refer to a system we quickly know what ones you mean.
So if your initials are JoeBlogs, and its a ES system (1 of x of your ES systems)
change code as follows. Also for short etc
Buy("Long entryJB1ES") 1 contracts this bar on close;


View user's profile View All Posts By User
coccigelus
Junior Member
**




Posts: 73
Registered: 11-7-2018
Member Is Offline

Mood: No Mood

[*] posted on 26-7-2018 at 12:11 PM


Hello

one way to avoid entriestoday from the autogenerated code perhaps is the following:

var:
bool reenter (false);

//// Contract's Session Close
If (TimeHms >= 145900 And TimeHms <= 150000) Then
Begin
BuyToCover this bar on close;
Sell this bar on close;
reenter=true; // reset reenter at the end of the session
End;

condition3= decision = 1 And sfDecision = 1 ;
condition4= decision = -1 And sfDecision = -1 ;
// Entry-filter check
If //(dateYmd > beginDate And dateYmd <= endDate)
//And (currentBarDTOHLCV <> lastBarDTOHLCV)And
((timeHms >= xxxxxx And timeHms <= xxxxxx))
//And (Not (TimeHms >= 150000 And TimeHms <= 150100))
Then Begin
// Buy/Sell
If condition3 Then // version without entriestoday
Begin
If reenter=true Then
Begin
Buy("Long entry") 1 contracts this bar on close;
reenter=false;
End
Else
Begin
BuyToCover("Short exit") this bar on close;
End;

End
Else If condition4 Then
Begin
If reenter=true Then
Begin
SellShort("Short entry") 1 contracts this bar on close;
reenter=false;
End
Else
Begin
Sell("Long exit") this bar on close;
End;

End;
End;


View user's profile View All Posts By User
admin
Super Administrator
*********




Posts: 5069
Registered: 7-4-2017
Member Is Offline

Mood: No Mood

[*] posted on 26-7-2018 at 04:17 PM


Thanks for this posting. My observation on people who made tight stops is, GSB would just often re-enter the trade. However the results sometimes improved to my surprise. But a stop isnt really a stop if you keep on re entering a bad position. A max daily loss of limit of trades per day is a option to consider.
Max entries per day is an option of the left side gui under general. Coccigelus code however will be faster if you just want one entry per day.


View user's profile View All Posts By User
coccigelus
Junior Member
**




Posts: 73
Registered: 11-7-2018
Member Is Offline

Mood: No Mood

[*] posted on 27-7-2018 at 01:21 AM


Hello,

This how I avoid use entriestoday with one trade only including a reenter after a stop. Note that in this example the stop used is a dynamic stop not a traditional one but easily changeable for the needs of the user:

var:
Double MyEntryPrice( 0 ) ,
mp(0),
entrypricee (0),
Mystop(0),
bool reenter (false);

mp=marketposition;
entrypricee=avgentryprice;

//// Contract's Session Close
If (TimeHms >= 145900 And TimeHms <= 150000) Then
Begin
BuyToCover this bar on close;
Sell this bar on close;
reenter=true; // reset reenter at the end of the session
End;

if mp > 0 then begin
MyEntryPrice =Maxlist(MyEntryPrice, EntryPricee, high);
Mystop = MyEntryPrice - ( PcntStop / 100 * Entrypricee);
If close Sell("Stoplong") 1 contracts this bar on close;
reenter=false; // do not reenter after a stop
end;
end else if mp < 0 then begin
MyEntryPrice =Minlist(myentryprice, EntryPricee, low);
Mystop = MyEntryPrice + ( PcntStop / 100 * Entrypricee);
If close>mystop and condition2=false then begin
Buytocover("Stopshort") 1 contracts this bar on close;
reenter=false;
end;
end else begin
MyEntryPrice = Close ; //Server per azzerare maxlist minlist
end;

condition3= decision = 1 And sfDecision = 1 ;
condition4= decision = -1 And sfDecision = -1 ;
// Entry-filter check
If //(dateYmd > beginDate And dateYmd <= endDate)
//And (currentBarDTOHLCV <> lastBarDTOHLCV)And
((timeHms >= xxxxxx And timeHms <= xxxxxx))
//And (Not (TimeHms >= 150000 And TimeHms <= 150100))
Then Begin
// Buy/Sell
If condition3 Then // version without entriestoday
Begin
If reenter=true Then
Begin
Buy("Long entry") 1 contracts this bar on close;
reenter=false;
End
Else
Begin
BuyToCover("Short exit") this bar on close;
End;

End
Else If condition4 Then
Begin
If reenter=true Then
Begin
SellShort("Short entry") 1 contracts this bar on close;
reenter=false;
End
Else
Begin
Sell("Long exit") this bar on close;
End;

End;
End;


View user's profile View All Posts By User
coccigelus
Junior Member
**




Posts: 73
Registered: 11-7-2018
Member Is Offline

Mood: No Mood

[*] posted on 27-7-2018 at 01:31 AM


I am planning to become soon a GSB user after finishing to learn and study in deeply the software which is a process already concluded and the results of the systems generated which is still in progress. I believe the implementation of dynamic stops like the one above exposed would be very beneficial for trend following type system. Specifically I would like to have the freedom to choose also percentage stop and dynamic stop similar to the above illustrated within GSB including futures. I am sure would be a highly beneficial feature to be implemented after You will finish the implementation of the 1 min and synthetic bars within GSB.

Paolo


View user's profile View All Posts By User
admin
Super Administrator
*********




Posts: 5069
Registered: 7-4-2017
Member Is Offline

Mood: No Mood

[*] posted on 27-7-2018 at 01:35 AM


Quote: Originally posted by coccigelus  
I am planning to become soon a GSB user after finishing to learn and study in deeply the software which is a process already concluded and the results of the systems generated which is still in progress. I believe the implementation of dynamic stops like the one above exposed would be very beneficial for trend following type system. Specifically I would like to have the freedom to choose also percentage stop and dynamic stop similar to the above illustrated within GSB including futures. I am sure would be a highly beneficial feature to be implemented after You will finish the implementation of the 1 min and synthetic bars within GSB.

Paolo

All of this is in the pipeline. Many users request it. After we have multi symbol walk forward, our efforts will go into additional secondary filters and exits. I expect the work to start next month but its quite a big job so will take a month or two (my wild guess)
It will great to have you on board. Your contributions are valued.


View user's profile View All Posts By User

  Go To Top

Trademaid forum. Software tools for TradeStation, MultiCharts & NinjaTrader
[Queries: 31] [PHP: 30.3% - SQL: 69.7%]