Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Variable

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

    Variable

    I have been building a strategy in the strategy builder and want to use the ATR indicator to base my profit target and stops on. I have made a variable and tried about a hundred things; I cannot make my variables register. I have looked all over the internet for some clarification. If I make it so if the time series is more than 600 am then set ATR1 to ATR, nothing happens. I've tried a variety of comininations and the variable doesn't register. It will compile fine, the strategy just exits as soon as it enters. Any help would be greatly appreciated. Thanks.

    #2
    Hello zrobfrank,

    Thanks for your notes.

    To clarify, you created a variable named ATR1 and are assigning the ATR indicator value to the ATR1 variable in the Conditions and Actions screen of the Strategy Builder. Is that correct?

    Have you added prints in the script outside of the condition you are assigning a value to ATR1 that prints out the ATR1 variable to a NinjaScript Output window?

    Adding prints would allow you to see what value the ATR1 is being set to. Below is a link to a forum post that demonstrates how to use prints to understand behavior.
    https://ninjatrader.com/support/foru...121#post791121

    Please note that a limitation of the Strategy Builder is that dynamic values cannot be assigned to Set methods in the Stops and Targets screen of the Strategy Builder.

    To use dynamic values for stops and targets, you would need to use Exit methods, such as ExitLongLimit() and ExitLongStopMarket(), in the Conditions and Actions screen to place profit target and stop loss orders.

    Here is a post from my colleague Jim that contains a video demonstrating how you could use ATR for stops in the Strategy Builder: https://forum.ninjatrader.com/forum/...15#post1121015

    You may also find more information about this topic in the forum thread linked above.

    Please let me know if I may assist further.
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      Brandon,

      Your response was prompt and helpful. I'm trying to transition from Tradestation and it's a steep learning curve. Thank you for your help.

      Rob

      Comment


        #4
        Originally posted by NinjaTrader_BrandonH View Post
        Hello zrobfrank,

        Thanks for your notes.

        To clarify, you created a variable named ATR1 and are assigning the ATR indicator value to the ATR1 variable in the Conditions and Actions screen of the Strategy Builder. Is that correct?

        Have you added prints in the script outside of the condition you are assigning a value to ATR1 that prints out the ATR1 variable to a NinjaScript Output window?

        Adding prints would allow you to see what value the ATR1 is being set to. Below is a link to a forum post that demonstrates how to use prints to understand behavior.
        https://ninjatrader.com/support/foru...121#post791121

        Please note that a limitation of the Strategy Builder is that dynamic values cannot be assigned to Set methods in the Stops and Targets screen of the Strategy Builder.

        To use dynamic values for stops and targets, you would need to use Exit methods, such as ExitLongLimit() and ExitLongStopMarket(), in the Conditions and Actions screen to place profit target and stop loss orders.

        Here is a post from my colleague Jim that contains a video demonstrating how you could use ATR for stops in the Strategy Builder: https://forum.ninjatrader.com/forum/...15#post1121015

        You may also find more information about this topic in the forum thread linked above.

        Please let me know if I may assist further.
        Is there a way to have dynamic stops/limits on the entry bar? Profit target/stop losses will offer protection as soon as a position is entered. Is it possible to stipulate conditions that will enact Exit methods as soon as a position is entered, or at least on the same bar? Thank you.

        Comment


          #5
          Hello zrobfrank,

          Thanks for your note.

          Yes, to have a script calculate logic and place trades intrabar you could set the Calculate mode to OnPriceChange or OnEachTick.

          Running the script with Calculate.OnBarClose means that the strategy would only process logic and place trades at the close of each bar.

          By running the strategy with Calculate.OnPriceChange, the strategy will process logic for each change in price. This means that if an order was submitted and the condition to place the Exit orders becomes true on the next change in price, the Exit orders would be placed once the price changes.

          Calculate.OnEachTick would work similarly to OnPriceChange except that logic would process for each incoming tick instead of each price change.

          See this help guide page for more information about Calculate: https://ninjatrader.com/support/help.../calculate.htm

          Please let me know if you have further questions on this.
          Brandon H.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by GLFX005, Today, 03:23 AM
          0 responses
          1 view
          0 likes
          Last Post GLFX005
          by GLFX005
           
          Started by XXtrader, Yesterday, 11:30 PM
          2 responses
          11 views
          0 likes
          Last Post XXtrader  
          Started by Waxavi, Today, 02:10 AM
          0 responses
          6 views
          0 likes
          Last Post Waxavi
          by Waxavi
           
          Started by TradeForge, Today, 02:09 AM
          0 responses
          12 views
          0 likes
          Last Post TradeForge  
          Started by Waxavi, Today, 02:00 AM
          0 responses
          2 views
          0 likes
          Last Post Waxavi
          by Waxavi
           
          Working...
          X