• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multi time frame and Multi Instrument

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

    Multi time frame and Multi Instrument

    Running a strategy on the FDAX on 1 minute data, i use the daily series to calculate some indicators on a daily basis and i want to add the FESX continious contract as a second instrument


    protected override void Initialize()
    {



    Add(PeriodType.Day, 1);
    Add("FESX ##-##", PeriodType.Minute, 1);


    CalculateOnBarClose = false;
    }
    then i want to add a filter that i only want to trade if some conditions for the FESX are satisfied


    protected override void OnBarUpdate()
    {

    ....
    #region FESX

    if (BarsInProgress == 2)
    {if (PriorDayOHLC().PriorClose[0] > CurrentDayOHL().CurrentOpen[0])
    {} else {return;} }

    if(Closes[2][0] > Opens[2][0]) {}
    else{ return; }
    #endregion
    ...
    but the code doesnt seem to affect the strategy at all

    #2
    Hello markus1000,
    Thanks for the code snippet.

    To assist you further, can you be a bit more explicit on what you are trying to do?

    I look forward to assisting you further.
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      i have a dax strategy and want to add a second instrument as a filter.

      A cheap example the strategy goes long if Dax gaps up and if several conditions are satisified, and i want to add a filter that the strategy should only go long if the FESX also gaps up.
      Last edited by markus1000; 08-09-2012, 10:34 AM.

      Comment


        #4
        Hello markus1000,
        Thanks for the information.

        You need to integrate the 2 conditions using the && operator. The below code checks for the gap for both the instrument.

        Code:
        if (BarsInProgress == 0)
        {
        	if (this.PriorDayOHLC().PriorClose[0] > CurrentDayOHL().CurrentOpen[0] && this.PriorDayOHLC(Closes[2]).PriorClose[0] > CurrentDayOHL(Closes[2]).CurrentOpen[0])
        	{
        		//do something
        	}
        	
        }
        Please let me know if I can assist you any further
        JoydeepNinjaTrader Customer Service

        Comment


          #5
          ok thank you will test it later

          but in general if i call


          if (BarsInProgress == 2)
          {if (PriorDayOHLC().PriorClose[0] > CurrentDayOHL().CurrentOpen[0])
          {} else {return;} }
          and then add the other filter in

          ..if (BarsInProgress == 0)
          {if (PriorDayOHLC().PriorClose[0] > CurrentDayOHL().CurrentOpen[0])
          isnt this basically the same like your code, maybe not that slick but..

          and i made a small mistake in my OP. the following code is not active in my strategy

          if(Closes[2][0] > Opens[2][0]) {}
          else{ return; }
          #endregion
          ...

          Comment


            #6
            Hello markus1000,
            To assist you further can you please send a toy NinjaScript code* replicating the behavior to support[AT]ninjatrader[DOT]com

            Please append Attn:Joydeep in the subject line of the email and give a reference of this thread in the body of the email.

            I look forward to assisting you further.

            *The "toy" just means something that is a stripped down version that isn't necessarily the whole logic. It makes things easier to rout out.
            JoydeepNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by StevenNelson, 11-19-2019, 05:39 AM
            3 responses
            16 views
            0 likes
            Last Post brucerobinson  
            Started by guidoisot, Today, 03:01 AM
            0 responses
            3 views
            0 likes
            Last Post guidoisot  
            Started by rontronimous, Yesterday, 05:55 PM
            0 responses
            10 views
            0 likes
            Last Post rontronimous  
            Started by bcgeek, Yesterday, 03:43 PM
            2 responses
            8 views
            0 likes
            Last Post bcgeek
            by bcgeek
             
            Started by Mberg, Yesterday, 04:05 PM
            1 response
            19 views
            0 likes
            Last Post NinjaTrader_ChrisSch  
            Working...
            X