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

Exit in different dataseries not working

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

    Exit in different dataseries not working

    Hi there

    Im doing bit of testing and i now have 5 different dataseries that im using.

    One is MES, and other is ES (trying to use ES to enter on MES)

    AddDataSeries(Data.BarsPeriodType.Tick, 1); (just the same as the main chart i run it on ES.
    AddDataSeries("MES 03-21", Data.BarsPeriodType.Tick, 1);


    Im running no script - when in the BarsInProgress == 4 -
    but i enter with the following code into that 4 series:
    EnterLongLimit(4, true, 1, CurrentLimPrice, "Long");

    and i believe it is entering - but I dont see it being able to exit - with this code:
    ExitLong(4, Convert.ToInt32(DefaultQuantity), "OWStoplossExitLong", "Long");

    If i Enter and Exit on dataseries 1 - then all is workign - but when i use the above code - it enters - and actually does some few exits - but almost all exits happens at end of day.

    can you see what may be wrong with this?

    THanks

    #2
    Hello KarstenKafl,

    Thank you for your post.

    The first thing I would advise is to turn on the Order Trace function:

    Code:
     if (State == State.SetDefaults)
    {
    TraceOrders = true;
    }
    Once you then recompile the strategy, you can open a new NinjaScript Output window under New > NinjaScript Output. This will print a log of any orders submitted by the strategy during while it's running, along with any ignored orders. You can then look through and see what may be occurring.

    Here is a link to our help guide that goes into more detail on tracing orders:

    https://ninjatrader.com/support/help...aceorders2.htm

    Trace orders alone may not give you the full picture of whether or not a trade should have been entered or exited on a given bar, so adding prints to your strategy that will show in the NinjaScript Output window, with information on what the variables you're using for your conditions are on a particular bar, can be helpful. Even just placing a print right after the exit to print that the position should have been exited may be helpful as well.

    This forum post goes into great detail on how to use prints to help figure out where issues may stem from — this should get you going in the correct direction. You can even add these using the Strategy Builder.

    https://ninjatrader.com/support/foru...ns-not-working

    If you run into issues like we saw here, the above information will allow you to print out all values used in the condition in question that may be evaluating differently. With the printout information you can assess what is different between the two.

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

    Comment


      #3
      thanks Kate

      Im already using print and the output window - and i will have to use it more + trace orders.

      But just so im sure - it means that the code i use above - as far as yuo can see that should not be the "issues" right? = it shoul dbe possible to exit an order with the code:
      ExitLong(4, Convert.ToInt32(DefaultQuantity), "OWStoplossExitLong", "Long"); from the 4.added data series right?

      Comment


        #4
        Hello KarstenKafl,

        Thank you for your reply.

        Yes, that's the correct syntax for submitting an ExitLong() to the 4th added data series. I don't see anything wrong with that.

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

        Comment


          #5
          Hi Kate

          thanks again - i found out that the issue is most likley caused by me checking if the Position.MarketPosition is flat or not - before i enter/exit.

          It looks like it is not easy to use that for checking for positions in a seconddary data series - or is it?

          or can i somehow use the trace orders - to see if there is actually an open position?

          I also check Position.AveragePrice - and i assume that is also not working? - or can i enter what symbol in looking for the positions in?

          thanks agian.
          Last edited by KarstenKafl; 01-05-2021, 02:40 PM.

          Comment


            #6
            Hello KarstenKafl,

            Thank you for your reply.

            In a multi-time frame script, to check the position on a specific added data series you'd need to use Positions[index].MarketPosition, where the index is the index for the added series. So, if you're wanting to check that the position on the 4th added data series is flat, you'd use something like:

            Code:
            if (Positions[4].MarketPosition == MarketPosition.Flat)
            {
                 // do something here
            }


            You'd use the same to access the AveragePrice: Positions[4].AveragePrice

            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 Segwin, 05-07-2018, 02:15 PM
            10 responses
            1,767 views
            0 likes
            Last Post Leafcutter  
            Started by Rapine Heihei, 04-23-2024, 07:51 PM
            2 responses
            30 views
            0 likes
            Last Post Max238
            by Max238
             
            Started by Shansen, 08-30-2019, 10:18 PM
            24 responses
            943 views
            0 likes
            Last Post spwizard  
            Started by Max238, Today, 01:28 AM
            0 responses
            9 views
            0 likes
            Last Post Max238
            by Max238
             
            Started by rocketman7, Today, 01:00 AM
            0 responses
            7 views
            0 likes
            Last Post rocketman7  
            Working...
            X