Thank you for your response.
Use GetValueByY to compare the plot value and the line's value: http://ninjatrader.com/support/helpG...etvaluebyy.htm
Please let me know if you have any questions.
protected override void OnRender(ChartControl chartControl, ChartScale chartScale) { /*The 2 floats below already restricts the line to what is on the screen, so you should not use below to restrict it, or else problems: if (ChartBars != null) { for (int barIndex = ChartBars.FromIndex; ChartBars.FromIndex <= ChartBars.ToIndex; barIndex++) { }*/ float startX = chartControl.GetXByBarIndex(ChartBars, ChartBars.FromIndex); float endX = chartControl.GetXByBarIndex(ChartBars, ChartBars.ToIndex); // float chartScaleYValue = chartScale.GetYByValue(ChartPanel.MinValue + ((ChartPanel.MaxValue - ChartPanel.MinValue)/2)); float chartScaleYValue = chartScale.GetYByValue((chartScale.MaxMinusMin)/2); //WH added 27/05/2917 - this works, original above does it off the visible chart SharpDX.Vector2 startPoint = new SharpDX.Vector2(startX, chartScaleYValue); SharpDX.Vector2 endPoint = new SharpDX.Vector2(endX, chartScaleYValue); using (SharpDX.Direct2D1.SolidColorBrush dxBrush = new SharpDX.Direct2D1.SolidColorBrush(RenderTarget, SharpDX.Color.DarkOrange)) { RenderTarget.DrawLine(startPoint, endPoint, dxBrush, 2.0f); } /*GetValueByY: Returns the series value on the chart scale determined by a y pixel coordinate on the chart. A double value representing a series value on the chart scale. This is normally a price value, but can represent indicator plot values as well. This changes the pixel value of chartScaleYValue to the left scale value so that I can calculate when there is a cross of it.*/ midScale[0] = chartScale.GetValueByY(chartScaleYValue); Print(Time[0].ToString()+" " + "midScale =" + midScale[0]); base.OnRender(chartControl, chartScale); } protected override void OnBarUpdate() { //Bull Signal if (low1 < BMTCollectiveMA1.Plot0[1] && Values[1][1] > midScale[0] && Values[1][0] < midScale[0] && Values[0][1] < 1 && Values[0][0] > Values[0][1]) { Alert("myAlertStochasticsK", Priority.High, "OB falls below midScale = UB", NinjaTrader.Core.Globals.InstallDir+@"\sounds\Alert1.wav", 10, Brushes.Green, Brushes.Black); ArrowUp myArrowUpA = Draw.ArrowUp(this, "My2PeriodsSignalsStrategy Arrow up_1" + CurrentBar, false, 0, Low[0] - 2*TickSize, Brushes.DarkGreen); myArrowUpA.OutlineBrush = Brushes.Black; } //Bear Signal if (high1 > BMTCollectiveMA1.Plot0[1] && Values[0][1] > midScale[0] && Values[0][0] < midScale[0] && Values[1][1] < 1 && Values[1][0] > Values[1][1]) { Alert("myAlertStochasticsK", Priority.High, "OS falls below midScale = US", NinjaTrader.Core.Globals.InstallDir+@"\sounds\Alert1.wav", 10, Brushes.Red, Brushes.Black); ArrowDown myArrowDownA = Draw.ArrowDown(this, "My2PeriodsSignalsStrategy Arrow down_1" + CurrentBar, false, 0, High[0] + 3*TickSize, Brushes.Red); myArrowDownA.OutlineBrush = Brushes.Black; } }
if ((close0 > open0 || ((open0 == close0) &&((Math.Abs(high0 - open0) < Math.Abs(low0 - open0))))) && (close0 > midScale[0] || close0 > midScale[1])) { ArrowUp myArrowUpA = Draw.ArrowUp(this, "MyAboveMidScaleAU", false, 0, Low[0] - 2*TickSize, Brushes.DarkBlue); myArrowUpA.OutlineBrush = Brushes.Black; } if ((close0 < open0 || ((open0 == close0) &&((Math.Abs(high0 - open0) > Math.Abs(low0 - open0))))) && (close0 < midScale[0] || close0 < midScale[1])) { ArrowDown myArrowDownA = Draw.ArrowDown(this, "MyBelowMidScaleAD", false, 0, High[0] + 2*TickSize, Brushes.Orange); myArrowDownA.OutlineBrush = Brushes.Black; }
if (midLine != double.MinValue && CrossBelow(Values[1], midLine, 1)) { ArrowUp myArrowUpB = Draw.ArrowUp(this, "MyAboveMidScaleAU" + CurrentBar, false, 0, Low[0] - 2*TickSize, Brushes.DarkBlue); myArrowUpB.OutlineBrush = Brushes.Black; Print(""); Print(Time[0]); Print("OBCross"); // Print(Time[0].ToString()+" " + "OBCross" + " " + "midLine =" + midLine); }
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by bmartz, Today, 09:30 AM
|
2 responses
11 views
0 likes
|
Last Post
by bltdavid
Today, 11:24 AM
|
||
Started by f.saeidi, Today, 11:02 AM
|
1 response
4 views
0 likes
|
Last Post Today, 11:08 AM | ||
Started by geotrades1, Today, 10:02 AM
|
4 responses
12 views
0 likes
|
Last Post
by geotrades1
Today, 11:08 AM
|
||
Started by rajendrasubedi2023, Today, 09:50 AM
|
3 responses
16 views
0 likes
|
Last Post Today, 10:57 AM | ||
Started by lorem, Today, 09:18 AM
|
2 responses
11 views
0 likes
|
Last Post Today, 10:55 AM |
Futures, foreign currency and options trading contains substantial risk and is not for every investor. An investor could potentially lose all or more than the initial investment. Risk capital is money that can be lost without jeopardizing one’s financial security or lifestyle. Only risk capital should be used for trading and only those with sufficient risk capital should consider trading. Past performance is not necessarily indicative of future results. View Full Risk Disclosure.
CFTC Rules 4.41 - Hypothetical or Simulated performance results have certain limitations, unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades have not been executed, the results may have under-or-over compensated for the impact, if any, of certain market factors, such as lack of liquidity. Simulated trading programs in general are also subject to the fact that they are designed with the benefit of hindsight. No representation is being made that any account will or is likely to achieve profit or losses similar to those shown.
This website is hosted and operated by NinjaTrader, LLC (“NT”), a software development company which owns and supports all proprietary technology relating to and including the NinjaTrader trading platform. NT is an affiliated company to NinjaTrader Brokerage (“NTB”), which is a NFA registered introducing broker (NFA #0339976) providing brokerage services to traders of futures and foreign exchange products. This website is intended for educational and informational purposes only and should not be viewed as a solicitation or recommendation of any product, service or trading strategy. No offer or solicitation to buy or sell securities, securities derivative or futures products of any kind, or any type of trading or investment advice, recommendation or strategy, is made, given, or in any manner endorsed by any NT affiliate and the information made available on this Web site is not an offer or solicitation of any kind. Specific questions related to a brokerage account should be sent to your broker directly. The content and opinions expressed on this website are those of the authors and do not necessarily reflect the official policy or position of NT or any of its affiliates.
Vendors along with their websites, products and services, collectively referred to as (“Vendor Content”), are independent persons or companies that are in no manner affiliated with NT or any if its affiliates. NT or any of its affiliates are not responsible for, do not approve, recommend or endorse any Vendor Content referenced on this website and it’s your sole responsibility to evaluate Vendor Content. Please be aware that any performance information provided by a vendor should be considered hypothetical and must contain the disclosures required by NFA Rule 2-29(c). If you are interested in learning more about, or investigating the quality of, any such Vendor Content you must contact the vendor, provider or seller of such Vendor Content. No person employed by, or associated with, NT or any of its affiliates is authorized to provide any information about any such Vendor Content.
Comment