Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Bool variable

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

    Bool variable

    Hello everyone!
    I'm using the Strategy Builder for a trade based on crossover moving averages.
    I want to use a bool variable to stop the strategy when I have an amount of money (either profit or loss).
    I already set the bool variable at the beginning of the strategy (in the variables section) with the default value "true", then in the conditions section I am using a single "Tab" with the conditions:
    "Realized PnL = MaxProfit"
    "Unrealized PnL = MaxLoss"
    And finally, in the same Tab, once the amount of profit or loss is reached, I reset the variable bool to "false" to stop the strategy but none of that works, the strategy continues to operate until the end of the day.
    Please can you help me? Is there a procedure to set bool variables?
    Regards!

    #2
    For all things that you want, you can´t do it without open code source. You have to unlock code and use Account item functions and CloseStrategy function.
    Sorry for me english.

    Comment


      #3
      Hello wcautela,

      Welcome to the NinjaTrader forums!

      Below is a link to an example named DailyLossLimitBuilderExample_NT8 you may find very helpful.
      https://ninjatrader.com/support/foru...ples#post93881

      It is possible to set bool values. Click add in the 'Do the following' section where actions are added. Expand the Misc section. At the bottom you find all variables and custom series that have been setup listed here where you can set the value for each variable.

      In the conditions, are you comparing the bool to be true or false?

      Is the condition that sets the value to false, triggering at an unexpected time?

      I recommend using Print to see when conditions are evaluating as true or false and why. See the video 'Debugging using prints with the Strategy Builder' linked in the forum post linked below.
      https://ninjatrader.com/support/foru...121#post791121


      Chelsea B.NinjaTrader Customer Service

      Comment


        #4
        Hello Chelsea,
        Ok, I already uploaded the 3 scripts that you sent me.
        I use the Tools/Import/NinjaScript Add-On function, but how can I see the code of those strategies with the Builder?
        I can only activate the strategy but I can't see its code?
        Regards!

        Comment


          #5
          Hello wcautela,

          Open the Strategy Builder -> select DailyLossLimitBuilderExample from the drop-down on the welcome page. Click Next. Click View Code.

          Below is a link to a forum post with helpful information about getting started with NinjaScript. Please watch the Automate Your Trading with NinjaTrader's Strategy Builder to learn more about how to use the Strategy Builder, and the NinjaScript Editor 401 video to learn more about viewing the code in the NinjaScript Editor.
          Chelsea B.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by stafe, Today, 12:34 PM
          2 responses
          20 views
          0 likes
          Last Post stafe
          by stafe
           
          Started by asmmbillah, Today, 11:18 AM
          1 response
          17 views
          0 likes
          Last Post NinjaTrader_ChrisL  
          Started by nickse2003, Today, 09:56 AM
          1 response
          27 views
          0 likes
          Last Post NinjaTrader_ChristopherJ  
          Started by ATMtrader0001, Today, 10:08 AM
          5 responses
          38 views
          0 likes
          Last Post ATMtrader0001  
          Started by WHICKED, Today, 09:47 AM
          1 response
          26 views
          0 likes
          Last Post NinjaTrader_Spencer  
          Working...
          X