How to store the price at daily specific time?
How to store the price at daily specific time?
for example, I want to use the price at 9:00 2 days ago or the vwap close of market yesterday?
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2222 times
Re: How to store the price at daily specific time?
if you want to store a specific price at a specific time...for example, I want to use the price at 9:00 2 days ago or the vwap close of market yesterday?
Code: Select all
var:
specific.price(0),
specific.time(0);
if time = specific.time then special.price = close;
If you need to access multiple day's historic data, you will need to create an ARRAY.
Re: How to store the price at daily specific time?
Bars.TimeValue gives you what you need. Example:
you can set this for hours, minutes, date, etc.
edit- sorry, I seem to have wandered over from the MC.NET forum. This is the C# answer.
Code: Select all
if ((Bars.TimeValue.Month == 9) && (Bars.TimeValue.Year == 2011)) {do whatever}
edit- sorry, I seem to have wandered over from the MC.NET forum. This is the C# answer.
Re: How to store the price at daily specific time?
Would you give me a example using array to solve this problem? Since in the above answer, you still cant quote the price efficiently. special.price will be(0,0,0...,close[1],0,..0,close,0,0,...) how to save to (...,close_900_[1],close_900...)Bars.TimeValue gives you what you need. Example:you can set this for hours, minutes, date, etc.Code: Select all
if ((Bars.TimeValue.Month == 9) && (Bars.TimeValue.Year == 2011)) {do whatever}
edit- sorry, I seem to have wandered over from the MC.NET forum. This is the C# answer.
Thanks
Re: How to store the price at daily specific time?
Here, I've done it with ArrayList and printing the close price from 2 days ago in the Output window of the PL.NET editor-
Code: Select all
using System;
using System.Drawing;
using System.Linq;
using System.Collections;
using PowerLanguage.Function;
using ATCenterProxy.interop;
namespace PowerLanguage.Strategy {
public class bars2daysback : SignalObject {
public bars2daysback(object _ctx):base(_ctx){}
public ArrayList closeprices = new ArrayList();
public double closepr;
protected override void Create() {
// create variable objects, function objects, order objects etc.
}
protected override void StartCalc() {
Output.Clear();
}
protected override void CalcBar(){
if (Bars.TimeValue.Hour == 16)
{
Output.WriteLine(Bars.TimeValue.ToString()+ " close: "+ Bars.CloseValue.ToString());
closeprices.Add(Bars.CloseValue);
if (closeprices.Count >3 )
{
Output.WriteLine("close 2 days ago: "+closeprices[(closeprices.Count-3)].ToString());
}
}
}
}
}
Would you give me a example using array to solve this problem? Since in the above answer, you still cant quote the price efficiently. special.price will be(0,0,0...,close[1],0,..0,close,0,0,...) how to save to (...,close_900_[1],close_900...)Bars.TimeValue gives you what you need. Example:you can set this for hours, minutes, date, etc.Code: Select all
if ((Bars.TimeValue.Month == 9) && (Bars.TimeValue.Year == 2011)) {do whatever}
edit- sorry, I seem to have wandered over from the MC.NET forum. This is the C# answer.
Thanks
Last edited by clonardo on 12 Oct 2013, edited 1 time in total.
Re: How to store the price at daily specific time?
To further clarify, that's just printing out the price from 2 days ago in output. If you want to use the lagged price, set a variable = closeprices[(closeprices.Count-3)].
Sample output using the code that I posted is as follows:
note: format is date/time, day's close, (newline) 2 day ago's close.
Sample output using the code that I posted is as follows:
note: format is date/time, day's close, (newline) 2 day ago's close.
9/30/2013 4:00:00 PM close: 105.23
close 2 days ago: 113.79
10/1/2013 4:00:00 PM close: 108.72
close 2 days ago: 109.18
10/2/2013 4:00:00 PM close: 105.39
close 2 days ago: 105.23
10/3/2013 4:00:00 PM close: 101.27
close 2 days ago: 108.72
10/4/2013 4:00:00 PM close: 101.97
close 2 days ago: 105.39
10/7/2013 4:00:00 PM close: 94.18
close 2 days ago: 101.27
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2957 times
Re: How to store the price at daily specific time?
Please keep in mind that clonardo's replies are referring to MultiCharts .Net.
If you are still unable to implement your logic with PowerLanguage – please let me know the particular difficulty you have.
If you are still unable to implement your logic with PowerLanguage – please let me know the particular difficulty you have.