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

Multi Instrument

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

    Multi Instrument

    If I want to place 2 orders from a chart (i.e. EUR/USD and GBP/USD), can I use the BarsArray with forex? In other words, is this correct:

    protectedoverridevoid Initialize()
    {
    // Add a 5 minute Bars object to the strategy
    Add("$EURUSD", PeriodType.Minute, 5);

    // Add a 15 minute Bars object to the strategy
    Add("$GBPUSD", PeriodType.Minute, 5);
    }

    and then submit and order to buy the EURUSD and sell the GBPUSD this way..........

    if (BarsInProgress == 1)
    {
    // Submits a buy market order for eur/usd
    EnterLong();
    }
    // Checks if OnBarUpdate() is called from an update on GBP/USD
    if (BarsInProgress == 2)
    {
    // Submits a Sell market order for gbp/usd
    EnterShort();
    }

    #2
    Yes edgeliner, a bars series is an object, no matter what types / markets you apply this to.

    BarsInProgess - which bars objects calls the OnBarUpdate() ? - http://www.ninjatrader-support.com/H...BarSeries.html

    BarsArray - holds an array of data points for the added bars objects - http://www.ninjatrader-support.com/H...BarSeries.html

    For more specific access you can work with Closes, Highs, Lows and Opens for example.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      That's what I thought....but I am not getting any trades from this?????

      Comment


        #4
        Please check into the log for errors and enable TraceOrders = true in the strategy Initialize(), to check please open the output window from the Tools entry.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Bertrand......

          I am running TraceOrders = True and other than this:

          10/30/2009 11:25:42 AM Entered internal SetStopTarget() method: Type=TrailStop FromEntrySignal='' Mode=Ticks Value=30 Currency=0 Simulated=False

          No other messages.

          Anyway, still no trades....... with this code.......

          protected override void Initialize()
          {
          Add("$EURUSD", PeriodType.Minute, 1);
          Add("$GBPUSD", PeriodType.Minute, 1);
          SetProfitTarget("", CalculationMode.Ticks, 20);
          SetStopLoss("", CalculationMode.Ticks, 15, false);
          TraceOrders = true;
          CalculateOnBarClose = true;
          }

          /// <summary>
          /// Called on each bar update event (incoming tick)
          /// </summary>
          protected override void OnBarUpdate()
          {

          // Checks if OnBarUpdate() is called from an update on EUR/USD minute Bars
          if (BarsInProgress == 1)
          {
          if (Close[0] < EMA(300)[0])
          EnterLong();
          }

          // Checks if OnBarUpdate() is called from an update on GBP/USD minute Bars
          if (BarsInProgress == 2)
          {
          if (Close[0] < EMA(300)[0])
          EnterShort();
          }

          Any other ideas????? (By the way, the close IS below the 300 EMA)

          Thanks!

          Comment


            #6
            I just noticed that it is not even showing up under the "Strategies" tab in the control Center????

            Comment


              #7
              Ok, so you're starting this from the chart correct?

              Which feed are you using, it it supporting FX data?

              Any error the log would show you after this is applied?

              Does the normal SampleMACrossOver work for you as expected?
              BertrandNinjaTrader Customer Service

              Comment


                #8
                Ok, so you're starting this from the chart correct?
                Yes!

                Which feed are you using, it it supporting FX data?
                Gain Capital (Forex.com)

                Any error the log would show you after this is applied?
                In the Output Window?

                Does the normal SampleMACrossOver work for you as expected?
                Yes!

                Very strange isn't it?

                Comment


                  #9
                  Bertrand....found it....what do you make of this from the Log???

                  10/30/2009 11:26:45 AM Strategy The strategy 'October30' has called the Add() method with an invalid instrument. Either '$GPBUSD' does not exist in the Instrument Manager or the specified exchange has not been configured.

                  Comment


                    #10
                    Please try adding $GBPUSD, not $GPBUSD...that would not be found in your instruments.
                    BertrandNinjaTrader Customer Service

                    Comment


                      #11
                      Oh yea....that was an old message from the log. I had already changed the typo. The more I look into it, it is trying to pull up other misc systems from my computer. Take a look at these 2 messages.......

                      10/30/2009 11:44:23 AM Strategy Failed to call method 'Initialize' for strategy 'TheLuckyLongJuly29': 'Position' property can not be accessed from within 'Initialize' method

                      10/30/2009 11:44:26 AM Strategy Starting NinjaScript strategy 'ALLpivotPLAY/8ad2cd3b76c749f3a0d42116feb0a2ac' : On starting a real-time strategy - StrategySync=SubmitLive EntryHandling=UniqueEntries EntriesPerDirection=3 StopTargetHandling=PerEntryExecution ErrorHandling=StopStrategyCancelOrdersClosePositio ns ExitOnClose=False Set order quantity by=Strategy

                      Can you make sense of that??? Can I just delete those systems?

                      Comment


                        #12
                        Bertrand......

                        Making progress....deleted those 2 and the system loaded....will let you know what happens....you are a big help Bertrand....thanks for all you do.......

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by esmall, Today, 07:14 PM
                        0 responses
                        1 view
                        0 likes
                        Last Post esmall
                        by esmall
                         
                        Started by Option Whisperer, 05-09-2024, 07:58 PM
                        6 responses
                        25 views
                        0 likes
                        Last Post Option Whisperer  
                        Started by rayyyu12, Today, 05:38 PM
                        0 responses
                        12 views
                        0 likes
                        Last Post rayyyu12  
                        Started by xepher101, Yesterday, 12:19 PM
                        2 responses
                        30 views
                        0 likes
                        Last Post xepher101  
                        Started by thumper57, Today, 04:30 PM
                        0 responses
                        8 views
                        0 likes
                        Last Post thumper57  
                        Working...
                        X