Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Array of signals

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

    Array of signals

    Hello.
    Help me please.
    How can I create an array with signals (each signal has price and direction - buy or sell) and make orders by using them?

    For example - after bar closed, I need to create two signals from high and low of this bar. And after that, when next ticks will rich any of these signal - I need to make an order.

    The question is - how can I create this array with signals?
    And should I loop through this array when each next tick will came to check if the price of current tick equals to any signal's prices in the array?

    Thank you.

    #2
    Is there a value with every bar? Or is there going to be conditions which might span several bars?

    If there is a value for each bar you need to access, you can see information related to creating your own data series:



    With this approach, you can just check the previous bar value and no need to loop through each member of the array.

    If you only need to create a short array which contains only a few values, you'd want to use a List, which is more of a general C# concept than NinjaScript:

    Represents a strongly typed list of objects that can be accessed by index. Provides methods to search, sort, and manipulate lists.


    In the case of a list, you'd need to loop through it on each new bar to check if it satisfies your conditions.
    MatthewNinjaTrader Product Management

    Comment


      #3
      Thanks for quick answer, Matthew.
      Yes, there is condition that takes two bars.

      I have big experience in Java and wonder, if there any possibilities to create my own class and import it into strategy?

      For example, I would like to create a SignalDTO class, witch would have two properties
      - double price;
      - OrderAction action (buy or sell);

      And after each bar close, I would calculate bar's values (high, close, open, close) and if a some condition is true - create a SignalDTO object, put it to the List (as you suggested previously), and loop through the List after each tick to check - if tick's price rich any signal's price (if rich - make an order).

      Sorry for such long description.

      Comment


        #4
        Yes, it's possible to create your own class and reference it from the strategy.

        The most straightforward way to do this is to create a custom Indicator which calculates your conditions. You can then pass that value from the indicator to your strategy to reference

        Here is an example of a indicator which uses a data series to store calculations:



        For example, if you wanted to access the values calculated by the SampleCustomDataSeries example, you could do so from your strategy by using:

        Code:
        double myCalc = SampleCustomDataSeries(10).AvgR[0];
        Of course, that indicator would need to be imported first.
        MatthewNinjaTrader Product Management

        Comment


          #5
          Originally posted by romulko View Post
          Thanks for quick answer, Matthew.
          Yes, there is condition that takes two bars.

          I have big experience in Java and wonder, if there any possibilities to create my own class and import it into strategy?

          For example, I would like to create a SignalDTO class, witch would have two properties
          - double price;
          - OrderAction action (buy or sell);

          And after each bar close, I would calculate bar's values (high, close, open, close) and if a some condition is true - create a SignalDTO object, put it to the List (as you suggested previously), and loop through the List after each tick to check - if tick's price rich any signal's price (if rich - make an order).

          Sorry for such long description.
          1. Create a struct to hold your paired values
          2. Place the structs in an ArrayList or a generic List.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          647 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          369 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          108 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          572 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          573 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X