Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Do SetProfitTarget() & SetStopLoss() for Multi-Time Frame & Instruments Strategy

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

    Do SetProfitTarget() & SetStopLoss() for Multi-Time Frame & Instruments Strategy

    Do SetProfitTarget() & SetStopLoss() work for Multi-Time Frame & Instruments Strategy?
    The total of all the instruments and the individuals.

    #2
    Hello johnnybegoode, thanks for your post.

    If you set the stop or target from State.Configure, then that will be applied to all orders generated by the strategy. You can also set individual stops and targets like so:

    Code:
    ...
    
    else if (State == State.Configure)
                {
                    AddDataSeries("CL 11-19", BarsPeriodType.Minute, 1);
                }
            }
    
            protected override void OnBarUpdate()
            {
                if(State == State.Historical)
                    return;
    
                if(BarsInProgress == 0)
                {
                    SetStopLoss(CalculationMode.Ticks, 10);
                    EnterLong();
                }
    
                if(BarsInProgress == 1)
                {
                    SetStopLoss(CalculationMode.Ticks, 30);
                    EnterLong();
                }
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      I mean could you make it work based the sum/total of all the combined instruments. It works on individual instrument.

      i.e. with 2 open positions

      BarsArray[0] - EURUSD is at -$20
      BarsArray[1] - GBPUSD is at $40

      I would like SetProfitTarget() at $20 and it closes both positions at the same time.
      At the moment, it is based on individual instrument's profit.

      Thank you!
      Last edited by johnnybegoode; 10-04-2019, 03:53 PM.

      Comment


        #4
        Hi johnnybegoode, thanks for your reply.

        Correct me if I am wrong, do you want to set the stop loss based on the average position? If so then just set a global stop loss and profit target. This will set a common stop loss for any entry that occurs. Any other values will need to be calculated by your script.
        Chris L.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by trilliantrader, Yesterday, 03:01 PM
        3 responses
        30 views
        0 likes
        Last Post NinjaTrader_Clayton  
        Started by cmtjoancolmenero, Yesterday, 03:58 PM
        4 responses
        26 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by Brevo, Today, 01:45 AM
        1 response
        14 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by rjbtrade1, 11-30-2023, 04:38 PM
        2 responses
        74 views
        0 likes
        Last Post DavidHP
        by DavidHP
         
        Started by suroot, 04-10-2017, 02:18 AM
        5 responses
        3,022 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Working...
        X