Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Spread Strategy

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

    Spread Strategy

    Hello.
    Need an help as newbie.
    How can I program a new custom strategy using a specific spread math formula at any time?
    The spread is beetween two instruments (futures) on different expirations (calendar spread) and will be running tick by tick or on seconds/minuts bars.
    I'd like to compute the spread not on last price, but on bid and ask prices on both futures.
    The further development will be on 3/4/..10 different futures

    The example formula on the ES (miniS&P future) is:
    ES 06-12 Ask - ES 03-12 Bid - ES 06-12 Bid + ES 03-12 Ask

    The input should be : when "formula >= 2" Sell ES 03-12 and at the same time Buy ES 06-12 (or viceversa, it's just an example)
    When "formula <=0" close both spread legs (Buy ES 03-12 and Sell ES 06-12 or viceversa)
    Must I create the formula as a new indicator?
    please help.
    thanks
    mark

    #2
    Hello Mark,
    Thanks for your post and I am happy to assist you.
    You have to code a multi-instrument strategy to achieve the same.
    For example if you are viewing ES 03-12 Bid chart, then you can add the ES 06-12 Ask as a secondary bar series in the initialize section, like
    Code:
    protected override void Initialize()
    {
    	Add("ES 03-12", PeriodType.Second, 10, MarketDataType.Ask);
    //rest of the code
    }
    And in OnBarUpdate you can put up the logic like,
    Code:
    protected override void OnBarUpdate()
    {
    	if (Closes[0][0] > Closes[1][0])
    	{
    		//do stuffs
    	}
    }
    For more details please refer to here http://www.ninjatrader.com/support/h...nstruments.htm.
    Also please have a look at the SampleMultiInstrument and SampleMultiTimeframe strategies that comes with NinjaTrader (in Control Center menu bar goto Tools>Edit NinjaScript>Strategies…, in the Strategies dialog, double click the said strategies).

    Both indicators and strategies supports multi-instrument coding, so its really upto you how you want to code it.
    Please let me know if I can assist you any further.
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      I'll have a look at what you suggested.
      Thanks for now
      I'll be back for sure

      Comment


        #4
        Hello Mark,
        Please do not hesitate to contact us in case of any issues.
        I look forward to assist you further.
        JoydeepNinjaTrader Customer Service

        Comment


          #5
          Looking around on other posts I found that someone suggested to use something like:
          " double mySpread = GetCurrentAsk () - GetCurrent Bid()"
          Does it make sense?
          How can I use also the Bid & Ask of a differet instrument (not the "current one" already named, of course)?
          thanks
          mark

          Comment


            #6
            Hello Mark,
            Yes you can do that way as well, however you have to add an additional bar series.
            Like
            Code:
            protected override void Initialize()
            {
                    Add("ES 06-12", PeriodType.Second, 10);
            
            	//other codes
            }
            Access the data as

            Code:
            if (this.GetCurrentAsk(0) == this.GetCurrentBid(1))
            {
            	//do stuff
            }
            Please let me know if I can assist you any further.
            JoydeepNinjaTrader Customer Service

            Comment


              #7
              Will try both. Keep you informed.
              Thanks Joydeep

              Comment


                #8
                Hello Mark,
                Best of luck.
                Please let me know if I can assist you any further.
                JoydeepNinjaTrader Customer Service

                Comment


                  #9
                  still having some problems for the strategy.
                  may i send to you?
                  with some explaination on what I'd like to do?
                  thanks

                  Comment


                    #10
                    Hello Mark,
                    Please send the strategy to support[AT]ninjatrader[DOT]com with Attn:Joydeep in the subject line and the reference to this thread in the email body.

                    I look forward to assisting you further.
                    JoydeepNinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by mmenigma, Today, 02:22 PM
                    0 responses
                    1 view
                    0 likes
                    Last Post mmenigma  
                    Started by frankthearm, Today, 09:08 AM
                    9 responses
                    34 views
                    0 likes
                    Last Post NinjaTrader_Clayton  
                    Started by NRITV, Today, 01:15 PM
                    2 responses
                    9 views
                    0 likes
                    Last Post NRITV
                    by NRITV
                     
                    Started by maybeimnotrader, Yesterday, 05:46 PM
                    5 responses
                    26 views
                    0 likes
                    Last Post NinjaTrader_ChelseaB  
                    Started by quantismo, Yesterday, 05:13 PM
                    2 responses
                    21 views
                    0 likes
                    Last Post quantismo  
                    Working...
                    X