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

2 entries, 1 profit target exit problem

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

    2 entries, 1 profit target exit problem

    Hi,

    I have run a problem when I want to set 2 entries and take profits one of them with profit target parameter.
    I am trying to take profit half of the entries and let rest of the entries go until exit conditions are met.

    This works well in backtesting but when I am running live simulation the profit target closes both entries.

    Any advises for the problem?

    PTargetValue = 200;


    SetProfitTarget("Longentry1", CalculationMode.Currency, PTargetValue);
    SetProfitTarget("Shortentry1", CalculationMode.Currency, PTargetValue);


    // Enter Long
    if (Logic to enter long)
    {
    EnterLong(Convert.ToInt32(EntryQuantity), "Longentry1");
    EnterLong(Convert.ToInt32(EntryQuantity), "Longentry2");
    }

    // Enter short
    if (Logic to enter short))
    {
    EnterShort(Convert.ToInt32(EntryQuantity), "Shortentry1");
    EnterShort(Convert.ToInt32(EntryQuantity), "Shortentry2");
    }​


    ​BR

    Gelotuz

    #2
    Hello Gelotuz,

    Thank you for your note.

    I'm not seeing the same on my end with this test script. I'm seeing them scaling out as expected unless the stop loss is hit. Do you see the same on your end with the example script?

    Thanks in advance, I look forward to assisting you further.​
    Attached Files
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      Hi Kate,

      Thank you for your respond.
      I tried to your example script and it seemed to work fine.

      I don't see the difference between codes except in example it is using CalculationMode.Ticks and I am trying to use CalculationMode.Currency
      CalculationMode.Currency: "When this mode is used, StopTargetHandling will automatically be set to ByStrategyPosition"
      Could this be the reason as StopTargetHandling is also different in my code as the example uses PerEntryExecution.

      I tried to swap CalculationMode to Currency in example but I wasn't able to test it yet.

      Here is picture how my code is acting in live simulation, first one (longs) is historical data and it works as intended, 2nd (shorts) is live data where problem occurs.

      Click image for larger version

Name:	ninjabug.png
Views:	86
Size:	28.4 KB
ID:	1215526


      ​BR

      Gelotuz

      Comment


        #4
        Hello Gelotuz,

        Thank you for your reply.

        That'd be what's causing it - in order to use Currency as the mode for the stops, it forces you to use By Strategy Position as the StopTargetHandling, which means any stop you set will be for the whole position.

        You'd want to use ticks instead if you're going to scale out there.

        Please let us know if we may be of further assistance to you.
        Kate W.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by lightsun47, Today, 03:51 PM
        0 responses
        4 views
        0 likes
        Last Post lightsun47  
        Started by 00nevest, Today, 02:27 PM
        1 response
        8 views
        0 likes
        Last Post 00nevest  
        Started by futtrader, 04-21-2024, 01:50 AM
        4 responses
        44 views
        0 likes
        Last Post futtrader  
        Started by Option Whisperer, Today, 09:55 AM
        1 response
        13 views
        0 likes
        Last Post bltdavid  
        Started by port119, Today, 02:43 PM
        0 responses
        9 views
        0 likes
        Last Post port119
        by port119
         
        Working...
        X