Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Is correct to use this indicator in this way?

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

    Is correct to use this indicator in this way?

    hi...look my code .

    my indicator :

    Code:
    namespace NinjaTrader.NinjaScript.Indicators
    { 
    public class Xx
    { 
    private bool signal= (espression);
    }
    
    public class Class2 : Indicator
    {
    public List<Xx> MT;
    private Xx useClass; 
    }
    protected override void OnBarUpdate()
    {
    
    Xx tmp1 = new Xx();
    MT.Add(tmp1); 
    MT[MT.count-1].signal= //Logic espression 
    
    }
    In my indicator i build a logic to using a list of class

    In my strategy is correct to do this : (i want to enter signal by my Class2 Indicator)



    Code:
      
     public class  StStrategy: Strategy
     {
     .....
     protected override void OnStateChange()
     if (State == State.SetDefaults)
     {
             .............
     {
      else if (State == State.Configure)
     {
                    mt = Class2();
            }
     
    protected override void OnBarUpdate()
     {
         if (mt.MT[mt.MT.Count-1].Xx)
                    EnterLong();
                    ....
                    ....
            
      
      }
    The question is: is good to use

    Code:
      
     if (mt.MT[mt.MT.Count-1].Xx)
    to recall indicator or is better use DataSeries in indicator (in dataseries i copy the value of list in this )...e use Dataseries in strategy...

    i don't know if it's the same or not..help me..

    thank
    Last edited by esignal; 03-07-2016, 05:18 PM.

    #2
    Hello,

    I'm not entirely clear on your final question, but your code should work as expected if you set it up the way you have laid out. Keep in mind that Class2 would be using the same data series as the strategy in this case, if that makes any difference (I'm not sure how DataSeries comes into play in your question).
    Dave I.NinjaTrader Product Management

    Comment


      #3
      ok...but see that example :

      i apply indicator and strategy to chart

      in My indicator i write (in OnBarUpdate) :
      protected override void OnBarUpdate()
      {
      Print(MT.Count);
      }
      and i see :



      Is correct !!

      but if i write in my esignal

      protected override void OnBarUpdate()
      {
      Print(mt.MT.Count);
      i see :



      it's not corret.

      it seems that does not make the update of indicator

      Comment


        #4
        Hello esignal,

        Thank you for your response.

        So you have scripts we could test this in?

        Comment


          #5
          okk..
          Now attached an example..
          The problem is the same..
          Attached Files

          Comment


            #6
            hi, are you understand this problem? or not?

            Comment


              #7
              esignal,

              Thank you for your patience.

              In your strategy you would change the following...
              Code:
              			else if (State == State.Configure)
              			{
                              gt = new forumIndicator();
              			}
              to...
              Code:
              			else if (State == State.Configure)
              			{
                              gt = forumIndicator();
              			}
              'new' instantiates the indicator without any loaded bars.

              Comment


                #8
                hi, i try it :



                but the result is the same

                Comment


                  #9
                  Hello eSignal,

                  I did forget to mention the use of Update():
                  Code:
                  			gt.Update();
                              Print(gt.MT.Count);

                  Comment


                    #10
                    Excuse me



                    Update() is a command of nt7?

                    Comment


                      #11
                      Thank you, but this is also available in NT 8: http://ninjatrader.com/support/helpG...-us/update.htm

                      Check out the ZigZag indicator in NinjaTrader 8 for example.

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by algospoke, Yesterday, 06:40 PM
                      2 responses
                      19 views
                      0 likes
                      Last Post algospoke  
                      Started by ghoul, Today, 06:02 PM
                      3 responses
                      14 views
                      0 likes
                      Last Post NinjaTrader_Manfred  
                      Started by jeronymite, 04-12-2024, 04:26 PM
                      3 responses
                      45 views
                      0 likes
                      Last Post jeronymite  
                      Started by Barry Milan, Yesterday, 10:35 PM
                      7 responses
                      21 views
                      0 likes
                      Last Post NinjaTrader_Manfred  
                      Started by AttiM, 02-14-2024, 05:20 PM
                      10 responses
                      181 views
                      0 likes
                      Last Post jeronymite  
                      Working...
                      X