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

Variables Reset

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

    Variables Reset

    SorrySorrySorry
    Last edited by tranta; 06-05-2014, 03:12 PM.

    #2
    Hi tranta,

    Are you using the ExitLongLimit as the stop loss? (this has the profit target variable in the price calculation and an ExitLongLimit is used as a profit target)

    You should set this to an IOrder so that you can update the price later.

    Are you wanting both entries to be triggered before the exit long limits are submitted?
    (Currently this is how your code is set. Both entry IOrders must not be null. So the orders do not have to fill, they just can't be null.

    What behavior are you wanting from this script?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello, Thank you for your reply. Im using ExitLongLimit as profitTarget, Strategy should enter to Long position after CCi crossabove "hranice" if hit profittarget -> flat position. If not enter to second only If price is below 30 ticks from last enter long position. and so on.

      Comment


        #4
        Hello tranta,

        The first ExitLongLimit should be placed after the entryOrder is submitted and the second ExitLongLimit should be placed after the entryOrder1 is submitted.

        Are you finding these are not being submitted?

        What is the incorrect behavior you are experiencing?

        Also, what instrument and interval are you testing this script on, because I am having difficulty getting the entry order conditions to be met.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hi tranta,

          Using YM 06-14 5 Minute (with Entries per direction set to 100 so they are not limited) I am getting the 14 trades in the screenshot.

          The reason that it does not trade often is when the crossabove happens, the close is not greater than the open.

          But this strategy does trade on the YM 06-14 5 Minute.

          Also attached is the output from prints I have added to the code to see what the conditions are evaluating as.

          Anywhere there is a crossover the cross above prints.
          Attached Files
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            Please try backtest from 1.1:2014. You will see my problem, and could you attache screenshot of chart with plotted traders.
            Last edited by tranta; 06-03-2014, 03:37 PM.

            Comment


              #7
              Hello,

              Attached is a screenshot of the trades made by the script on YM 06-15 5 Minute (I accidently did 1 minute on my last test) from 1/1/2014 to 6/2/2014 using the code in your post 5.

              I think the issue you are referring to is that the ExitLongLimits are not being submitted.

              This is because you are setting the entryOrder and entryOrder1 to null before the position becomes long.

              When the entryOrder is submitted the following code is run in OnBarUpdate() and the entry order handles are set to null. This happens right away and way before the position is ever updated.

              if (Position.MarketPosition == MarketPosition.Flat)
              {
              entryOrder1 = null;
              entryOrder = null;
              }

              This code is best in OnPositionUpdate().
              Attached Files
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                Hello tranta,

                What parameters are you using with this script?
                What time zone are you in?
                (I am not getting the same orders on the same day)

                Why is this order a bug? The order should not have not been submitted because the entryOrder was not null?
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Hello
                  1) Central Europe Time
                  2)It took 2 order in same time, it should take only one.
                  3) Profit 7, Diff 28, Hranice -150, Period 10
                  Thank your for your help

                  Comment


                    #10
                    Hi tranta,

                    There is nothing in this code that would prevent the second order from being placed at the same time as the first order if (High[0] < Variable0 - Diff * TickSize).

                    In other words, if the first condition is true, then the first part of the second condition is true too.

                    What code should be preventing this?

                    Would you like to add code to make sure that the second order is not placed at the same time as the first order?

                    If so move the second condition before the first condition so that entryOrder does not get set before entryOrder1.
                    Chelsea B.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by nandhumca, Today, 03:41 PM
                    0 responses
                    3 views
                    0 likes
                    Last Post nandhumca  
                    Started by The_Sec, Today, 03:37 PM
                    0 responses
                    3 views
                    0 likes
                    Last Post The_Sec
                    by The_Sec
                     
                    Started by GwFutures1988, Today, 02:48 PM
                    1 response
                    5 views
                    0 likes
                    Last Post NinjaTrader_Clayton  
                    Started by ScottWalsh, 04-16-2024, 04:29 PM
                    6 responses
                    33 views
                    0 likes
                    Last Post ScottWalsh  
                    Started by frankthearm, Today, 09:08 AM
                    10 responses
                    36 views
                    0 likes
                    Last Post frankthearm  
                    Working...
                    X