Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Position Size Problem

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

    Position Size Problem

    I like Ninjatrader so far but am stuck on this one thing forever...

    I cant seem to clear out the position size to 0 on a particular instrument.
    The recommended approach is to put a market order to clear it. So, when I do that e.g. I have AUDJPY...it shows 50000L in position. Now I sell 50000 mkt, then it shows me 50000S in the strategy window...it keeps going between 50000L and 50000S. Kinda asinine.

    You need a way to reset the positions in the strategy system easily, and for users to key in by hand what they want it to be incase they are already in positions. Doing these fake buys and sells makes no sense at all.

    #2
    I know part of the problem

    The fact that there is no way to manually clear out positions is bad. But what is really causing my problem is that the OnBarUpdate is firing twice.
    Try this code and you will see what I mean by watching the Output window.

    --------------------
    public class RB3BarSetupV2 : Strategy
    {
    #region Variables
    // Wizard generated variables
    private int qty = 1; // Default setting for Qty
    // User defined variables (add any user defined variables below)
    bool flag=false;
    #endregion

    /// <summary>
    /// This method is used to configure the strategy and is called once before any strategy method is called.
    /// </summary>
    protected override void Initialize()
    {
    Add( PeriodType.Minute, 1);

    }

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

    Print("Time:"+Time[0]);
    }

    Comment


      #3
      Hello,

      For your original question:
      You need to use ExitLong() and ExitShort() to close out your positions. Otherwise you will be reverse each time like you are currently experiencing.

      For your most recent post:

      The Print() is occuring twice because you have two timeframes working since you put Add( PeriodType.Minute, 1); in your Initialized() method.

      So each time the bar interval is called you will get a Print(). BarsInProgress == 0 and BarsInProgress == 1 will each print once.

      Please review these link:
      http://www.ninjatrader-support.com/H...struments.html

      http://www.ninjatrader-support.com/H...BarSeries.html
      DenNinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by hazylizard, Today, 08:38 AM
      1 response
      8 views
      0 likes
      Last Post NinjaTrader_Erick  
      Started by geddyisodin, Today, 05:20 AM
      2 responses
      17 views
      0 likes
      Last Post geddyisodin  
      Started by Max238, Today, 01:28 AM
      5 responses
      45 views
      0 likes
      Last Post Max238
      by Max238
       
      Started by giulyko00, Yesterday, 12:03 PM
      3 responses
      13 views
      0 likes
      Last Post NinjaTrader_BrandonH  
      Started by habeebft, Today, 07:27 AM
      1 response
      16 views
      0 likes
      Last Post NinjaTrader_ChristopherS  
      Working...
      X