Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
Reading a horizontal line "Y" value
Collapse
X
-
Hello Drummer,
Please use this code to get the Y value.
Code:foreach(IDrawObject o in DrawObjects) { if (o.UserDrawn) { if (o.DrawType == DrawType.HorizontalLine) { IHorizontalLine hLine = (IHorizontalLine)o; Print(hLine.Y); } } }
Please let me know if I can assist you any further.JoydeepNinjaTrader Customer Service
-
Iray
Hi Joydeep, I am having a similar problem with Iray and would be grateful for some help. When I use horizontal line it works ok but Iray doesn't work (I have commented out the horizontal line code). I have attached the error message when compiling. I can't find anything in the manual examples about it.
Thanks in advance
DJ
PHP Code:
public class djdeltastrategy : Strategy
{
#region Variables
// Wizard generated variables
private int myInput0 = 1; // Default setting for MyInput0
private double lineTargetDR1A =0;
private bool showtargetoneDR1A = true;
private double targetoneDR1A = 0;
#endregion
/// <summary>
/// This method is used to configure the strategy and is called once before any strategy method is called.
/// </summary>
protected override void Initialize()
{
CalculateOnBarClose = true;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// IHorizontalLine alertLineDR1A = null;
// IDrawObject drawAlertLineDR1A = DrawObjects["DR1A"];
// if (drawAlertLineDR1A != null && drawAlertLineDR1A.DrawType == DrawType.HorizontalLine)
// alertLineDR1A = (drawAlertLineDR1A as IHorizontalLine);
// lineTargetDR1A = showtargetoneDR1A ? Instrument.MasterInstrument.Round2TickSize(alertLineDR1A.Y) : targetoneDR1A;
// DrawText("tag22", false,"D1", -2,lineTargetDR1A-3*TickSize, 0,Color.White,new Font("Arial", 8, FontStyle.Bold),StringAlignment.Center, Color.Lime, Color.Green, 5);
// alertLineDR1A.Pen.Color = Color.Red;
// alertLineDR1A.Pen.Width = 5;
// alertLineDR1A.Pen.DashStyle = DashStyle.Dot;
IRay alertLineDR1A = null;
IDrawObject drawAlertLineDR1A = DrawObjects["DR1A"];
if (drawAlertLineDR1A != null && drawAlertLineDR1A.DrawType == DrawType.Ray)
alertLineDR1A = (drawAlertLineDR1A as IRay);
lineTargetDR1A = showtargetoneDR1A ? Instrument.MasterInstrument.Round2TickSize(alertLineDR1A.Y) : targetoneDR1A;
DrawText("tag22", false,"D1", -2,lineTargetDR1A-3*TickSize, 0,Color.White,new Font("Arial", 8, FontStyle.Bold),StringAlignment.Center, Color.Lime, Color.Green, 5);
alertLineDR1A.Pen.Color = Color.Red;
alertLineDR1A.Pen.Width = 5;
alertLineDR1A.Pen.DashStyle = DashStyle.Dot;
}
#region Properties
[Description("")]
[GridCategory("Parameters")]
public int MyInput0
{
get { return myInput0; }
set { myInput0 = Math.Max(1, value); }
}
#endregion
}
}
Comment
-
Iray
Joydeep, please let me add some more detail to this. I've attached another chart where you can see magenta dotted lines at the bottom. What I'm actually trying to do here is draw a line from one point that goes to the right and doesn't stop. I don't want it to draw a horizontal line.
A line doesn't work using F2 doesn't work because it stops as the chart time moves.
The extended line using F4 would be the best but that doesn't work because it seems to draw like a horizontal line having a left and a right. I only want the line to go right from where I start it.
The ray was the only thing that let me go right but now I realize that probably isn't the right thing either because I want to access the Y value which means I have to keep it dead straight when drawing it.
Alternatively I could manually draw a line using F2 then once it's redraw automatically so it goes to the far right. In any case it looks like I need to access two lots of Y values start and finish whereas the horizontal line is only one Y value.
Any ideas on this one?
Thanks
DJLast edited by djkiwi; 03-16-2012, 03:09 PM.
Comment
-
Hello DJ,
Thanks for writing in and I am happy to assist you.
An IRay do not have a Y value. its either Anchor1Y or Anchor2Y
So please modify the code as per
Code:lineTargetDR1A = showtargetoneDR1A ? Instrument.MasterInstrument.Round2TickSize(alertLineDR1A.[B][COLOR="Green"]Anchor1Y[/COLOR][/B]) : targetoneDR1A;
Please let me know if I can assist you any further.JoydeepNinjaTrader Customer Service
Comment
-
IRAY Anchor
Thanks Joydeep, that worked perfectly. The only problem now is I'm trying to get the Y value out as followsDrawTextFixed("uptick",(lineTargetDR1A.Anchor1Y).T oString("N0"), trPosition,Color.White,textFontMed, Color.White, Color.Green, 10);
Could you please advise the correct syntax for this one?
Thanks
DJ
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by usazencort, Today, 01:16 AM
|
0 responses
1 view
0 likes
|
Last Post
by usazencort
Today, 01:16 AM
|
||
Started by kaywai, 09-01-2023, 08:44 PM
|
5 responses
602 views
0 likes
|
Last Post Today, 12:32 AM | ||
Started by xiinteractive, 04-09-2024, 08:08 AM
|
6 responses
22 views
0 likes
|
Last Post Today, 12:31 AM | ||
Started by Pattontje, Yesterday, 02:10 PM
|
2 responses
20 views
0 likes
|
Last Post
by Pattontje
Yesterday, 11:49 PM
|
||
Started by flybuzz, 04-21-2024, 04:07 PM
|
17 responses
230 views
0 likes
|
Last Post
by TradingLoss
Yesterday, 11:45 PM
|
Comment