Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

how to refer to the price of previous entry?

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

  • NinjaTrader_Tim
    replied
    Hi no111,

    Make sure your condition are being met with Print()s

    For example...
    Code:
    if ( Close[0] < Close[1] 
                    && Position.Quantity == 1) 
                { 
                  Print("Second condition has been triggered");
                  EnterLong(2, "L2"); 
                }

    Leave a comment:


  • no111
    replied
    First condition set works good. So if price is above 200MA and RSI is below 25 for two days, buy 1 unit.

    But the second&third unit never enters.. What am I doing wrong?

    I want it enter when:

    Unit 1 is entered
    Close is below close yesterday.

    There are no errors in the log.
    Anybody has a solution for this?

    PHP Code:
            {
                
    // Condition set 1
                
    if (RSI(23)[0] < 25
                    
    && RSI(23)[1] < 25
                    
    && Close[0] > SMA(200)[0])
                {
                    
    EnterLong(1"L1");
                }
                if ( 
    Close[0] < Close[1]
                    && 
    Position.Quantity == 1)
                {
                    
    EnterLong(2"L2");
                }
                
    // Condition set 2
                
    if (RSI(23)[0] > 70)
                {
                    
    ExitLong("EXITT""");
                }
            } 
    Last edited by no111; 05-28-2010, 12:29 PM.

    Leave a comment:


  • NinjaTrader_Tim
    replied
    Hi no111,

    If the only condition is Quantitiy==2, you could simply enter with 5 contracts initially.

    If you're looking to add more conditions to that, start by adding Print()s to ensure your condition is being met and entered.
    More info at - http://www.ninjatrader.com/support/f...ead.php?t=3418

    Also, it may take another bar for it to recognize the initial contracts.

    Check for any errors in the Log tab while running the script.

    Leave a comment:


  • no111
    replied
    Does anyone know how to fix this?

    Leave a comment:


  • no111
    replied
    Max. entries: 66.

    When RSI is below 25; 2 long.

    So the nextbar should be added by 3 because of: if (Position.Quantity == 2)
    {
    EnterLong(3, "long3");
    }

    But it doesn't.. what is wrong?


    PHP Code:
    protected override void Initialize()
            {
                 
    EntriesPerDirection 66
                
    EntryHandling EntryHandling.AllEntries
                
    Add(SMA(200));
                
    Add(RSI(23));

                
    CalculateOnBarClose true;
            }

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

                
    // Condition set 2
                
    if (Close[0] > SMA(200)[0]
                    && 
    RSI(23).Avg[0] < 25
                    
    && RSI(23).Avg[1] < 25)
                {
                    
    EnterLong(2"long2");
                }
                

                
    // Condition set 3
                
    if (Position.Quantity == 2)
                {
                    
    EnterLong(3"long3");
                }

                
    // Condition set 4
                
    if (RSI(23).Avg[0] > 70
                    
    && Position.MarketPosition == MarketPosition.Long)
                {
                    
    ExitLong("exit""");
                }
            }

            
    #region Properties
            
    [Description("")]
            [
    Category("Parameters")]
            public 
    bool MyInput0
            
    {
                
    get { return myInput0; }
                
    set myInput0 value; }
            }
            
    #endregion
        
    }

    Leave a comment:


  • NinjaTrader_RyanM1
    replied
    Hello no111,

    This is controlled through EntriesPerDirection and EntryHandling properties. These properties can be hard coded or set when you run the strategy.

    If you want to access the current position, you can access this in the wizard under Strategy > Current Position size.

    Leave a comment:


  • no111
    replied
    Originally posted by NinjaTrader_Tim View Post
    Hi no111,

    This can be done using the wizard as well, and the logic descrsibes....

    "if the close of the previous bar is greater than the close of the current bar"
    I know, thanks.
    But I want that only if there is already a position of 2.
    How do I set that.

    My purpose is to average in..

    Leave a comment:


  • NinjaTrader_Tim
    replied
    Hi no111,

    This can be done using the wizard as well, and the logic descrsibes....

    "if the close of the previous bar is greater than the close of the current bar"
    Attached Files

    Leave a comment:


  • no111
    replied
    Originally posted by NinjaTrader_Tim View Post
    Hi no111,

    Can you clarify a little on what you are intending to do?

    Position.AvgPrice will return the average price of a strategy's position.

    More info at - http://www.ninjatrader-support.com/H....html?AvgPrice
    I want to add on the position if close[1] > close[0]

    Leave a comment:


  • NinjaTrader_Tim
    replied
    Hi no111,

    Can you clarify a little on what you are intending to do?

    Position.AvgPrice will return the average price of a strategy's position.

    More info at - http://www.ninjatrader-support.com/H....html?AvgPrice

    Leave a comment:


  • no111
    replied
    Let say the strategy isfilled with quantity of 2.

    When i'm trying this, see attachment..

    it doesnt work?
    Attached Files

    Leave a comment:


  • NinjaTrader_Ray
    replied
    No.

    Here is a current list of available NinjaScript consultants available for contract work.

    http://www.ninjatrader.com/webnew/pa...injaScript.htm

    Leave a comment:


  • justmake
    replied
    Thanks for the answer,Josh.
    Do you offer the service of writing customized ninja script ?
    how would you charge it?
    Justmake

    Leave a comment:


  • NinjaTrader_JoshP
    replied
    You can save the current position's avg entry price into a temporary variable. That will grant you access to it in the future. Definitely doable with custom programming in NinjaScript.

    Leave a comment:


  • justmake
    replied
    Hello,Ray,

    Thanks for reply. Is there any way for me to refer to the previous entry price in
    Ninja Script language?

    thanks,
    Justmake

    Leave a comment:

Latest Posts

Collapse

Topics Statistics Last Post
Started by wildleanketosale, Today, 03:49 AM
0 responses
1 view
0 likes
Last Post wildleanketosale  
Started by wildleanketosale, Today, 03:48 AM
0 responses
3 views
0 likes
Last Post wildleanketosale  
Started by hiltonvarai, Today, 03:10 AM
0 responses
1 view
0 likes
Last Post hiltonvarai  
Started by afyuwi, Today, 02:33 AM
0 responses
2 views
0 likes
Last Post afyuwi
by afyuwi
 
Started by wushutrades, Today, 01:41 AM
0 responses
5 views
0 likes
Last Post wushutrades  
Working...
X