Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

price crossing the ray, and use the slope to filter a signals

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

    price crossing the ray, and use the slope to filter a signals

    Hi
    please I need your help when
    When have a signal, a buy or sell an order is executed
    I'm still waiting for another a candle from the signal to draw a ray
    so I have:

    BarAgo=Currentbar-1 -------------------->signal
    Currentbar


    with these two informations I can calculate the slope

    x1 = ChartControl.GetXByTime(myRay.StartAnchor.Time);
    x2 = ChartControl.GetXByTime(myRay.EndAnchor.Time);
    y1 = myRay.StartAnchor.Price;
    y2 = myRay.EndAnchor.Price;

    slope = (y1 - y2) / (x1 - x2);

    now the market is moving

    I have some questions
    • By using this ray (slope) I would like to add a condition so that no order is executed until there is a crossover.

    after my remarks there will be signals and false signals so I must avoid them
    • how to calculate the crossover point ( price crossing the ray)

    I am working on that one. But I don't know the result yet.

    X3 = ChartControl.GetXByBarIndex(ChartBars, Bars.Count - 1);
    y3 = y1 - slope * (x1 - x3);


    Thank you for your patience and the time you devote to us

    #2
    Hi aekzof, thanks for posting. The value of the "Slope" variable is likely nowhere near the price value on the chart, so I assume you would want to detect the cross of the price and the ray value. The CrossAbove/Below methods can take a Series and a static double value to calculate the cross between a price value and a static value, like a singular point on a ray.
    https://ninjatrader.com/support/help...crossabove.htm

    Our colleague made this script that gets an X/Y value based on a rays slope:


    Kind regards,
    -ChrisL
    Last edited by NinjaTrader_ChrisL; 04-26-2022, 08:21 AM.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    154 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Started by CaptainJack, 04-24-2026, 11:07 PM
    0 responses
    306 views
    0 likes
    Last Post CaptainJack  
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    244 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    345 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    176 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Working...
    X