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 judysamnt7, 03-13-2023, 09:11 AM
          4 responses
          59 views
          0 likes
          Last Post DynamicTest  
          Started by ScottWalsh, Today, 06:52 PM
          4 responses
          36 views
          0 likes
          Last Post ScottWalsh  
          Started by olisav57, Today, 07:39 PM
          0 responses
          7 views
          0 likes
          Last Post olisav57  
          Started by trilliantrader, Today, 03:01 PM
          2 responses
          21 views
          0 likes
          Last Post helpwanted  
          Started by cre8able, Today, 07:24 PM
          0 responses
          10 views
          0 likes
          Last Post cre8able  
          Working...
          X