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

    #31
    thank you. i added that and will see tonight on a sim account the behavior. attached is the script as you mentioned. hope you will be able to help me out in this from the code (only look at the long section. I do not do short trades using this strategy).
    Attached Files

    Comment


      #32
      Hello babouin77,

      Thank you for your reply.

      Please note that we do not offer debugging services in the support department and taking the debugging steps and checking the strategy logic is the responsibility of the developer of the strategy. In this case, you would be responsible for taking these steps and checking if your logic works as you expect.

      Please follow up if you have additional questions after you have debugged the strategy using prints like we have suggested. This would be done so you can check the logic your strategy logic and see why your conditions are not allowing actions to be taken.

      We also would ask that you refrain from making additional posts to the thread until you have thoroughly tested what you can on your end. This helps others reading the thread so it is easier to follow, and also helps our support technicians so they can pick up the thread in another tech's absence.

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

      Comment


        #33
        i tested it... whenever i use on first tick it does not open trades... something is not right from what you suggested... i understand you can not debug but the help you provided is not working so any help is appreciated.

        Comment


          #34
          Hello babouin77,

          IsFirstTickOfBar will always be true unless a script is using Calculate.OnEachTick or Calculate.OnPriceChange and that script is processing historical data with Tick Replay enabled or the script is processing realtime data. When we are processing historical data with Tick Replay or processing realtime data when the script uses Calculate.OnEachTick or Calculate.OnPriceChange, IsFirstTickOfBar will only be true when we are processing the first tick of a bar.

          Here is a demonstration showing how you can test IsFirstTickOfBar and understand how it is used. I recommend setting up small test scripts like this to better understand the properties you want to use.

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

          Your script is also not following our suggestion for a useful debugging print. You need to print the values used to evaluate your conditions above the condition, not within that condition. Printing out values inside the condition only tells you it became true. Printing out the values used to evaluate that condition outside of that condition will tell you what each value is, before the condition is checked, so you can understand why it is not becoming true.

          In order to understand why an order is not being submitted, or in general why any strategy has not taken an expected action, you need to use prints to:

          1. Confirm the order submission method is reached (Place a print next to the order method in the came code block)
          2. If the order method is not reached, you need to debug the condition controlling it (Place a print above the condition that prints the values used in that condition.)
          3. If the order method is reached, but no order is submitted, you will need to test again with TraceOrders enabled and check the order feedback in the NinjaScript Output window to see why the order was ignored.

          Please let us know if this process is not clear.


          JimNinjaTrader Customer Service

          Comment


            #35
            thanks a lot for your helpful video and explanation.

            my script is using Calculate.OnEachTick and I am doing it in real time but it is not opening any trades with is first tick of bar... if I change to on bar close and remove is first tick it will open trades normally.

            I changed my conditions

            protected override void OnBarUpdate()
            {
            // Condition set 1 - Upward Price Breakout
            Print("PriceBreakoutRectangularBase(upwardBreakout ,VolumeMultiple).Plot0[0] = " + PriceBreakoutRectangularBase(upwardBreakout,Volume Multiple).Plot0[0]);

            Print("Market Position: " + Position.MarketPosition);
            Print("IsFirstTickOfBar: " + IsFirstTickOfBar);


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


            // Position.MarketPosition == MarketPosition.Flat && IsFirstTickOfBar )

            {


            EnterLong(Convert.ToInt32(NumberOfContract), "Long");
            justEntered = true;
            }

            i will test and let you know and I will make sure to choose on each tick and see if it will open any trades.
            wil llet u know.

            Comment


              #36
              and even when it does not open any trades... if I turn off the strategy then on again i can see historical trades but in real time they never opened. in the screen shot below i have one chart on each tick and one chart on bar close 2 separate scripts and the on bar close opened a trade and on each tick did not open a trade. Click image for larger version

Name:	firsttick.png
Views:	85
Size:	54.4 KB
ID:	1121589

              Comment


                #37
                Hello babouin77,

                Thank you for your reply.

                Originally posted by babouin77 View Post
                and even when it does not open any trades... if I turn off the strategy then on again i can see historical trades but in real time they never opened. in the screen shot below i have one chart on each tick and one chart on bar close 2 separate scripts and the on bar close opened a trade and on each tick did not open a trade. Click image for larger version

Name:	firsttick.png
Views:	85
Size:	54.4 KB
ID:	1121589
                When we enable a strategy, it processes the data on the chart as historical data. The conditions have become true in a historical context, but this may not be the case in a realtime context. Remember, on historical data a strategy only knows 4 data points - the OHLC of a bar - and can only process OnBarClose, so if your strategy is running OnEachTick or OnPriceChange in real time, the results would be expected to be different.

                In order to determine why a strategy has not taken expected actions, you will need to use debugging prints to understand if the conditions did not allow the order submission to be reached or if the conditions became true and the order was ignored. Please see our reply from post #34.

                If you are finding it is too difficult for you to debug your logic, you could consider hiring a consultant to build a strategy the way you would like. Please let me know if you'd like a representative of our Vendor Support team to provide you with further information regarding NinjaScript Consultants.

                Thanks in advance; I look forward to assisting you further.
                Kate W.NinjaTrader Customer Service

                Comment


                  #38
                  whatever NinjaTrader_Jim provided helped a lot. thank you

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by RideMe, 04-07-2024, 04:54 PM
                  6 responses
                  31 views
                  0 likes
                  Last Post RideMe
                  by RideMe
                   
                  Started by tkaboris, Today, 05:13 PM
                  0 responses
                  2 views
                  0 likes
                  Last Post tkaboris  
                  Started by GussJ, 03-04-2020, 03:11 PM
                  16 responses
                  3,281 views
                  0 likes
                  Last Post Leafcutter  
                  Started by WHICKED, Today, 12:45 PM
                  2 responses
                  19 views
                  0 likes
                  Last Post WHICKED
                  by WHICKED
                   
                  Started by Tim-c, Today, 02:10 PM
                  1 response
                  10 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Working...
                  X