• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Exit Long() followed by Position check

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

    Exit Long() followed by Position check

    I'm using OnMarketData to enter trades and only want one entry per direction. Below is pseudo code on how I want to implement it.

    Say I'm long and the condition to enter short is true. Could it be possible that ExitLong() doesn't exit my long "quick enough," and therefore Position.MarketPosition == MarketPosition.Flat evaluates to false?

    Thanks

    Code:
    protected override void OnMarketData(MarketDataEventArgs e){
    
          if (condition to enter short) {
    
               ExitLong();
    						
               if (Position.MarketPosition == MarketPosition.Flat){
                  //enter short
                }
           }
    }

    #2
    Yes, think that could be the case :::grimReaper:::, if you tied your entry to only a specific Level 1 event - though fill for a market exit should be quick for a liquid instrument (but certainly depends on instrument and time traded).
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Thanks Bertrand, good to know. In any case it's a simple fix:

      Code:
      protected override void OnMarketData(MarketDataEventArgs e){
      
            if (condition to enter short) {
      						
                 if (Position.MarketPosition == MarketPosition.Short){
                    return;
                 } else {
                    ExitLong()
                    //and enter short
                  }
             }
      }

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by bbdjad, Today, 04:36 AM
      0 responses
      1 view
      0 likes
      Last Post bbdjad
      by bbdjad
       
      Started by mittie3, Today, 03:33 AM
      0 responses
      5 views
      0 likes
      Last Post mittie3
      by mittie3
       
      Started by Againmain1, Today, 03:04 AM
      0 responses
      8 views
      0 likes
      Last Post Againmain1  
      Started by tonytimpa, Today, 01:33 AM
      0 responses
      5 views
      0 likes
      Last Post tonytimpa  
      Started by kiwidtrader, Yesterday, 11:49 PM
      0 responses
      5 views
      0 likes
      Last Post kiwidtrader  
      Working...
      X