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!
See more
See less

Partner 728x90

Collapse

Point type to Bars/Price converter?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • NinjaTrader_Jesse
    replied
    Hello,

    Thank you for the question.

    For NT7 I would have no suggestion here as there are no exposed methods for this that I could relay. Going forward in NT8 the ChartControl and other chart-related coordinate methods have all been exposed so you can translate back and forth between coordinate and price/time.

    If any other NT7 users have custom solutions for this question an answer would be welcome for any undocumented/unsupported solutions.

    I look forward to being of further assistance.

    Leave a comment:


  • mballagan
    replied
    How do we convert back from the .NET x,y coordinates to NinjaTrader barnumber/price?


    So we might have something like

    double x = ChartControl.GetXByBarIdx(BarsArray[0], barnumber);
    double y = ChartControl.GetYByValue(this, pricevalue);

    //do some calculations using x,y and get updated values x1,y1

    //we then want

    int barnumber = GetBarNumber(x1);
    double priceval = GetPrice(y1);

    This is just dummy code but how would GetBarNumber(), GetPrice() be implemented?

    Leave a comment:


  • NinjaTrader_Jesse
    replied
    Hello,

    Correct, a Situation you often run into ChartControl being null would be in an indicator that is in the Market Analyzer. There is no chart so any ChartControl calls would be null.

    I look forward to being of further assistance.

    Leave a comment:


  • FREEN
    replied
    Thanks for revealing unsupported methods Jesse!

    So the null check is for checking for a chart instance, right?

    No "visible" chart == null ?

    //Fredrik
    Last edited by FREEN; 10-19-2015, 04:51 PM.

    Leave a comment:


  • NinjaTrader_Jesse
    replied
    Hello,

    Thank you for the question.

    There are easy methods for this hidden in the ChartControl.

    For X coordinates by bar number, you can use:

    Code:
    ChartControl.GetXByBarIdx(BarsArray[0], 100)
    or for TIme:

    Code:
    ChartControl.GetXByTime(Time[0]);
    for Y:

    Code:
    ChartControl.GetYByValue(this, 2000);
    Depending on where these are used, ChartControl can be null so a null check is always recommended as well:

    Code:
    if(ChartControl != null)
    {
    //do stuff
    }
    I look forward to being of further assistance.

    Leave a comment:


  • FREEN
    started a topic Point type to Bars/Price converter?

    Point type to Bars/Price converter?

    Probably asked before but can´t find it:

    Is there a NinjaScript method or other easy solution for converting the .NET Point type to X/Y (Bars/Price) coordinates and vice versa?
    Last edited by FREEN; 10-19-2015, 03:14 PM.

Latest Posts

Collapse

Topics Statistics Last Post
Started by jclose, Today, 09:37 PM
0 responses
5 views
0 likes
Last Post jclose
by jclose
 
Started by WeyldFalcon, 08-07-2020, 06:13 AM
10 responses
1,414 views
0 likes
Last Post Traderontheroad  
Started by firefoxforum12, Today, 08:53 PM
0 responses
11 views
0 likes
Last Post firefoxforum12  
Started by stafe, Today, 08:34 PM
0 responses
11 views
0 likes
Last Post stafe
by stafe
 
Started by sastrades, 01-31-2024, 10:19 PM
11 responses
169 views
0 likes
Last Post NinjaTrader_Manfred  
Working...
X