Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

strategy relation to ATM

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

    strategy relation to ATM

    I'm entering trades manually on the DOM with an ATM strategy. I want to close the trade automatically if certain conditions occur, so I wrote a strategy like the following;

    if(Position.MarketPosition == MarketPosition.Long && Bars.PercentComplete >= 0.67
    && 'the rest of my criteria')ExitLong();

    This however does not close the position. Is this because the position was not opened with the strategy or do I need additional coding to indicate the position was opened with the DOM?

    Thanks,

    Safetrading

    #2
    safetrading, the issue here is that the strategy was never long coming from historical data to begin with, as such the rule to send an ExitLong market order never triggered.

    What you would need to do is execute a historical long entry with the strategy code, so that it would be having the position to exit from when you enable it after the manual trade is running.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Sorry, but I don't understand what it means to "execute a historical long entry", are there any code examples you could point me to?

      Thanks

      Comment


        #4
        Unfortunately I would not have a code example, but the idea is this - you would need to ensure the strategy position is long coming from historical data, so you could pick up the long exit > otherwise if strategy was flat it would be ignored. So you would for example execute it on the prior day on a bar close to your manual entry time, this could be code for as user input so you set the time you entered via the discretionary trade. Another option would be issuing a fresh Short signal if the strategy is flat and your exit criteria are met, this way you don't have to rely on picking up a historical position, but would execute the short which would take your account long flat.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Thanks for the response, it gives me a direction to work on it.

          Have a nice day.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by ZenCortexCLICK, Today, 04:58 AM
          0 responses
          2 views
          0 likes
          Last Post ZenCortexCLICK  
          Started by sidlercom80, 10-28-2023, 08:49 AM
          172 responses
          2,280 views
          0 likes
          Last Post sidlercom80  
          Started by Irukandji, Yesterday, 02:53 AM
          2 responses
          17 views
          0 likes
          Last Post Irukandji  
          Started by adeelshahzad, Today, 03:54 AM
          0 responses
          5 views
          0 likes
          Last Post adeelshahzad  
          Started by Barry Milan, Yesterday, 10:35 PM
          3 responses
          13 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Working...
          X