Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicator Attributes for Strategy Question

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

    Indicator Attributes for Strategy Question

    I am writing in reference to;


    I created the following Strategy as a Test for viewing Text in a Strategy based-on an indicator's color (somewhat common in MetaTrader EA's).



    PHP Code:
    protected override void Initialize()
            {
            Add(HeikenAshi());
                Color BarColor;
                CalculateOnBarClose = true;
            }
    
            /// <summary>
            /// Called on each bar update event (incoming tick)
            /// </summary>
            protected override void OnBarUpdate()
            {
                // Condition set 1
                if (BarColor == Color.Red);
                {
                    DrawText("My text" + CurrentBar, "Color=Red", 0, 0, Color.Black);
                }
                
                 if (BarColor == Color.Lime);
                {
                    DrawText("My text" + CurrentBar, "Color=Green", 0, 0, Color.Black); 
    
    How do I get an accurate reading ? As-is, the bars are not being counted and tracked properly.

    Thanks.
    Last edited by Faspomy; 10-03-2008, 03:02 AM.

    #2
    Hello,

    Please remove Color BarColor in you intialization and test it.
    DenNinjaTrader Customer Service

    Comment


      #3
      Thanks Ben.

      I did that and it still does not track at all properly. I also changed 'Red' and
      'Lime' to BarUp and BarDown from the Indicator (shown below).

      This Strategy shows that it simply alternates-- every other bar indicates green or red. The Strategy does not seem to be correctly importing the data from the indicator.

      What else can I do to accurately track the color changes ? Or, is my NT simply not configured properly ?


      PHP Code:
               protected override void Initialize()
              {
              Add(HeikenAshi());
                  CalculateOnBarClose = true;
              }
      
              /// <summary>
              /// Called on each bar update event (incoming tick)
              /// </summary>
              protected override void OnBarUpdate()
              {
                  // Condition set 1
                  if (BarColor == HeikenAshi().BarColorDown);
                  {
                      DrawText("My text" + CurrentBar, "Color=Red", 0, 0, Color.Black);
                  }
                  
                   if (BarColor == HeikenAshi().BarColorUp);
                  {
                      DrawText("My text" + CurrentBar, "Color=Red", 0, 0, Color.Black);
                  }
              } 
      
      Last edited by Faspomy; 10-03-2008, 10:50 AM.

      Comment


        #4
        Hello,


        Probably the easiest way to do what you want is would be to build a bool series or string series within the HA indicator then access that series from your strategy. The HA is for visualization only in its current state.

        So add code to the HA that will set string values like "green" and "red" then access these via your strategy to build your logic. This link will help:



        Give it a try and post your code if you get stuck.
        DenNinjaTrader Customer Service

        Comment


          #5
          Thanks Ben.

          are any example files readily available to accompany the information in the link above ?

          Comment


            #6
            This is the closest we have. Replace the BoolSeries with the StringSeries.


            Hope that help.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Thank you Ben and Josh.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              558 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              324 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              101 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              545 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              547 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X