Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Get information from indicator into strategy

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

    Get information from indicator into strategy

    Hello,

    I hope my question will be comprehensible to you, because obviously it is hard to explain here what exactly I am trying to do with my strategy.
    I have a custom indicator which calculates the number of days the bar is above or below an EMA and adds them up. I then calculate the average time and I draw a standard deviation line. I am trying to use this indicator information in my strategy and say: I want to stop my long or short orders which are generated from my strategy rules, when the cumulative number of days above or below the EMA, cross above or below the standard deviation line.

    I don't understand how could I use part of the information from the custom indicator, to manage orders to my strategy. Do I do this in my strategy code or in the indicator code? If I do this in my strategy, my variables from the indicator code are obviously not recognized.

    Please help in case you understand the problem.

    Thanks!

    #2
    You'll do the logic to manage orders (or exit positions) from your
    strategy, using standard deviation data collected by the indicator.

    Your indicator has all the data, already stored in a Series, right?
    You want your strategy to access this standard deviation data, right?

    Make sure the Series is "public" in the indicator. This is usually
    done via public properties.

    Let's use @Darvas.cs as an example.
    Open this indicator in notepad and follow along.

    Suppose the 'Series<double>' variable known as "boxTopSeries"
    was your standard deviations series, and you needed to make this
    available to your strategy.

    Note how "boxTopSeries" is a private variable, but your strategy
    cannot access that -- so we need to spawn a relative to this private
    variable and make it public -- so we use a public property and make
    an identical twin but with a new name "BoxTopSeries" -- note the
    case of the first letter, the change from 'b' to 'B' is critical.

    Scroll down to "Properties" in @Darvas.cs.
    Do you see "BoxTopSeries" in there?
    (No, you don't)

    So, just like in your case, you'll create a public property,

    Code:
    [Browsable(false)]
    [XmlIgnore]
    public Series<double> BoxTopSeries
    {
        get { return boxTopSeries; }
    }
    Wa-laah! Now in your strategy you have access to "BoxTopSeries",
    because it is a public property exposed by the indicator.

    Apply this example to your own situation.
    Does that help?
    Last edited by bltdavid; 04-03-2021, 11:34 AM.

    Comment


      #3
      Originally posted by yannistsoupakis View Post
      I have a custom indicator which calculates the number of days the bar is above or below an EMA and adds them up. I then calculate the average time and I draw a standard deviation line. I am trying to use this indicator information in my strategy and say: I want to stop my long or short orders which are generated from my strategy rules, when the cumulative number of days above or below the EMA, cross above or below the standard deviation line.
      It sounds like your indicator already has two series.
      Series #1 has "the cumulative number of days above or below the EMA".
      Series #2 has "the standard deviation line".
      Both series must be type "Series<double>".
      Is this all correct?

      Are both series publicly exposed by the indicator?
      If not, see my previous post.

      You can use CrossAbove and CrossBelow to achieve what you want.

      Suppose Series #1 was called "MyEmaData".
      Suppose Series #2 was called "MyStdDevData".

      In your strategy, you could check for a CrossAbove, like this,

      Code:
      if (CrossAbove(MyIndy(args).MyEmaData, MyIndy(args).MyStdDevData, 1))
      {
          .... the EMA cumm days has crossed above the StdDev line ....
          .... take action to exit position ....
      }
      The code for CrossBelow is very similar.

      Make sense?

      Last edited by bltdavid; 04-03-2021, 11:58 AM.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      88 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      134 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
      119 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      67 views
      0 likes
      Last Post PaulMohn  
      Working...
      X