Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

check for divergence since a specific event as a condition to entering a trade

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

    check for divergence since a specific event as a condition to entering a trade

    Hi,

    I'm wondering if it is possible to essentially check for a divergence between the price and an indicator since a specific event (i.e., a change in price direction that started on the other side of a moving average and then cuts through that moving average and continues to run with no pullback) until the point that the strategy would have otherwise executed a trade but for identifying a divergence during that period.

    In effect, I'm trying to get the strategy to not execute a trade (a long for example) it would have otherwise executed if the bars (recently) changed direction (from short to long) on the other side of a moving average, then crossed up through the moving average with no pullbacks, and since that change in direction another indicator was essentially flat.

    I've tried using a variable (bool) that turns to true when the bars change direction on the other side of a moving average, and which stays true until any subsequent change in direction of the bars. My thought was that if a trade was otherwise going to be executed by the strategy, but the variable is true, and since turning true the other indicator has essentially remained flat, a condition will not be satisfied and the trade won't be executed. The problem I'm facing is I'm not sure how to have the other indicator's slope checked since the variable changed to true so that if the slope of that indicator is essentially flat since the variable changed a condition won't be satisfied and the trade won't be executed.

    Any help with this would be much appreciated.

    Thank you.


    #2
    Hello,

    Thanks for your post.

    You can use the Slope() method to check for the slope value. Please see the help guide here: https://ninjatrader.com/support/help...nt8/?slope.htm

    You can specify the number of bars to check the slope of and/or do multiple checks of various bars back to determine change in slope.

    In the Slope() you can specify a price series such as Close or use a moving average as the input to the slope.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    93 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    138 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    68 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    123 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    73 views
    0 likes
    Last Post PaulMohn  
    Working...
    X