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 Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    567 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    330 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    101 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    548 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    548 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X