Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Value of last occurrence

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

    Value of last occurrence

    Hello,
    I have two indicators I want to use in my strategy. One is an exhaustion reading of 90 and 10. The other I'm using to establish a trend.
    What I'd like to do is figure out how to incorporate the value of the last occurrence in my strategy.
    Example: A short signal is if the exhaustion indicator is 90 AND the trend indicator value of this bar is BELOW the last time the exhaustion indicator read 90.
    Exhaustion indicator 90 or >, Trend indicator = 65, last time Exhaustion indicator 90 or >, Trend indicator = 70, put on position

    or

    Ex. Indicator >= 90, Trend Ind. = 65, last time Ex. Indicator >=90, Trend indicator = 50, do not put on trade
    Thank you

    #2
    Hello bstzgr,

    Thank you for your post.

    You could achieve this by storing the value of the Trend Indicator when the Exhaustion Indicator is above 90. For example, if set a double variable named prevTrendInd and set it to zero to start we could use the following:
    Code:
    // Check condition is true.
    if(ExInd()[0] >= 90 && TrendInd()[0] = 65 && TrendInd()[0] > prevTrendInd)
    {
    // If the prevTrendInd is 0 (initial value) then do not trade.
    if(prevTrendInd != 0)
    {
    // Place trade.
    }
    // Set the current value of the TrendInd as the value for the prevTrendInd.
    prevTrendInd = TrendInd()[0];
    }

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by janefoster, Yesterday, 11:50 PM
    0 responses
    5 views
    0 likes
    Last Post janefoster  
    Started by kaywai, 07-13-2024, 09:05 PM
    3 responses
    27 views
    0 likes
    Last Post kaywai
    by kaywai
     
    Started by stafe, Yesterday, 01:32 PM
    2 responses
    19 views
    0 likes
    Last Post stafe
    by stafe
     
    Started by Jakub, Yesterday, 11:06 AM
    2 responses
    24 views
    0 likes
    Last Post ashpang
    by ashpang
     
    Started by MatthewLesko, 05-21-2021, 09:37 PM
    4 responses
    167 views
    0 likes
    Last Post Mahmad1323  
    Working...
    X