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.
      Hello, I've updated the DailyLossLimit and DailyLosLimitMultiTrade examples that were posted on the forum for NinjaTrader 7 for NinjaTrader 8. These are often requested and I felt they are good examples to have for NT8. DailyLossLimitExample_NT7 - http://ninjatrader.com/support/forum...241#post451241 (http://ninjatrader


      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.



      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 rbeckmann05, Yesterday, 06:48 PM
          1 response
          12 views
          0 likes
          Last Post bltdavid  
          Started by llanqui, Today, 03:53 AM
          0 responses
          6 views
          0 likes
          Last Post llanqui
          by llanqui
           
          Started by burtoninlondon, Today, 12:38 AM
          0 responses
          10 views
          0 likes
          Last Post burtoninlondon  
          Started by AaronKoRn, Yesterday, 09:49 PM
          0 responses
          15 views
          0 likes
          Last Post AaronKoRn  
          Started by carnitron, Yesterday, 08:42 PM
          0 responses
          11 views
          0 likes
          Last Post carnitron  
          Working...
          X