Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Make this reverse work...

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

    Make this reverse work...

    I've attached 4 tabs of the Control Center.

    I'm using NinjaScript to automate a strategy.

    To paraphase my code:

    OnBarUpdate()

    Upon a long signal
    ExitShort()
    EnterLong(1)

    Upon a short signal
    ExitLong()
    EnterShort(1)

    Problem: If the current trade is long 1 contract, then upon a short signal, I end up being short 2 contracts, instead of being short 1 contract. Why? I've attached various tabs from my Control Center.

    I simply want to reverse my position upon each signal.
    Attached Files

    #2
    No need to exit the current position explicitly. Just issue the Enter... method to enter the opposite position and NT internally will close any pending position.

    See SampleMACrossOver strategy

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    79 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    45 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    29 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    32 views
    0 likes
    Last Post TheRealMorford  
    Started by Mindset, 02-28-2026, 06:16 AM
    0 responses
    66 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Working...
    X