Writing Open, High, Low, Close to output file
Author: MikeyRules
Creation Date: 1/28/2010 12:09 PM
profile picture

MikeyRules

#1
Hello,

I would like to output the Open, High, Low, Close (among other data) to an output file. I have coded it this way but when I open the output file, I get the proper values for everything except the OHLC values. In those cells I get "WealthLab.DataSeries" in each one. How can I get the actual OHLC values to write to those output file cells. Thanks!

CODE:
Please log in to see this code.
profile picture

Eugene

#2
Open, High... - that's incorrect syntax in this context.

See DataSeries > Accessing a Single Value from a DataSeries in the WealthScript Programming Guide for the correct syntax.

P.S. Another question to ask yourself is: at which bar do I need these data series? There are a lot of bars. Is it Position.EntryBar? Or maybe it's .ExitBar? What if the Position isn't closed?
profile picture

MikeyRules

#3
Thanks Eugene. I left out of the original post that I tried to output High[bar], Low[bar], etc. and when I compiled I got the error - "The name 'bar' does not exist in the current context"

I also tried p.Open[bar] and got the compile error - "WealthLab.Position does not contain a definition for 'Open'"


What I am trying to do is to output the value for the O,H,L,C of the SPY for every day it has traded, so the bar would be each day. The buy/sell works to buy the open and sell the close each day. It is the output that is the issue.

All the Position Object properties print fine to the output file (EntryPrice, ExitDate, etc.) but i am still not sure how to get the DataSeries info into the output file. I guess I could print the MAE and MFE and do the math from the entry to get the high and the low but that seems like an extra step that isn't ideal. Thanks again for your help.
profile picture

Eugene

#4
QUOTE:
I left out of the original post that I tried to output High[bar], Low[bar], etc. and when I compiled I got the error - "The name 'bar' does not exist in the current context"

That's expected, and that was on my mind when writing my Post Scriptum above.
QUOTE:
I also tried p.Open[bar] and got the compile error - "WealthLab.Position does not contain a definition for 'Open'"

Absolutely correct.
QUOTE:
What I am trying to do is to output the value for the O,H,L,C of the SPY for every day it has traded, so the bar would be each day

What I am trying to do is to understand how do you envision it.

Consider a trade held for 300 bars. You output only 1 line per Position. There are columns for ExitDate, ExitPrice, MAE/MFE... are you trying to fit the 300 bars * 4 columns (OHLC) = 1200 columns for OHLC into the same single line? I'm puzzled.
profile picture

MikeyRules

#5
The buy/sell logic in the code above has it buying the open and selling the close every day, so I have one trade in the symbol each day. Certainly if the trade went longer than one day, then there would certainly be the problem you are pointing out.

This is a one off piece of code that I am using to get the full historial OHLC for the SPY for its existence. I am not trading it or anything.

Should I create a variable for each of O, H, L and C and populate it with the proper values and then print out the value of the variable? Would that work?

profile picture

Eugene

#6
OK. Simply replace this fragment:
CODE:
Please log in to see this code.

with this one:
CODE:
Please log in to see this code.
profile picture

MikeyRules

#7
Thank you sir, that does the trick! I appreciate it!
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).