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

Placing long/short orders on multiple instruments

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

    Placing long/short orders on multiple instruments

    Hi,

    I would like to place different size positions long and short on multiple stocks. For example, let's assume the whole portfolio should be long $100 and short $100, and I have 5 stocks that I am trading. My algorithm computes a "weight" to put on each stock, with 1.0 being the total portfolio weight on each side long or short. Meaning, if I assign a weight of .5 to a stock, then it should have a position of long $50, or if I have a weight of -.25, then the position should be short $25. My algorithm ensures that each side (long or short) adds up to 1.0 (or -1.0 on the short side), so this way the long and short sides are the same size, so the portfolio always remains dollar-neutral (long and short same amount).

    Can you please show me some simple code that would take the weights for stocks that my algorithm produces (on a daily basis) and place the appropriate trade entries? For example, can I specify a dollar amount of stock to buy in my trade order? What should the NinjaScript command look like?

    Thanks!
    Protis

    #2
    Hey mate, are you performing trades on stocks, currency or futures?

    On currency the easiest way to control it is to auto fill with an amount equal to a dollar value you want invested. AUDJPY is a flat value, so 1000 = $1000, on the AUSUSD its 100000 = $1000.

    If it's stocks you'll need to determine the value / price before getting your entry amount, so if its $25 a stock you can only afford 1 if your trading 4 $25 stocks.

    You can adjust your account cash starting value. My startegy is currently testing with $10,000 starting over 6 forex trades and evenly splits based on 70% of that. So it assume if it's trading 6 in total that if can invest up to ~1160 each.

    Comment


      #3
      Thanks! I am actually working with stocks...could you please be more specific with some code snippets? Let's say I already know how I want to distribute the account's cash at each time step, according to "weights" that I give to each stock, where all the positive weights add up to 1.0 and all the negative weights add up to -1.0. Basically I want to end up with an equal amount of money long and short.
      Thanks again,
      Protis

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by LillyMarv, Today, 06:47 AM
      1 response
      9 views
      0 likes
      Last Post marcus2300  
      Started by michi08, Today, 08:51 AM
      1 response
      5 views
      0 likes
      Last Post bltdavid  
      Started by awwenzovs, Today, 08:03 AM
      1 response
      7 views
      0 likes
      Last Post bltdavid  
      Started by nicthe, Today, 07:38 AM
      1 response
      12 views
      0 likes
      Last Post bltdavid  
      Started by algospoke, 02-19-2024, 03:25 PM
      4 responses
      36 views
      0 likes
      Last Post gummybar  
      Working...
      X