Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Removing auto stop and Re-entry

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

    Removing auto stop and Re-entry

    How can I stop my script from closing my trades, and opening a new one. Instead I would like it to wait to either hit my stop or TP, or to be manually closed.

    #2
    Hello Gerardc1,

    Thank you for your post.

    You would need to code your strategy logic to prevent further trades until your stop or target has been hit.

    You can check the MarketPosition of your strategy. For example,

    Code:
    if (<conditions for long entry> && Position.MarketPosition == MarketPosition.Flat)
    {
    EnterLong(1, "long");
    SetStopLoss(CalculationMode. ...);
    SetProfitTarget(CalculationMode ...);
    }​


    Please let us know if you have any further questions.

    Comment


      #3
      I have been trying to complie my custom script, but I keep getting two error messages. I will share a screenshot. Please help.

      Comment


        #4
        Hello,

        I am not seeing any screenshot in your reply. Please post the screenshot of the compile errors you are getting along with the lines of code you are getting the errors on.

        Comment


          #5
          Click image for larger version

Name:	Screenshot (2).png
Views:	45
Size:	134.9 KB
ID:	1306980​Please let me know if you can see the Screenshot

          Comment


            #6
            Hello,

            Thank you for your post.

            Was this strategy created or edited by an AI tool?

            Remove lines 31 and 32 from the using statements. As the compile error implies, 'Strategy' and 'StrategyAnalyzer' do not exist in the NinjaTrader.NinjaScript namespace.

            In the future, use the NinjaScript Wizard to begin creating your scripts. It will automatically create the correct and necessary skeleton code for your script

            Comment


              #7
              Thanks for your response. it was created by AI so I will take that into consideration, but when I remove the script it's not showing up in the stategy on my charts or in StrategyAnalyzer

              Comment


                #8
                When you remove the script from where? From the Editor? If you remove the script from the NinjaScript Editor that would be expected since you removed the script.

                My previous post only instructed you remove lines 31 and 32 from the script, not remove the entire script.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by CarlTrading, 03-31-2026, 09:41 PM
                1 response
                43 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by CarlTrading, 04-01-2026, 02:41 AM
                0 responses
                21 views
                0 likes
                Last Post CarlTrading  
                Started by CaptainJack, 03-31-2026, 11:44 PM
                0 responses
                30 views
                1 like
                Last Post CaptainJack  
                Started by CarlTrading, 03-30-2026, 11:51 AM
                0 responses
                50 views
                0 likes
                Last Post CarlTrading  
                Started by CarlTrading, 03-30-2026, 11:48 AM
                0 responses
                40 views
                0 likes
                Last Post CarlTrading  
                Working...
                X