OmniTrader Professional Forum OmniTrader Professional Forum
forums calendars search
today this week
 
register logon control panel Forum Rules
You are currently browsing as a guest.
You should logon to access more features
A Self-Moderated Community - ALL MEMBERS, PLEASE READ!
Vote for Members who contribute the most to your trading, and help us moderate content within the Forums.


  Current location        Thread information  
OmniTrader Professional Forum
OmniLanguage Discussion
writing to a file in OL?
Last Activity 7/21/2019 10:41 AM
5 replies, 218 viewings

Jump to page : 1
Now viewing page 1 [25 messages per page]
 
back reply
Printer friendly version

^ Top
kmcintyre

Veteran
100
Posts: 101

Joined: 9/12/2007
Location: Valley Center, CA

User Profile
 
Subject : writing to a file in OL?
Posted : 6/6/2019 1:42 PM
Post #30441

I tried to compile

WritePrivateProfileString()

in an indicator script. It doesn't appear that VBA function is available in OL.

Has anyone figured out how to write to a file from OL code?

I would really like to save off my actual entry and exit target levels.

The best I have been able to do is write DebugMsg() lines, run my code, manually select all the Debug tab output, cut and paste to Notepad...

(No, Ctrl+A will not select all content on the IDE Debug pane...)

This is a PITA. And my guess is the Debug pane has limitations as to how many lines of data it can hold.

Is there a better way?

Thanks

^ Top
Jim Dean

Sage
20001000100100
Posts: 3214

Joined: 3/13/2006
Location: L'ville, GA

User Profile
 
Subject : RE: writing to a file in OL?
Posted : 6/6/2019 2:09 PM
Post #30442 - In reply to #30441

Both can be done but debugmsg is far, far easier.
When finished just shift-down arrow to select it all. Then right click to copy.

Dealing with text files in OLang requires a journey back to ProBasic days. Stick with debugmsg unless you have to both write and read-back what you’ve written. And before taking that on, down a few patience pills, and don’t expect most of the normal dotnet methods to work.

[Edited by Jim Dean on 6/6/2019 2:12 PM]

^ Top
kmcintyre

Veteran
100
Posts: 101

Joined: 9/12/2007
Location: Valley Center, CA

User Profile
 
Subject : RE: writing to a file in OL?
Posted : 6/6/2019 7:01 PM
Post #30443 - In reply to #30441

I will probably take a shot at the direct file access approach.

Reading from a csv has been on my list of things to try in OL.

If you have any sample code or hints on which FileOpen() FileClose(), FileRead(), and FileWrite() (and maybe FileSeek()) calls work, it would be helpful.

(from memory. It has been a long time since I wrote VB. fopen(), fclose(), fwrite(),fread(), and fseek() got much more mileage back in the day. Then CFile.Open, CFile.Close(), etc...) So many ways to skin the same cat...)

^ Top
kmcintyre

Veteran
100
Posts: 101

Joined: 9/12/2007
Location: Valley Center, CA

User Profile
 
Subject : RE: writing to a file in OL?
Posted : 6/7/2019 1:42 PM
Post #30444 - In reply to #30441

I am attaching a #indicator that writes to a disk file.

As with all things OL, the was an unexplained anomaly.

If I tried to write one record per bar with no ancillary logic, OT would report that the file was already open. I was blocked by the OS from deleting the file until OT was closed.

See the code for comments...

Generally speaking, the code seems to work well given the if statement logic. It seems MUCH faster than DebugMsg() and saves me cutting and pasting from the IDE Debug pane.

I plan on using similar logic to save actual target entry, stop, and limit levels. Why? Because Trade Plan Blocks do not properly capture this information. Therefor PortSim simulations are inaccurate given my strategies. So I will use PortSim to guess-timate and Excel to validate.

Hope this helps someone...

Cheers

Attached file : indTestWriteToFile.txt (1KB - 39 downloads)

^ Top
Ryan Olson

Veteran
10025
Posts: 148

Joined: 12/29/2006
Location: Austin, Tx

User Profile
 
Subject : RE: writing to a file in OL?
Posted : 6/7/2019 2:19 PM
Post #30446 - In reply to #30441

This is super helpful> I am sure you have just turbo charged every bodies coding minds.

Good work.

Ryan
^ Top
Jez

Member
25
Posts: 29

Joined: 5/14/2006

User Profile
 
Subject : RE: writing to a file in OL?
Posted : 6/7/2019 4:35 PM
Post #30447 - In reply to #30444

Thanks Keith. Very helpful.
Jump to page : 1
Now viewing page 1 [25 messages per page]
back reply

Legend    Action      Notification  
Administrator
Forum Moderator
Registered User
Unregistered User
E-Mail this thread to a friend
Toggle e-mail notification


Nirvana Systems
For any problems or issues please contact our Webmaster at webmaster@nirvsys.com.