• 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

Closing out Multi Instrument Strategy based on Profit

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

    Closing out Multi Instrument Strategy based on Profit

    Hi I am having some issue with closing out a multi-instrument strategy.

    I would like to close out the position if the sum of both instruments dollar value is >= $30.


    //Enter Long index0 and Short index1

    if (entry logic here)
    {
    EnterLong(0, Positions[0].Quantity, "L1");
    EnterShort(1, Positions[1].Quantity, "S1");
    Print("Long Entry on Primary Instrument (index0)");
    Print("Short Entry on Secondary Instrument (index1)");
    }


    //take profit
    if (Positions[0].GetUnrealizedProfitLoss(PerformanceUnit.Currency, Closes[0][0]) + Positions[1].GetUnrealizedProfitLoss(PerformanceUnit.Currency, Closes[1][0]) >= 30)
    {

    ExitLong(0, Positions[0].Quantity, "exit","L1");
    ExitShort(1, Positions[1].Quantity, "exit","S1");
    }

    #2
    Hello brucelevy,

    Thank you for your note.

    I put your script inside the attached strategy and don't see any issue with the script.

    What is the issue you are having exactly?

    I look forward to your reply.
    Attached Files
    Alan P.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by andurpithe, Today, 03:21 AM
    0 responses
    3 views
    0 likes
    Last Post andurpithe  
    Started by bultakkoz, Today, 02:28 AM
    0 responses
    4 views
    0 likes
    Last Post bultakkoz  
    Started by kunahoylea, Today, 01:07 AM
    0 responses
    1 view
    0 likes
    Last Post kunahoylea  
    Started by qewcool, Yesterday, 10:51 PM
    0 responses
    2 views
    0 likes
    Last Post qewcool
    by qewcool
     
    Started by momchi, Yesterday, 10:09 PM
    0 responses
    2 views
    0 likes
    Last Post momchi
    by momchi
     
    Working...
    X