For all of you who want to open multiple text files from within VBA here is the code that will do just that. Here I open a Open File Dialog and enable multiple file selection. I then parse the return string to gather the path and individual file names. The data is then processed – I am looking for a file with a date and a value separated by a comma. You can basically do anything you want with VBA and you also have the EXCEL functions right at your fingertips. Plus output to a worksheet is ultra simple.
Set fd = Application.FileDialog(msoFileDialogOpen) With fd Set ffs = .Filters With ffs .Clear .Add "CSV Data", "*.csv; *.txt" End With .AllowMultiSelect = True If .Show = False Then Exit Sub fcnt = 0 maxDate = DateValue("01/01/1900") minDate = DateValue("12/31/2200") prevSymbol = "**" dateNewestToOldest = False For Each it In fd.SelectedItems fcnt = fcnt + 1 filePath(fcnt) = it fileName(fcnt) = Right(filePath(fcnt), Len(filePath(fcnt)) - InStrRev(filePath(fcnt), "\")) symbol(fcnt) = Left(fileName(fcnt), 2) Set DataHolder = New DataClass
If symbol(fcnt) <> prevSymbol Then symbolHolder.Add symbol(fcnt) prevSymbol = symbol(fcnt) dataCnt = 0 Open filePath(fcnt) For Input As #1 rowNumber = 1 Do Until EOF(1) Line Input #1, lineFromFile dataCnt = dataCnt + 1 If dataCnt > skipLines Then lineFromFile = Replace(lineFromFile, " ", "") lineItems = Split(lineFromFile, ",") numItems = UBound(lineItems) - LBound(lineItems) + 1 isDash1 = InStr(lineItems(0), "-") isSlash1 = InStr(lineItems(0), "/") If isDash1 > 0 Or isSlash1 > 0 Then inputDate = CDate(lineItems(0)) Else myYear = Left(lineItems(0), 4) myMonth = Mid(lineItems(0), 5, 2) myDay = Right(lineItems(0), 2) inputDate = DateSerial(Left(lineItems(0), 4), Mid(lineItems(0), 5, 2), Right(lineItems(0), 2)) End If If dataCnt > 1 Then If inputDate < tempDate Then dateNewestToOldest = True End If If inputDate > maxDate Then maxDate = inputDate If inputDate < minDate Then minDate = inputDate Set DataHolder = New DataClass DataHolder.SymbolName = symbol(fcnt) DataHolder.SymbolNum = fcnt DataHolder.EquDate = inputDate DataHolder.EquVal = lineItems(1) myEquityCollection.Add DataHolder tempDate = inputDate End If Loop Close #1 Next it End With
George Pruitt’s Easing into EasyLangauge – Academy
A video-based approach to teaching EasyLanguage. Learn at your own pace.
Module #1
and Pattern Smasher 2024 too!
From the creator of the bestselling Easing into EasyLanguage series comes his latest project – Easing into EasyLanguage Academy. In this introductory course, George shows you to program a George Taylor Technique into a day trading system. You will start with a blank slate and learn everything you need to take advantage of Taylor’s Buy and Short – day techniques. Give the gift the keeps on giving – knowledge.
Can You Program This Trading Strategy?
Imagine this: On a buy day, you want to:
Enter: Place a buy order for tomorrow if the market:
Trades a certain amount below today’s low, and
Then travels back up to today’s low.
Protect: Use a protective stop at tomorrow’s low (before the buy stop is triggered).
Risk Manage: If the entry and exit levels are too large, limit your risk to a predefined amount.
Profit Secure: When a specific profit level is reached, implement a ratcheting trailing stop to lock in a percentage of the maximum open trade equity.
Time Manage: If still in the trade at a specific time of day, exit the position.
PURCHASE NOW AND GET PATTERN SMASHER 2024 FOR FREE!
Learn how to do this and then pick intelligent and robust paremeter sets.s
Get the Pattern Smasher Cheat Code to create this strategy. This is a 4 Pattern relationship based on the last three day’s closing relationships. You can learn more at George’s Digital Store.