Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

BarsInProgress-exitorder

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

    BarsInProgress-exitorder

    Hello,

    I thought I´m ready with everything for my script-strategies but there occurs still one problem.

    I run the strategy COBC=true in a 5 RangeChart (=dataseries5). Entries I do at close of 3RangeChart (dataseries 3). Entries work fine and I move and cancel stops with stopOrder as well. But my exitOrders are not filled.

    if (BarsInProgress!=3) return;
    entryconditions() entryOrder=EnterLong (3000, "L1"); works OK

    if(GetCurrentAsk(0) == DonchianChannel(BarsArray[5],21)Upper[1])
    exitOrder1a = ExitLong(1000, "xL1a","L1"); doesnt work, the exitOrder is not filled.

    Also with if(GetCurrentAsk(3) == DonchianChannel(BarsArray[5],21)Upper[1])
    exitOrder1a = ExitLong(1000, "xL1a","L1"); the exitOrder isnt filled.

    stopOrders work and I move or cancel with eg if(GetCurrentAsk() > Position.AvgPrice + (80*TickSize) && stopOrder1a!= null && stopOrder1a.OrderState==OrderState.Accepted)
    stopOrder2a)=ExitLongStop(...)

    Why isn´t the exitOrder filled?

    Thank you for your help.

    Best
    Tony
    Last edited by tonynt; 04-16-2013, 12:24 AM. Reason: new information

    #2
    Tony, I would suggest debugging your script step by step :

    a) is the ExitOrder code submission triggered as you would expect? You could check with adding a print in the respective section to see if the condition hits as you expect

    b) if it's hit and submitted - what would TraceOrders return for the given order? Would it be ignored or expiring for any reason?



    I know debugging can be one of the things one is not looking forward to, but it will help establish a clear ground to work from simple to more and more complex setups without losing track.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Thank you for your reply.

      I do with debugging and output window and background coloring and setting variables and flags to be printed in the output window. I have no clu whats wrong as they show correct values/status.
      An interesting point is that it worked with simulated datafeed on Sunday I finally tested but today in Sim-mode the exitOrders are not filled (the entries are correctly and the stops are managed correctly - I do the entries with certain conditions and a key-reversal-bar 3 Range and the strategy is enabled in my 5rangechart)

      Do you have an idea about the difference between simulated datafeed and now the "live-Sim-mode"? (I have bid and ask as it is shown in the dom). Is there another possibility to "touch" price then with GetCurrentAsk or Bid?

      Or do I have to add maybe if (BarsInProgress==3
      && GetCurrentAsk(3) == DonchianChannel(BarsArray[5],21)Upper[1])
      exitOrder1a = ExitLong(1000, "xL1a","L1");

      (by condition in my understanding it should also work with GetCurrentAsk(0), no?)

      Thanks
      Tony


      Originally posted by NinjaTrader_Bertrand View Post
      Tony, I would suggest debugging your script step by step :

      a) is the ExitOrder code submission triggered as you would expect? You could check with adding a print in the respective section to see if the condition hits as you expect

      b) if it's hit and submitted - what would TraceOrders return for the given order? Would it be ignored or expiring for any reason?



      I know debugging can be one of the things one is not looking forward to, but it will help establish a clear ground to work from simple to more and more complex setups without losing track.
      Last edited by tonynt; 04-16-2013, 04:54 AM. Reason: idea

      Comment


        #4
        Hi Tony, I would not expect a difference here simulated vs simulated live, as the differences of the feeds would just be missing historical data on the internal Simulator feed and of course slightly different price levels as it's completely internal generated. Since you're working on the same instrument, GetCurrentAsk() should be fine. If you're sure the condition triggers, what would the TraceOrders output then show for this specific exit order you have issues with?
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Bertrand, thank you for your supply.

          To answer correctly - can you please help me by showing what output we could expect? I have traceorders=true and the entries and stop changes are shown in the output window - but the exitOrder is not plotted in "live-sim-mode" because its not done. Do I understand you wrong?

          With simulated datafeed the exitorder is in the output window with all informations, as well the cancelling of the corresponding stop as I have coded (I do not work with OCO).

          What message would be in the output window when exitOrder is not filled? Sorry, can you please help me to inform you correctly?

          (The conditions are filled - as we can see if price rises above donchian, and the flags are correctly (eg exitbyconditions=true.....)).

          Thanks
          Tony

          Originally posted by NinjaTrader_Bertrand View Post
          Hi Tony, I would not expect a difference here simulated vs simulated live, as the differences of the feeds would just be missing historical data on the internal Simulator feed and of course slightly different price levels as it's completely internal generated. Since you're working on the same instrument, GetCurrentAsk() should be fine. If you're sure the condition triggers, what would the TraceOrders output then show for this specific exit order you have issues with?
          Last edited by tonynt; 04-16-2013, 05:03 AM.

          Comment


            #6
            Tony, to get more familiar with the TraceOrders feature please check into this tip we have up here - http://www.ninjatrader.com/support/f...ead.php?t=3627

            If your exit order would trigger, you should see a PlaceOrder command for it in the output window. Otherwise if it would be ignored for any reason you would see this noted as well. That info you would need to correlate with your debug prints to understand the event sequence better.
            BertrandNinjaTrader Customer Service

            Comment


              #7
              Hello,

              I have tested all "combinations" of BarsInProgress and everything works as expected. And the exits are filled eg with
              ...
              &&CrossAbove(Stochastics(BarsArray[3],7,14,3).K, Stochastics(BarsArray[3],7,14,3).D,1))
              exitOrder1a = ExitLong(1000, "xL1a","L1");

              BUT NOT with
              if(GetCurrentAsk(3) == DonchianChannel(BarsArray[5],21)Upper[1])
              exitOrder1a = ExitLong(1000, "xL1a","L1"); the exitOrder isnt filled.

              Please what is wrong here in this line for having the exit when current price (3) == Donchian(BarsArray[5]) ?

              Thanks
              Tony

              Originally posted by NinjaTrader_Bertrand View Post
              Tony, to get more familiar with the TraceOrders feature please check into this tip we have up here - http://www.ninjatrader.com/support/f...ead.php?t=3627

              If your exit order would trigger, you should see a PlaceOrder command for it in the output window. Otherwise if it would be ignored for any reason you would see this noted as well. That info you would need to correlate with your debug prints to understand the event sequence better.
              Last edited by tonynt; 04-17-2013, 04:59 PM. Reason: typing error

              Comment


                #8
                Originally posted by tonynt View Post
                Hello,

                I have tested all "combinations" of BarsInProgress and everything works as expected. And the exits are filled eg with
                ...
                &&CrossAbove(Stochastics(BarsArray[3],7,14,3).K, Stochastics(BarsArray[3],7,14,3).D,1))
                exitOrder1a = ExitLong(1000, "xL1a","L1");

                BUT NOT with
                if(GetCurrentAsk(3) == DonchianChannel(BarsArray[5],21)Upper[1])
                exitOrder1a = ExitLong(1000, "xL1a","L1"); the exitOrder isnt filled.

                Please what is wrong here in this line for having the exit when current price (3) == Donchian(BarsArray[5]) ?

                Thanks
                Tony
                Your condition:
                Code:
                if(GetCurrentAsk(3) == DonchianChannel(BarsArray[5],21)Upper[1])
                is unlikely to EVER be correct, because of how computers store floating point numbers, aka doubles.

                Either round the indicator Plot values to TickSize, or else measure the difference, and trigger on a small enough difference.

                We discussed this issue also in these threads:
                ref: http://www.ninjatrader.com/support/f...ad.php?t=51489
                http://www.ninjatrader.com/support/forum/showthread.php?t=3929

                Comment


                  #9
                  koganam,

                  thank you for your reply.

                  This works with testing in simulated datafeed and in backtesting but not with live-data. Therefore I have included in my strategies.

                  Thank you for your hint, but as I´m not a programmer I have no idea about the 2 possibilities you mention.

                  Could you maybe post me how to code? I include you in my prayers! It would take me about 3 weeks to find out how to do, while you would do it in 3 minutes I assume.

                  Thanks
                  Tony



                  Originally posted by koganam View Post
                  Your condition:
                  Code:
                  if(GetCurrentAsk(3) == DonchianChannel(BarsArray[5],21)Upper[1])
                  is unlikely to EVER be correct, because of how computers store floating point numbers, aka doubles.

                  Either round the indicator Plot values to TickSize, or else measure the difference, and trigger on a small enough difference.

                  We discussed this issue also in these threads:
                  ref: http://www.ninjatrader.com/support/f...ad.php?t=51489
                  http://www.ninjatrader.com/support/forum/showthread.php?t=3929

                  Comment


                    #10
                    Originally posted by tonynt View Post
                    koganam,

                    thank you for your reply.

                    This works with testing in simulated datafeed and in backtesting but not with live-data. Therefore I have included in my strategies.

                    Thank you for your hint, but as I´m not a programmer I have no idea about the 2 possibilities you mention.

                    Could you maybe post me how to code? I include you in my prayers! It would take me about 3 weeks to find out how to do, while you would do it in 3 minutes I assume.

                    Thanks
                    Tony
                    Code:
                    if(GetCurrentAsk(3) == Instrument.MasterInstrument.Round2TickSize(DonchianChannel(BarsArray[5],21)Upper[1]))

                    Comment


                      #11
                      koganam,

                      thank you so much!

                      I added to my conditions and looking tomorrow if it works to exit. I will tell you about.

                      Have a great day!

                      Best regards
                      Tony

                      Originally posted by koganam View Post
                      Code:
                      if(GetCurrentAsk(3) == Instrument.MasterInstrument.Round2TickSize(DonchianChannel(BarsArray[5],21)Upper[1]))

                      Comment


                        #12
                        koganam,

                        I had some trades today and I allow to show in the attached screenshot one current trade where you can see the entershort (the black line) and at about 13:26 the touch with the Donchian (red colored). But there is no exit with
                        if(GetCurrentAsk(5) == Instrument.MasterInstrument.Round2TickSize(Donchia nChannel(BarsArray[5],21).Lower[1]))

                        I have no idea what I have done wrong.

                        Thank you in advance for your reply.

                        Best regards
                        Tony
                        Attached Files
                        Last edited by tonynt; 04-19-2013, 07:40 AM. Reason: corrections attachment

                        Comment


                          #13
                          Tony, are you really sure the Ask was touching this line then? Please remember FX spot charts are driven from bid prices as there is not real last. So depending on the spread seen, could be the ask didn't reach your point.
                          BertrandNinjaTrader Customer Service

                          Comment


                            #14
                            Bertrand,

                            thank you! I´m not sure ("I know that I know nothing")

                            With your information do you mean for exitshorts (I assume you refer to my screenshot) to change in the coding simply from Ask to Bid price? And this also for long trades to change exitcondition from Ask to Bid for having an exitLong? I thought exit short with Ask and exitLing with Bid would be more safe(?) Do I understand correctly to do ExitShort and ExitLong both with Bid price?

                            Thank you!
                            Tony



                            Originally posted by NinjaTrader_Bertrand View Post
                            Tony, are you really sure the Ask was touching this line then? Please remember FX spot charts are driven from bid prices as there is not real last. So depending on the spread seen, could be the ask didn't reach your point.

                            Comment


                              #15
                              Yes, if you work with this setup on FX spot charts, I would drive conditions from the bid price unless you're specifically setting up the charts to be based on another series.
                              BertrandNinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by wzgy0920, 04-20-2024, 06:09 PM
                              2 responses
                              26 views
                              0 likes
                              Last Post wzgy0920  
                              Started by wzgy0920, 02-22-2024, 01:11 AM
                              5 responses
                              32 views
                              0 likes
                              Last Post wzgy0920  
                              Started by wzgy0920, Yesterday, 09:53 PM
                              2 responses
                              49 views
                              0 likes
                              Last Post wzgy0920  
                              Started by Kensonprib, 04-28-2021, 10:11 AM
                              5 responses
                              192 views
                              0 likes
                              Last Post Hasadafa  
                              Started by GussJ, 03-04-2020, 03:11 PM
                              11 responses
                              3,235 views
                              0 likes
                              Last Post xiinteractive  
                              Working...
                              X