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 NullPointStrategies, Today, 05:17 AM
    0 responses
    50 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    126 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    69 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    42 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    46 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X