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:	42
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 NullPointStrategies, Yesterday, 05:17 AM
                0 responses
                62 views
                0 likes
                Last Post NullPointStrategies  
                Started by argusthome, 03-08-2026, 10:06 AM
                0 responses
                134 views
                0 likes
                Last Post argusthome  
                Started by NabilKhattabi, 03-06-2026, 11:18 AM
                0 responses
                75 views
                0 likes
                Last Post NabilKhattabi  
                Started by Deep42, 03-06-2026, 12:28 AM
                0 responses
                45 views
                0 likes
                Last Post Deep42
                by Deep42
                 
                Started by TheRealMorford, 03-05-2026, 06:15 PM
                0 responses
                50 views
                0 likes
                Last Post TheRealMorford  
                Working...
                X