Hi all,
I would like to use time variable for start and end of calculation (STime, ETime). Can someone point me to the example in MC.NET?
I want to compare variable later with Bar.Time.
Thank you
mirek
EL format of variable was STime=0930.
How to input DateTime variable [SOLVED]
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2957 times
Re: How to input DateTime variable [SOLVED]
Hi Henry,
thank you for the quick response and pointing me to the right direction. I am just posting code to help someone else if he needs it.
If you have any comments just let me know.
mirek
thank you for the quick response and pointing me to the right direction. I am just posting code to help someone else if he needs it.
If you have any comments just let me know.
mirek
Code: Select all
public _myInd(object _ctx):base(_ctx)
{
STime = "09:30";
}
[Input]
public string STime { get; set; }
private IPlotObject plot1;
protected override void Create() {
// create variable objects, function objects, plot objects etc.
plot1 = AddPlot(new PlotAttributes("", EPlotShapes.Line, Color.Cyan));
}
protected override void StartCalc() {
// assign inputs
}
protected override void CalcBar(){
// indicator logic
DateTime mySTime;
mySTime = DateTime.Parse(STime);
if (Bars.Time[0] == mySTime)
....
Plotting/Drawing "forward in time" or extending ETextStyleH
Hello.
My indicator uses an ITextObject which has a border (myTextObject.Border = true), and it is anchored to the right of the current bar (myTextObject.HStyle = ETextStyleH.Right); but the border always seems to obscure the current bar, especially if I'm using OHLC bars.
Is there a way I can make the ITextObject draw at a time coordinate which is in the future? At present, I'm making it appear next to the current bar using something like:
However, I want it to appear further away to the right, as if locating it two or three bars into the future.
In PowerLanguage, I believe this is not possible; but a workaround was created by TS users which used the following functions:
AddTime:
MinutesToTime:
TimeToMinutes:
Can something similar be created in MC .NET? If so, please point me in the right direction (for example DateTime?).
Alternatively, is it easy to extend ETextStyleH so that, instead of taking .Left, .Right, and .Centre as properties, it accepts other arguments like ".Right + myOffset"? or ".Left + myOffset"?
My indicator uses an ITextObject which has a border (myTextObject.Border = true), and it is anchored to the right of the current bar (myTextObject.HStyle = ETextStyleH.Right); but the border always seems to obscure the current bar, especially if I'm using OHLC bars.
Is there a way I can make the ITextObject draw at a time coordinate which is in the future? At present, I'm making it appear next to the current bar using something like:
Code: Select all
myTextObject.Location = new ChartPoint(Bars.Time[0], Bars.High[0])
In PowerLanguage, I believe this is not possible; but a workaround was created by TS users which used the following functions:
AddTime:
Code: Select all
[LegacyColorValue = true];
{ User Function: AddTime
Inputs : xTime - time in 24 hour format.
Minutes - amount to add/subtract to xTime.
Sample Usage :
if (Time[0] > AddTime (Sess1StartTime, +30))
then ...
Returns: Adjusted time in 24 hour format.
}
Inputs : xTime (NumericSimple),
Minutes (NumericSimple) ;
AddTime = MinutesToTime (TimeToMinutes (xTime) + Minutes) ;
Code: Select all
inputs: Minutes( numericsimple ) ;
variables: var0( 0 ), var1( 1 / 60 ), var2( 0 ) ;
var0 = IntPortion( Minutes * var1 ) ;
var2 = Minutes - 60 * var0 ;
MinutesToTime = 100 * Mod( var0, 24 ) + var2 ;
Code: Select all
inputs: XTime( numericsimple ) ;
Value1 = XTime * .01 ;
TimeToMinutes = 60 * IntPortion( Value1 ) + 100 * FracPortion( Value1 ) ;
Alternatively, is it easy to extend ETextStyleH so that, instead of taking .Left, .Right, and .Centre as properties, it accepts other arguments like ".Right + myOffset"? or ".Left + myOffset"?
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2957 times
Re: Plotting/Drawing "forward in time" or extending ETextSty
Hello SSS,Hello.
My indicator uses an ITextObject which has a border (myTextObject.Border = true), and it is anchored to the right of the current bar (myTextObject.HStyle = ETextStyleH.Right); but the border always seems to obscure the current bar, especially if I'm using OHLC bars.
Is there a way I can make the ITextObject draw at a time coordinate which is in the future? At present, I'm making it appear next to the current bar using something like:
Code: Select all
myTextObject.Location = new ChartPoint(Bars.Time[0], Bars.High[0])
You can offset the bars to the right by assigning the time value from the future with the help of AddMinutes or AddSeconds (depending on your chart resolution) methods of DateTime structure:
Code: Select all
Bars.Time[0].AddMinutes(5);
Re: Plotting/Drawing "forward in time" or extending ETextSty
Thanks. You guys are great!Hello SSS,
You can offset the bars to the right by assigning the time value from the future with the help of AddMinutes or AddSeconds (depending on your chart resolution) methods of DateTime structure:Code: Select all
Bars.Time[0].AddMinutes(5);
Re: How to input DateTime variable
I would like to use time variable for start and end of calculation (STime, ETime). Can someone point me to the example in MC.NET?
I want to compare variable later with Bar.Time.
Code: Select all
[Input]
public DateTime StartTime{get;set;}