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 TheWhiteDragon, 01-21-2019, 12:44 PM
            5 responses
            551 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by rtwave, 04-12-2024, 09:30 AM
            5 responses
            37 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by funk10101, Today, 12:02 AM
            1 response
            11 views
            0 likes
            Last Post NinjaTrader_LuisH  
            Started by GLFX005, Today, 03:23 AM
            1 response
            6 views
            0 likes
            Last Post NinjaTrader_Erick  
            Started by nandhumca, Yesterday, 03:41 PM
            1 response
            13 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Working...
            X