Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Sync account position

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

    #16
    asafs, Thank you for your reply. We would like to see how this is used within the code, if possible, as we are having some difficulty getting the statements to compile and have something wrong at present. Are you able to upload some code fragments which will help us? Thanks - Helen

    Comment


      #17
      Please check the code below. It processes historical orders and it looks like restores current market position when you load strategy. Sync Account Position is turned off.

      Code:
      if( CurrentBar < Bars.Count-1 )
      {
      	foreach( Order order in Account.Orders )
      	{
      		if( (CurrentBar == Bars.GetBar(order.Time)-1   )&& order.OrderState == OrderState.Filled   )
      		{
      							
      			if( order.OrderAction == OrderAction.Buy )
      			{
      				if( order.OrderType == OrderType.Market )
      				{
      					if( Close[0] >= order.AvgFillPrice ) EnterLongStop(  order.Quantity, order.AvgFillPrice, order.Name );
      					if( Close[0] < order.AvgFillPrice ) EnterLongLimit(  order.Quantity, order.AvgFillPrice, order.Name );
      				}
      				if( order.OrderType == OrderType.Limit )EnterLongLimit( order.Quantity, order.LimitPrice, order.Name );
      			}
      			if( order.OrderAction == OrderAction.Sell )
      			{
      				if( order.OrderType == OrderType.Market )
      				{
      					if( Close[0] >= order.AvgFillPrice ) ExitLongStop(  order.Quantity, order.AvgFillPrice);
      					if( Close[0] < order.AvgFillPrice ) ExitLongLimit(  order.Quantity, order.AvgFillPrice);
      				}
      				if( order.OrderType == OrderType.Stop )ExitLongStop(  order.Quantity, order.StopPrice );
      			}
      		}
      	}
      }

      Comment


        #18
        Account position / Order status

        Is there any way to check account position status from within a strategy?
        In NT8 does:

        Account.Position.MarketPosition == MarketPosition.Flat / Long /Short
        get the account NOT strategy position?

        Regards
        Last edited by elliot5; 04-28-2016, 06:46 AM.

        Comment


          #19
          Hello everington_f,


          "In NT8 does: Account.Position.MarketPosition == MarketPosition.Flat / Long /Short get the account NOT strategy position?"


          To monitor the account position in NT 8, you would need to use:
          Code:
          [LEFT] if (PositionAccount .MarketPosition == MarketPosition.Flat )
                                                         {
          //Do Something
                                                         }
          [/LEFT]


          Here is the PositionAccount Help Guide to assist you further.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Mindset, 04-21-2026, 06:46 AM
          0 responses
          101 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by M4ndoo, 04-20-2026, 05:21 PM
          0 responses
          144 views
          0 likes
          Last Post M4ndoo
          by M4ndoo
           
          Started by M4ndoo, 04-19-2026, 05:54 PM
          0 responses
          71 views
          0 likes
          Last Post M4ndoo
          by M4ndoo
           
          Started by cmoran13, 04-16-2026, 01:02 PM
          0 responses
          125 views
          0 likes
          Last Post cmoran13  
          Started by PaulMohn, 04-10-2026, 11:11 AM
          0 responses
          79 views
          0 likes
          Last Post PaulMohn  
          Working...
          X