Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ghost order

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

    ghost order

    Hello,

    I have in my script in state.configure and in onbarupdate if flat the setstoploss for the trades (and I have no setprofittarget).

    If I want to exit with a setprofittarget and not with setstoploss I have added to my customized buttons to send the setprofittarget with the corresponding signal name. This works ok.

    But I see now that with a new entry there is setstoploss and also setprofittarget. Why is there also the setprofittarget when I dont have it defined in the code. Is it stored somewhere, how do I delete this so that with every new entry there is only the setstoploss.

    Thank you!
    Tony

    #2
    Hello Sir Please Can you show me the code I can Help you
    thanks

    Comment


      #3
      Hello,
      thank you for your reply. There is no code about the SetProfittarget after it is submitted. And there is no Setprofittarget in state.configure. It is "created" during a trade by condtions and then sent via button with "Setprofittarget(....)". The strange behavior is that with the next entry there is a ProfitTarget for this new position, which should not be. Only when refreshing the script with F5 it works again for one time, next entry the Setprofittarget is there with the entry again, without submitting it by conditions.
      Thanks

      Comment


        #4
        Hello tonynt,

        Thank you for your post.

        To confirm, there is code in your script to submit a profit target, however, you are seeing the profit target being submitted when not expected?

        To understand why the script is behaving as it is, such as placing orders or not placing orders (or drawing objects or other actions) when expected, it is necessary to add prints to the script that print the values used for the logic of the script to understand how the script is evaluating.

        In the strategy add prints (outside of any conditions) that print the values of every variable used in every condition that places an order along with the time of that bar.

        This will print to the output window. Run o backtest the script and when the output from the output window appears save this by right-clicking the output window and selecting Save As... -> give the output file a name and save -> then attach the output text file to your reply.

        Output from prints will appear in the NinjaScript Output window.
        NT8: New -> NinjaScript Output

        The prints should include the time of the bar and should print all values from all variables and all hard coded values in all conditions that must evaluate as true for this action to be triggered. It is very helpful to include labels and operators in the print to understand what is being compared in the condition sets.

        Below I am providing a link to videos that demonstrate adding prints to a script to get further information about the behavior of the script.
        NT8 —


        If you are using the Strategy Builder in NinjaTrader 8, you can also build prints in the Actions window under Misc -> Print.
        NT8 Strategy Builder —


        It is also helpful to set TraceOrders to true in State.Configure as well as print the order object in OnOrderUpdate().
        TraceOrders will output to the NinjaScript Output window a message when orders are being submitted, ignored, cancelled, or rejected.
        Printing the order object in OnOrderUpdate() will allow you to track the progression of the order from submitted, to working, to filled, cancelled, or rejected.
        These tools will let you know what happens to the order.
        TraceOrders - https://ninjatrader.com/support/help...raceorders.htm
        OnOrderUpdate() - https://ninjatrader.com/support/help...rderupdate.htm

        I'm also including a link to a forum post with further suggestions on debugging a script.


        Save the output from the output window to a text file. Let me know if you need assistance creating a print or enabling TraceOrders.

        I am happy to assist with analyzing the output from prints and TraceOrders.​

        Comment


          #5
          Hello,

          thank you for your reply. Misunderstanding. As I wrote I have no profit target in state.configure nor in onbarupdate. So with the entry I have the stoploss but no profittarget. This is ok!

          Then when in the trade and conditions true I send the profittarget with one of my buttons. This works also ok.


          BUT then with the next "fresh" entry there is also a profit-target immediately with the entry. Why? Shouldn´t be a profit target with the entry as described. (profit target only IF I send it during the trade).

          If I would disable and enable the strat then it would work, but this is not the way to go.

          Thank you!
          Tony

          Comment


            #6
            Hello tonynt,

            The only way to understand the strategy's behavior is to debug using prints and TraceOrders. It could be that the logic for enabling the button is getting carried over to the next entry, however, without the information from debugging this is just a guess.

            Please provide the info from debugging.

            Comment


              #7
              Hello,

              thank you for your reply. Misunderstanding caused by my poor translation. Profit target is not sent by button. Its sent when "condition true" eg MACDcrossover.
              So short story again: entry with conditions and having a stoploss, but no profittarget. This works ok.
              Then when in the trade and there is MACD-crossover the profittarget is sent. Thisworks as well ok.
              Then after the trade being flat and with same conditions there is a new entry and there is the stoploss but now there is also the profittarget with the entry. The profittarget should be sent only when MACDcrossover occurs in the trade.
              Why is there the profittarget with the "next" entry? Does NT store the last profittarget? Has there to be a reset before the new entry for setprofittarget to set it back to "null" so that with new entry there is only the setstoploss, as it works ok with the first entry as described.

              Thank you for your support!
              Tony

              Comment


                #8
                Hello tonynt,

                I understand, however I can't make any suggestions without the output from debugging.

                If you would like assistance with this matter, please provide the output from debugging.

                Otherwise we don't have any information to make any suggestion as to why this is happening.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by argusthome, 03-08-2026, 10:06 AM
                0 responses
                110 views
                0 likes
                Last Post argusthome  
                Started by NabilKhattabi, 03-06-2026, 11:18 AM
                0 responses
                59 views
                0 likes
                Last Post NabilKhattabi  
                Started by Deep42, 03-06-2026, 12:28 AM
                0 responses
                37 views
                0 likes
                Last Post Deep42
                by Deep42
                 
                Started by TheRealMorford, 03-05-2026, 06:15 PM
                0 responses
                41 views
                0 likes
                Last Post TheRealMorford  
                Started by Mindset, 02-28-2026, 06:16 AM
                0 responses
                78 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Working...
                X