I've got a strategy that trades the price delta between two instruments. Right now the delta is an indicator that plots as a line but I want to apply some studies to it that require OLHC data points to calculate. Is there any way to create to this on the fly or do I have to construct a custom instrument out of the raw data? Ideally I'd like to view the delta as candlesticks.
Thoughts?
Creating an instrument from calculated data [SOLVED]
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2223 times
Re: Creating an instrument from calculated data
Nothing prevents you from creating 4 data points of delta on the fly.I've got a strategy that trades the price delta between two instruments. Right now the delta is an indicator that plots as a line but I want to apply some studies to it that require OLHC data points to calculate. Is there any way to create to this on the fly or do I have to construct a custom instrument out of the raw data? Ideally I'd like to view the delta as candlesticks.
Thoughts?
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2223 times
Re: Creating an instrument from calculated data
...then plot them as OHLCAgreed, but if I want to chart those four points as a candle on a chart?
-
- Posts: 191
- Joined: 27 Apr 2010
- Location: San Jose
- Has thanked: 67 times
- Been thanked: 10 times
Re: Creating an instrument from calculated data
TJ,
I know I can plot four points for each hour, day, etc., but I was hoping not to have to re-create candlestick or bar charting functionality, i.e., drawing small horizontal opening and closing tick trend lines, and vertical bars or bodies of the proper length and color, in order to view the data in a standard format. Am I missing something subtle--or perhaps obvious?--in your comment?
I know I can plot four points for each hour, day, etc., but I was hoping not to have to re-create candlestick or bar charting functionality, i.e., drawing small horizontal opening and closing tick trend lines, and vertical bars or bodies of the proper length and color, in order to view the data in a standard format. Am I missing something subtle--or perhaps obvious?--in your comment?
- furytrader
- Posts: 354
- Joined: 30 Jul 2010
- Location: Chicago, IL
- Has thanked: 155 times
- Been thanked: 217 times
Re: Creating an instrument from calculated data
You can use the PlotPB command to easily replicate a bar chart.
Re: Creating an instrument from calculated data
Why not exporting the delta as OHLC in a txt-file with headers :
date, time, open, high, low, close
and mapping it as symbol via ASCII-Mapping gain ?
But I'm not sure ASCII-Mapping will work with the "Resolution" problem as time-format 1, 2 ... 1435 ... etc etc.. Then it should be work as a symbol
Please keep me updated it is working or not.
Mike
date, time, open, high, low, close
and mapping it as symbol via ASCII-Mapping gain ?
But I'm not sure ASCII-Mapping will work with the "Resolution" problem as time-format 1, 2 ... 1435 ... etc etc.. Then it should be work as a symbol
Please keep me updated it is working or not.
Mike
-
- Posts: 191
- Joined: 27 Apr 2010
- Location: San Jose
- Has thanked: 67 times
- Been thanked: 10 times
Re: Creating an instrument from calculated data
I know I could construct a custom instrument from the data, but that comes with the burden of having to update the data regularly and being without real-time data between updates. Not sure what I'm going to do at this point. I can use indicators that only require one price data point per bar but have to code each one of them to take the price delta as the price input. Kind of discourages experimentation...
Re: Creating an instrument from calculated data
Please correct me if I'm wrong, but I thought symbols from ASCII-Mapping are updated automatically.
This means you could write a "study" to calulate your delta and convert it to an OHLC data set. Then you "export these data via FileAppend-command with date & time for each bar in a txt- or csv-file like "delta_OHLC_1min.txt". Maybe I'm wrong, but this file would be written on every new bar and so updated automatically and these updates should be shown in the charts without manual adjustments.
Again, pls correct me if I'm wrong.
This means you could write a "study" to calulate your delta and convert it to an OHLC data set. Then you "export these data via FileAppend-command with date & time for each bar in a txt- or csv-file like "delta_OHLC_1min.txt". Maybe I'm wrong, but this file would be written on every new bar and so updated automatically and these updates should be shown in the charts without manual adjustments.
Again, pls correct me if I'm wrong.
-
- Posts: 191
- Joined: 27 Apr 2010
- Location: San Jose
- Has thanked: 67 times
- Been thanked: 10 times
Re: Creating an instrument from calculated data
I just wrote a quick indicator to plot the price difference between two different instruments. It works fine when the plot is built from tick data on the fly, but all bars plotted before the live tick stream started plot as one big blob (from zero to the high). I understand why that happens given my code, but now the challenge is to plot the historical data based on the tick data also.
Thoughts?
Thoughts?
Code: Select all
variables:
Delta (0),
intrabarpersist Bar_High (0),
intrabarpersist Bar_Low (0);
// calculate delta
Delta = close data1 - close data2;
if barstatus = 0 then begin
Bar_High = Delta;
Bar_Low = Delta;
end;
if barstatus > 0 then begin
if Delta > Bar_High then Bar_High = Delta;
if Delta < Bar_Low then Bar_Low = Delta;
end;
PlotPaintBar(Bar_High,Bar_Low,"Delta",black);
- Attachments
-
- Delta_line_chart_vs._bar_chart_showing_the_bars_not_built_on_the_fly.png
- (48.64 KiB) Downloaded 1138 times
-
- Delta_line_chart_vs._bar_chart_built_from_tick_data.png
- (45.68 KiB) Downloaded 1115 times
- Andrew MultiCharts
- Posts: 1587
- Joined: 11 Oct 2011
- Has thanked: 931 times
- Been thanked: 559 times
Re: Creating an instrument from calculated data [SOLVED]
We are considering a feature that would allow to create custom symbols and plot them on charts to base your scripts on them for future versions, but no there is ETA at the moment. I found a feature request in PM, you can vote for it.
In theory the following should be working:
A custom indicator applied to a chart with multiple data series, that would be reading their values, perform some calculations and write the output values down to an ASCII file. By means of ASCII mapping you should be able to read those values in real-time and feed another chart with them where you can apply any other script.
In theory the following should be working:
A custom indicator applied to a chart with multiple data series, that would be reading their values, perform some calculations and write the output values down to an ASCII file. By means of ASCII mapping you should be able to read those values in real-time and feed another chart with them where you can apply any other script.