NexusFi: Find Your Edge


Home Menu

 





Strategy run with Optimization API not agreeing with manual running of strategy


Discussion in EasyLanguage Programming

Updated
    1. trending_up 502 views
    2. thumb_up 1 thanks given
    3. group 4 followers
    1. forum 3 posts
    2. attach_file 1 attachments




 
Search this Thread

Strategy run with Optimization API not agreeing with manual running of strategy

  #1 (permalink)
shawnh
Maritimes, Canada
 
Posts: 9 since Nov 2010
Thanks Given: 0
Thanks Received: 1

Dear Traders, I'm encountering a puzzling problem while working with the EasyLanguage Optimization API in TS 9.5. My strategy has several inputs, one of them which I am optimizing will take 3 values - 0 (disable this parameter), 1 (do a certain calc), and 2 (do a slightly different calc). When I simply apply the strategy manually to my chart (1 year of DOW emini 5 minute), all 3 parameter values will evaluate correctly... but when I run an API optimization of my strategy of that parameter for those 3 values, only the 0 value (ie. parameter is disabled) will give the correct output. Parameter values 1 and 2 produce results which are way off. It's confounding. I'm even using the exact barebones sample code which is in the Optimization API manual.
If I could get the API to somehow output a list of the individual trades for each of the 3 optimization backtests, then I might have a fighting chance of narrowing down the problem by comparing that to the list of trades from the manual Strategy Performance Report... but from what I can see, there doesn't look to be a way to output individual trades using the API. Can anyone offer any help please? Very much appreciated!

Cheers
Shawn

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
ZombieSqueeze
Platforms and Indicators
Trade idea based off three indicators.
Traders Hideout
Better Renko Gaps
The Elite Circle
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Diary of a simple price action trader
26 thanks
Just another trading journal: PA, Wyckoff & Trends
25 thanks
Tao te Trade: way of the WLD
22 thanks
My NQ Trading Journal
16 thanks
HumbleTraders next chapter
9 thanks
  #2 (permalink)
 bfulks 
Boston MA
 
Experience: Advanced
Platform: TradeStation
Trading: Stocks and options
Posts: 24 since Aug 2022
Thanks Given: 2
Thanks Received: 4

It is probably trying values that are not integers. You might try setting it to use only those integers (see picture).



Bob

Reply With Quote
  #3 (permalink)
 kiwibird 
melbourne victoria australia
 
Experience: Master
Platform: tradestation
Trading: emini russell 2000
Posts: 1 since Jan 2016
Thanks Given: 4
Thanks Received: 4



shawnh View Post
Dear Traders, I'm encountering a puzzling problem while working with the EasyLanguage Optimization API in TS 9.5. My strategy has several inputs, one of them which I am optimizing will take 3 values - 0 (disable this parameter), 1 (do a certain calc), and 2 (do a slightly different calc). When I simply apply the strategy manually to my chart (1 year of DOW emini 5 minute), all 3 parameter values will evaluate correctly... but when I run an API optimization of my strategy of that parameter for those 3 values, only the 0 value (ie. parameter is disabled) will give the correct output. Parameter values 1 and 2 produce results which are way off. It's confounding. I'm even using the exact barebones sample code which is in the Optimization API manual.
If I could get the API to somehow output a list of the individual trades for each of the 3 optimization backtests, then I might have a fighting chance of narrowing down the problem by comparing that to the list of trades from the manual Strategy Performance Report... but from what I can see, there doesn't look to be a way to output individual trades using the API. Can anyone offer any help please? Very much appreciated!

Cheers
Shawn


Shawn,
you could have a print/filewrite statement in your code that writes out the trades.
this might help https://community.tradestation.com/Discussions/Topic.aspx?Topic_ID=131715&SearchTerm=OrderLogging&txtExactMatch=

I have seen this issue before just in normal optimization, without the api, and feel its impossible to solve, partly because its so erratic. It just goes away for unknown reasons.
You can try ts 10, though I understand a significant amount of people dont want to do that.
If you go to 10, build 68 is the most stable for trading. What comes after that for my users was much less stable.
Likely doesnt matter for a development machine.
By the way, I know of no way to get to build 68. Only the base build is build 70

ts support has improved, so you could try them or the ts forum

Reply With Quote
  #4 (permalink)
shawnh
Maritimes, Canada
 
Posts: 9 since Nov 2010
Thanks Given: 0
Thanks Received: 1

Thanks so much bfulks and kiwibird for the help. Well, with the help of some "Print" statements I was able to quickly pinpoint what the problem was with the calling of my strategy from an API TradingApp - I simply needed these 2 statements in my "DefineJob" section:

security.SecurityOptions.BarBuilding = tsopt.BarBuilding.SessionHours;
security.SecurityOptions.TimeZone = elsystem.TimeZone.Exchange;

The API execution of my strategy was reading my DOW emini datafile 1 hour "later" (ie. timestamps all 1 hour later) than the correct manual running of my strategy, and of course this was greatly throwing off my results which would depend on time-of-day.

These are important statements when running the optimization API... be careful not to overlook them!

Cheers
Shawn

Reply With Quote
Thanked by:




Last Updated on August 28, 2023


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts