Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Exit at price instead of when bar close

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

    #16
    in the example they user to exit cross below... does that mean i have to use cross below to exit or can I use <= as well and get out on the tick that occurs?

    Comment


      #17
      Hello babouin77,

      Thank you for your reply.

      You can replace the conditions with your own exit conditions - this is simply an example.

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

      Comment


        #18
        got you. thanks. testing it now appreciate ur help

        Comment


          #19
          even the example is not exiting at the tick but at the close of the candle. what am I doing wrong?
          Attached Files

          Comment


            #20
            Originally posted by NinjaTrader_Kate View Post
            Hello babouin77,

            Thank you for your reply.

            In order for the exit order to be submitted right at the time the desired price is hit, you would need to run the script On Each Tick instead of On Bar Close. If you want your entries to be On Bar Close and your exits to be On Each Tick, you can certainly separate logic so some logic is only performed on the first tick of a bar and some logic executes on every tick. Please see the help guide example below for more information about separating your logic in this way:

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

            Please let us know if we may be of further assistance to you.
            Kate,

            Could this sample code be provided so as to open it in the Strategy Builder vs. reading the code from the Ninjascript editor..? I like to compare the codes side by side as it is written in the Strategy Builder as it is written in C#.. Then try to build it myself in the Strategy Builder.. It's just my method of trying to teach myself to understand...

            Thanks Michael
            Last edited by Mykro; 09-25-2020, 12:03 PM.

            Comment


              #21
              Hello babouin77 and Mykro,

              Thank you for your replies.

              babouin77, it's still possible for the strategy to exit at the open of a new bar if the conditions for exit became true at that time, however, with the default settings you should be seeing exits happening intrabar.

              Mykro, unfortunately this particular example cannot be reproduced in the strategy builder as it's not possible to utilize the IsFirstTickOfBar bool in a Strategy Builder strategy, so what you're requesting cannot be accomplished.

              Please let us know if we may be of further assistance to you.


              Kate W.NinjaTrader Customer Service

              Comment


                #22
                that is what I am saying in real time it did not exit intra bar when the cross below happened but rather when the bar closed... can you run it on ur end and confirm? thanks

                Comment


                  #23
                  Hello babouin77,

                  Thank you for your patience.

                  I've been testing for several days and cannot reproduce your findings. However, I've created an additional example for you to test which is attached that illustrates the same idea, separating some logic to run on the first tick of the bar and some to run on each tick. This particular example will only take trades in real time data, so you'll need to test in real time using the Sim101 account.

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

                  Comment


                    #24
                    thank you i appreciate it

                    Comment


                      #25
                      will this work on playback? or just in real time?

                      Comment


                        #26
                        i have this condition

                        if (PriceBreakoutRectangularBase(upwardBreakout,Volum eMultiple).Plot0[0] == 1 &&
                        Position.MarketPosition == MarketPosition.Flat && IsFirstTickOfBar)

                        and it is not doing it at all. it just wont open long. any idea why?

                        Comment


                          #27
                          Hello babouin77,

                          Thank you for your reply.

                          The provided example will only work on real time data, so it may either be tested on live data with the Sim101 or with Market Replay data on the Playback connection.

                          As far as your second question, we would suggest taking basic debugging steps such as adding prints to determine what values are being returned before posting on the forums to reduce multiple posts and make your threads easier for use to follow for others, as well as help you find resolutions more quickly without having to wait on our staff to respond.

                          I've included some tips for debugging below. The Playback Connection can be used to replay data as if it were realtime.

                          Debugging Tips - https://ninjatrader.com/support/help...script_cod.htm

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

                          Debugging in the Strategy Builder - https://drive.google.com/file/d/1mTq...w?usp=drivesdk

                          Playback Connection - https://ninjatrader.com/support/help...connection.htm

                          Debugging Demo - https://drive.google.com/file/d/1rOz...w?usp=drivesdk

                          If you add prints to the strategy to see what's being returned from PriceBreakoutRectangularBase(upwardBreakout,Volum eMultiple).Plot0[0] for each bar, that would likely put you on the right track.

                          It's also worth noting that the strategy must be running OnEachTick or OnPriceChange for IsFirstTickOfBar to return correctly.

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

                          Comment


                            #28
                            yeah I tried it on playback over the weekend and the entry was not on bar close or first tick of the bar... neither was the exit. I printed some values and the values are true but the above syntax did not enter when the bar is close and the new bar is forming on the first tick. i will try to run it now on real time and see. thanks the thing is the entry should be on the close and the start of the new one and not in the middle of the candle.
                            Last edited by babouin77; 10-05-2020, 12:25 PM.

                            Comment


                              #29
                              ok i added is IsFirstTickOfBar like in this statement

                              if (PriceBreakoutRectangularBase(upwardBreakout,Volum eMultiple).Plot0[0] == 1 &&
                              Position.MarketPosition == MarketPosition.Flat && IsFirstTickOfBar)

                              and the trade never opens up. but if I disable and re enable the trade I see that a long should have opened but it never did. any idea why? if I remove the if isfirsttickofbar it will open the trade normally. any input is highly appreciated. attached is the strategy if it helps.

                              Attached Files

                              Comment


                                #30
                                Hello babouin77,

                                Thank you for your reply.

                                When exporting scripts as an example, please do not export them as a compiled assembly as in your .zip file, as we cannot view the source code in that way, or save them as a .txt file as that adds extra steps for us to change the file type to .cs. We would ask that you export the source code from Tools > Export > NinjaScript Add-ons with the "export as a compiled assembly" box unchecked so we may easily import and view your code.

                                That being said, in taking a look at your .txt version of the script, I'm seeing that this code does not demonstrate prints to tell you why this particular condition does not become true.

                                For example, I might add the following prints right before this specific set of conditions:

                                Print("PriceBreakoutRectangularBase(upwardBreakout ,VolumeMultiple).Plot0[0] = " + PriceBreakoutRectangularBase(upwardBreakout,Volume Multiple).Plot0[0]);
                                Print("Market Position: " + Position.MarketPosition);
                                Print("IsFirstTickOfBar: " + IsFirstTickOfBar);

                                Worth noting here:

                                With TickReplay disabled, IsFirstTickOfBar will always be true in historical data.

                                With TickReplay enabled and Calculate set to .OnPriceChange or .OnEachTick, IsFirstTickOfBar will only be true on the first tick of a bar.

                                Below is a link to a forum post with details and links to the help guide.
                                https://ninjatrader.com/support/foru...377#post773377

                                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 DJ888, 04-16-2024, 06:09 PM
                                4 responses
                                12 views
                                0 likes
                                Last Post DJ888
                                by DJ888
                                 
                                Started by terofs, Today, 04:18 PM
                                0 responses
                                9 views
                                0 likes
                                Last Post terofs
                                by terofs
                                 
                                Started by nandhumca, Today, 03:41 PM
                                0 responses
                                6 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
                                9 views
                                0 likes
                                Last Post NinjaTrader_Clayton  
                                Working...
                                X