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 cmoran13, 04-16-2026, 01:02 PM
    0 responses
    42 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    25 views
    0 likes
    Last Post PaulMohn  
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    162 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    98 views
    1 like
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    157 views
    2 likes
    Last Post CaptainJack  
    Working...
    X