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 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, 11: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 bmartz, 03-12-2024, 06:12 AM
            5 responses
            32 views
            0 likes
            Last Post NinjaTrader_Zachary  
            Started by Aviram Y, Today, 05:29 AM
            4 responses
            12 views
            0 likes
            Last Post Aviram Y  
            Started by algospoke, 04-17-2024, 06:40 PM
            3 responses
            28 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by gentlebenthebear, Today, 01:30 AM
            1 response
            8 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by cls71, Today, 04:45 AM
            1 response
            7 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Working...
            X