Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Integer Output

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

    Integer Output

    I have an indicator which needs to output an integer to strategies.


    I tried an IntSeries, but am having errors with the following property;

    [Browsable(false)]
    [XmlIgnore()]
    public IntSeries GridValue
    {
    get { return gridValue[1]; }// error here
    }


    EDIT: I am receiving an error which states 'Cannot implicitly convert int to NinjaTrader.Data.IntSeries'.


    How else can I output an integer value from an indicator without it being 'set' as above, so its value may be used within Strategies ??
    Last edited by Faspomy; 11-01-2008, 09:31 AM.

    #2
    I suspect 'gridValue' is in fact your IntSeries? If yes, then:

    return gridValue;

    is sufficient. If you want to return the actual integer value and not the series, then change to:

    public int GridValue
    RayNinjaTrader Customer Service

    Comment


      #3
      Thank you Ray.


      I'm not sure what you mean by " If you want to return the actual integer value and not the series, then change to: public int GridValue"

      Will a series allow me to read integer values set by the indicator ? For example;

      PHP Code:
      if (SMA(14).Value[0] > SMA(14).Value[1])
                  {
                      
      gridValue.Set(20);
                  } 
      I would like to access the '20' in a strategy.

      When I create a public int, the value is browsable, and is pre-set within the indicator's properties. Example; MyIndicator(GridValue, period)

      How can I gain access to GridValue's output from the indicator, without having its value pre-set as above ?
      Last edited by Faspomy; 11-01-2008, 12:48 PM.

      Comment


        #4
        gridValue is a series of values, an array for arguments sake. If you want to expose the entire array, then

        return gridValue;

        if you only want to return the current bar value held by the gridValue series, then

        public int GridValue
        RayNinjaTrader Customer Service

        Comment


          #5
          Thank you Ray.
          I changed to an integer

          PHP Code:
           [Browsable(false)]  
                  [
          XmlIgnore()]        
                  public 
          int GridValue
                  
          {
                      
          get {return gridValue; } 
          Still having a problem accessing the data, though. Here are conditions within the indicator to set gridValue;

          PHP Code:
                       SMA1.Set(SMA(14).Value[0]);
                      
          SMA2.Set(SMA(7).Value[0]);
                      
                       if (
          CrossAbove(SMA(14).Value,SMA(7).Value1));
                      {
                          
          gridValue 10;
                          Print(
          "gridValue = 10");

                      }
                      
                      if (
          CrossAbove(SMA(7).Value,SMA(14).Value1));
                      {
                          
          gridValue 20;
                          Print(
          "gridValue = 20");
                      } 
          This is the Strategy code to read the value;

          PHP Code:
                     if (MyIndicator(1).GridValue == 10)
                      {
                          
          EnterLong(1"");
                      }
                      
                      if (
          MyIndicator(1).GridValue == 20)
                      {
                          
          ExitLong();
                      } 
          What should happen is obvious. However, nothing happens-- no buys or sells are activated.

          Also, I am receiving "gridValue = 10" & " gridValue = 20" printing-out to the output window, at the same time, on every bar.

          Questions;
          - am I formatting the integer correctly in the indicator ?
          - do conditionals work differently in an indicator versus a strategy ? If not, why would I be receiving erroneous results ?
          Last edited by Faspomy; 11-02-2008, 09:00 PM.

          Comment


            #6
            Hello,

            This link has a reference sample that shows how to make a variable exposed:


            Notice what is going on in the Properties area and how Update() is used.
            DenNinjaTrader Customer Service

            Comment


              #7
              Ban,

              thank you. That should solve the update problem.

              I am still having a problem, though, with the values being printed-out to the output window as both '20' and '10' on each bar.

              Am I missing something ?

              Comment


                #8
                Hello,


                Try removing the ";" after each condition and see if it works better.

                Also you do not need to use SMA(14).Value and SMA(7).Value. Do it this way:

                if (CrossAbove(SMA(14), SMA(7), 1))
                {
                gridValue = 10;
                Print(“gridValue = 10”);
                }

                DenNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by usazencort, Today, 01:16 AM
                0 responses
                1 view
                0 likes
                Last Post usazencort  
                Started by kaywai, 09-01-2023, 08:44 PM
                5 responses
                603 views
                0 likes
                Last Post NinjaTrader_Jason  
                Started by xiinteractive, 04-09-2024, 08:08 AM
                6 responses
                22 views
                0 likes
                Last Post xiinteractive  
                Started by Pattontje, Yesterday, 02:10 PM
                2 responses
                21 views
                0 likes
                Last Post Pattontje  
                Started by flybuzz, 04-21-2024, 04:07 PM
                17 responses
                230 views
                0 likes
                Last Post TradingLoss  
                Working...
                X