Exporting historical data from ThinkorSwim for external analysis

JonR

JonR

New member
@Picard I haven't tried to import data into a trading platform yet. I use the exported data in Excel to validate custom studies I create in TOS.
 
S

sdtrader2

New member
Hi Folks,
I am a new user here. Great community here.
I am looking to write out historical daily closing value of $ADD from think of swim for the past 1 year.
Will appreciate the advice on this

Thanks
 
G

g00sey

New member
@korygill thank you so much for this code! If I want to collect 5min bar data instead, would I only need to change how the variable marketOpen is defined in the strategy code, specifically changing 60 seconds to 300 seconds?

Code:
def marketOpen = if agg >= AggregationPeriod.DAY then 1 else if SecondsTillTime(adjEndTime) >= 300 and SecondsFromTime(adjStartTime) >= -300 then 1 else 0;
 
B

b0rd2dEAth

New member
If anyone is interested, I adjusted the thinkScript strategy and the Powershell script to include volume. I have a screenshot but don't know how to include that in posts to the forum.
can please you or someone else please share the scripts with me? Im trying to get the data to include volume.

Im also trying to make sure the times go from 6:00am PST to 4:00pm PST and collect with minute iterations. does that mean I set the time to from 900 to 1900?

edit: for some reason ThinkOrSwim freezes when right clicking and clicking 'show report'. All I did was attempt to add in the volume. it worked for a small range. i'm trying to do 30 days, 1 minute intervals. is this a normal issue?

update: Resolved!
looks like the code was simpler than I thought. The only thing I had to do was boot into Windows and increase the memory size for ThinkOrSwim. Might work on macOS too, I'll try it later. Got my volume data loaded properly now. I gotta say, this code is quite elegant.

thanks korygill!
 
Last edited:
J

judddder

New member
Kory,

I am struggling with the Powershell Portion of this. I keep getting an error trying to do this: From a PowerShell command window, run the script and pass your exported csv file as a parameter.

This is what I get:
PS C:\Users\jud> C:\Users\jud\Documents\Get-SOHLCP.ps1 C:\Users\jud\Documents\ StrategyReports_ESXCME_72720.csv
C:\Users\jud\Documents\Get-SOHLCP.ps1 : A positional parameter cannot be found that accepts argument 'StrategyReports_ESXCME_72720.csv'.
At line:1 char:1
  • C:\Users\jud\Documents\Get-SOHLCP.ps1 C:\Users\jud\Documents\ Strateg ...
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: :)) [Get-SOHLCP.ps1], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Get-SOHLCP.ps1
 
korygill

korygill

Active member
VIP
It looks like you have an extra space.

C:\Users\jud\Documents\Get-SOHLCP.ps1 C:\Users\jud\Documents\StrategyReports_ESXCME_72720.csv
 
M

MrBubbles

New member
Hello Kory, appreciate the work you’ve done in this. Would it be possible to include volume data in this export?
 
J

judddder

New member
It looks like you have an extra space.

C:\Users\jud\Documents\Get-SOHLCP.ps1 C:\Users\jud\Documents\StrategyReports_ESXCME_72720.csv
That was it, that seemed to just open the excel file though. Does it save the data somewhere?
 
J

judddder

New member
That was it, that seemed to just open the excel file though. Does it save the data somewhere?
Nevermind, got it figured out. I just added semicolons instead of bars between data and import straight into excel using the From text/CVS button.
 
Top