Alright so I have a couple of questions, here is a quick summary of the strategy (I am using a strategy because I want to place buttons in the chart trader, will attach example below):
The object is to be able to input a price and execute logic based on that price. I do not want it to just be an input in the strategy as I would like it to be easy to use.
I have two ways I tried and two dead ends,
First one:
- Placed a text box in the chart trader ("TextboxExample" below)
- But whenever I go to type this thing shows up ("ThisThingExample" If I can disable this I am golden and fix is done)
Second one:
- I put a button where the text box was
- When clicked into "Edit" mode then it collects the point where I click the screen next
- Then converts it to a value using the chartscale Function .GetValueByY()
- It then draws a line at that point and executes logic in the strategy based off of it
For whatever reason whenever I click (especially near the bottom of the screen) it places the line that I tell it to draw too far up on the chart.
I printed the values it was converting to and they dont match exactly where my cursor is (close but not quite).
For what it is worth as well the closer I get to the bottom the more it resists converting close to my point.
Not sure what it could be let me know if you can help, I have attached pics below and I am pasting how I have coded the conversion as well below.
Let me know if I need to make a mock to test, Thanks!
Here is code:
This is how I save the chartscale (couldn't access in my data collection spot) -
"""
private NinjaTrader.Gui.Chart.ChartScale charts;
protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
{
charts = chartScale;
"""
(Not full code just important bit)
Here is my function for Mouse Click (I subscribe ChartControl.MouseLeftButtonUp += OnMouseClick) -
"""
private void OnMouseClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
Point cursorPoint = ChartControl.MouseDownPoint;
if(charts != null){
lvlPrice = charts.GetValueByYWpf((float) cursorPoint.Y);
Print(charts.GetValueByY((float) cursorPoint.Y));
}
}
"""
And then I have it draw at lvlPrice

Comment