Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Returning a method from an indicator

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

    Returning a method from an indicator

    Hey guys,

    I downloaded this simple indicator (attached) that changes the slope color between a rising and falling EMA. I need a little help on how I can detect when it's rising and falling from my strategy. I tried:

    private EMASlopeColor EMASlopeInd;

    EMASlopeInd = EMASlopeColor(20, Brushes.Lime, Brushes.Red);
    AddChartIndicator(EMASlopeInd);

    If (EMASlopeInd.IsRising == true)
    Print ("IsRising");

    But it tells me that IsRising is a method. Can you help point me the right way?

    Thanks!

    #2
    Indicator attached..
    Attached Files

    Comment


      #3
      Hello PN720,

      Thanks for your post,

      Please try: if (IsRising(EMASlopeInd))

      Alternately if you prefer to see the == true you can write it as if (IsRising(EMASlopeInd) == true)

      Either way will work.

      Also, please make sure you are doing a Currentbar check to ensure you have at least a few bars loaded before checking the isRising() condition.

      Comment


        #4
        Originally posted by NinjaTrader_Paul View Post
        Hello PN720,

        Thanks for your post,

        Please try: if (IsRising(EMASlopeInd))

        Alternately if you prefer to see the == true you can write it as if (IsRising(EMASlopeInd) == true)

        Either way will work.

        Also, please make sure you are doing a Currentbar check to ensure you have at least a few bars loaded before checking the isRising() condition.
        Hi Paul,

        This worked perfectly, thank you!

        One follow-up question.. what is the correct syntax if I wanted to check prior bar?

        I tried both of these and neither worked:

        if (IsRising[1](EMASlopeInd) == true)

        if (IsRising(EMASlopeInd[1]) == true)

        Comment


          #5
          Hello PM720,

          Thanks for your reply.

          The IsRising() (and IsFalling()) will only provide the lookback of the current bar to the previous bar, there is no adjustment or indexing. It is best to think of them as describing the current condition compared to the previous bar.

          You can accomplish the same thing by comparing EMASlopeInd[0] to EMASlopeInd[1] or to continue further back EMASlopeInd[1] to EMASlopeInd[2], etc. etc,

          Example: if (EMASlopeInd[1] >EMASlopeInd[2] && IsRising(EMASlopeInd)) would be the same as:

          if (EMASlopeInd[1]> EMASlopeInd[2] && EMASlopeInd[0] > EMASlopeInd[1])

          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