Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

CrossAbove/CrossBelow help

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

    CrossAbove/CrossBelow help

    Is it possible to have a CrossAbove or CrossBelow trigger to occur only if an oscillating indicator has not reached a certain point prior?

    Let's say I have an oversold line at 0.80 and a neutral point at 0.50. My strategy just entered a short because a CrossBelow 0.80 occurred and the indicator continues downward but does not reach the neutral point of 0.50. It then turns and now crosses above 0.80, in which I would like the CrossAbove to trigger a long entry since the neutral point of 0.50 was never reached.

    How would I accomplish something like this?

    #2
    Hello Rogue_Two,

    Thanks for your post.

    One way to handle that would be to set a bool to either true or false when you first enter the short. In another condition, you would check if you are in a short position and if your oscillator goes below 50 you set the bool to the other state. In another condition, you would check that the bool is is in the original condition (meaning oscillator had not gone below 50) and that you are in a short position and that you have a cross above 80. For example:

    if (your original conditions to cross below 80)
    {
    EnterShort();
    myBelow50bool = false;
    }

    if (Position.MarketPosition == MarketPosition.Short && youroscillator[0] < 50)
    {
    myBelow50bool = true;
    }

    if (PositionMarketPosition == MarketPosition.Short && myBelow50bool == false && your oscillator crosses above 80)
    {
    EnterLong();
    }


    Note: depending on your actual logic you may need additional code, this is just a quick example of pseudo code based on the information provided and has not been tested.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, Yesterday, 05:17 AM
    0 responses
    64 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    139 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    75 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    45 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    50 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X