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

BoolSeries and BarsArray

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

    BoolSeries and BarsArray

    Wondering if someone could help me out with this.

    I am creating a strategy using BoolSeries with BarsArray using a 15 and 60 minute chart. The basic idea is if bullIndication is true on a 15 and a 60 minute chart, then go long. The code works fine using one chart (without using BarsArray), but I can not get it with BarsArray. Here is what I have:

    Indicator Code:

    bullIndication.Set(true);
    bearIndication.Set(false);


    I had to create an instance so I can access the BoolSeries.

    Strategy Code:
    #region Variables
    private double multiplier = 2.;
    private int rangePeriod = 14;
    private int basePeriod = 13;
    private Indicator.myIndicator ABC;
    private double lastStopValue;
    #endregion


    protected override void Initialize()
    {
    ExitOnClose = false;

    Add(PeriodType.Minute, 15);
    Add(PeriodType.Minute, 60);

    ABC = myIndicator(basePeriod, multiplier, rangePeriod);
    Add(ABC);

    CalculateOnBarClose = true;
    }

    protected override void OnBarUpdate()
    {
    if (BarsInProgress != 0)
    return;

    if (ABC.BullIndication[0](BarsArray[1] && ABC.BullIndication[0](BarsArray[2]));
    EnterLong(DefaultQuantity, "");


    I can not figure out the code to call the BoolSeries with the BarsArray. Could someone please help me with the correct code for this section:
    -----
    if (ABC.BullIndication[0](BarsArray[1] && ABC.BullIndication[0](BarsArray[2]));
    -----

    Thank you very much.

    #2
    Hello shawnkm,

    Thank you for your post and welcome to the NinjaTrader Support Forum!

    You would change the syntax to the following:
    Code:
    if (ABC(BarsArray[1]).BullIndication[0] && ABC(BarsArray[2]).BullIndication[0])
    {
    // Do something.
    }
    For information on using multiple bar series in your code please visit the following link: http://ninjatrader.com/support/helpG...nstruments.htm

    Please let me know if I may be of further assistance.

    Comment


      #3
      Thank you for the welcome message and thank you for the help!

      I have tried your suggestion and it gives me the following error:

      The name 'ABC' does not exist in the current context

      Comment


        #4
        shawnkm,

        What indicator are you planning to use? Is ABC an indicator you have?

        Comment


          #5
          The indicator name is myIndicator.

          ABC is the instance that you have to create to be able to access the BoolSeries.

          Here is how the code works:

          -----
          if (ABC.BullIndication[0])
          EnterLong(DefaultQuantity, "");
          -----

          That code works 100%. I just cant get it to function using it with BarsArray.

          Thank you again Patrick for all of your help!

          Comment


            #6
            shawnkm,

            I actually am not following. Can you provide all needed files to test this?

            You can send to [email protected] with 'ATTN: Patrick H - 1451623' in the subject line if you prefer.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Jonker, 04-27-2024, 01:19 PM
            3 responses
            23 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by businessman1929, 04-29-2024, 01:28 PM
            2 responses
            21 views
            0 likes
            Last Post businessman1929  
            Started by bltdavid, 03-27-2023, 05:32 AM
            18 responses
            347 views
            0 likes
            Last Post ETFVoyageur  
            Started by NM_eFe, Today, 05:15 PM
            0 responses
            5 views
            0 likes
            Last Post NM_eFe
            by NM_eFe
             
            Started by vitaly_p, Today, 05:09 PM
            0 responses
            6 views
            0 likes
            Last Post vitaly_p  
            Working...
            X