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

different entry prices in automated strategy with multiple independent entries

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

    different entry prices in automated strategy with multiple independent entries

    hello everyone,


    i have a couple of questions, i am working on an automated strategy that would take multiple positions, and i want to know what coding alternatives would i have to know the exact entry price of the latest position the strategy opened. let's say the entries looked a little something like this; when the uptrend condition first becomes true a first position would be opened, and then if time (number of bars observed) goes by and no new lower lows have been observed, the strategy would open up several additional positions:

    Code:
    if uptrend;
            {
            EnterLong(ps01, "p01");
            }
    
    
    if bars later and no new lower lows;
    	{
    	EnterLong(ps02, "p02");
    	}
    			
    if bars later and no new lower lows;
    	{
    	EnterLong(ps03, "p03");
    	}
    
    if bars later and no new lower lows;
    	{
    	EnterLong(ps04, "p04");
    	}
    
    if bars later and no new lower lows;
    	{
    	EnterLong(ps05, "p05");
    	}

    i want to know the entry price of each individual position (as is evident, each of them would have its own name) so that i can manage stops individually for each position if price moves for - against me, and also so that i could know how all the positions are doing collectively.


    is there any command to call the exact entry price of a given entry so that i could adjust the stops for all positions as price moved for - against me? or alternatively, if it was possible to set a trailing stop for each individual entry since that particular position was opened, how could i do that?


    also, all of these entries are market orders as far as i understand. could it be possible to place limit orders for these long positions a number of ticks below the price observed when the order is triggered? and how could the strategy know whether or not the order ever got filled and at what price?

    very well, thanks.

    #2
    Originally posted by rtwave View Post
    hello everyone,


    i have a couple of questions, i am working on an automated strategy that would take multiple positions, and i want to know what coding alternatives would i have to know the exact entry price of the latest position the strategy opened. let's say the entries looked a little something like this; when the uptrend condition first becomes true a first position would be opened, and then if time (number of bars observed) goes by and no new lower lows have been observed, the strategy would open up several additional positions:

    Code:
    if uptrend;
            {
            EnterLong(ps01, "p01");
            }
    
    
    if bars later and no new lower lows;
    	{
    	EnterLong(ps02, "p02");
    	}
    			
    if bars later and no new lower lows;
    	{
    	EnterLong(ps03, "p03");
    	}
    
    if bars later and no new lower lows;
    	{
    	EnterLong(ps04, "p04");
    	}
    
    if bars later and no new lower lows;
    	{
    	EnterLong(ps05, "p05");
    	}

    i want to know the entry price of each individual position (as is evident, each of them would have its own name) so that i can manage stops individually for each position if price moves for - against me, and also so that i could know how all the positions are doing collectively.


    is there any command to call the exact entry price of a given entry so that i could adjust the stops for all positions as price moved for - against me? or alternatively, if it was possible to set a trailing stop for each individual entry since that particular position was opened, how could i do that?


    also, all of these entries are market orders as far as i understand. could it be possible to place limit orders for these long positions a number of ticks below the price observed when the order is triggered? and how could the strategy know whether or not the order ever got filled and at what price?

    very well, thanks.
    Assign your orders to named IOrders, and query the IOrders if you need information about executions or orders.

    Comment


      #3
      Hello rtwave,

      Thank you for writing in.

      koganam would be correct; you'll want to assign your orders to IOrder objects: https://ninjatrader.com/support/help...t7/?iorder.htm

      Check the object's AvgFillPrice property to obtain the average fill price of the order.

      If you want to place additional orders when a particular order has filled, you'll want to use the OnExecution() method: https://ninjatrader.com/support/help...nexecution.htm

      Please, let us know if we may be of further assistance.
      Zachary G.NinjaTrader Customer Service

      Comment


        #4
        thanks you both.


        i had never heard about IOrder objects or the OnExecution() method, but i will get busy checking out the links you posted and hopefully will be able to make them work in my strategies.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by GLFX005, Today, 03:23 AM
        0 responses
        1 view
        0 likes
        Last Post GLFX005
        by GLFX005
         
        Started by XXtrader, Yesterday, 11:30 PM
        2 responses
        11 views
        0 likes
        Last Post XXtrader  
        Started by Waxavi, Today, 02:10 AM
        0 responses
        6 views
        0 likes
        Last Post Waxavi
        by Waxavi
         
        Started by TradeForge, Today, 02:09 AM
        0 responses
        12 views
        0 likes
        Last Post TradeForge  
        Started by Waxavi, Today, 02:00 AM
        0 responses
        2 views
        0 likes
        Last Post Waxavi
        by Waxavi
         
        Working...
        X