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

TP and SL decided from a variable not working

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

    TP and SL decided from a variable not working

    Hello, I'm trying to automate a strategy that has a stop loss dependent on the ATR at the moment of the start of the trade multiplied by a factor of three.

    I created a variable called ATRX3 and when the condition of the trade happen I set the variable to the ATR*3

    I then add a take profit and stop loss in currency equal to the variable...

    the variable is set as a DOUBLE with a default value of 1

    problem is that when the trade start it immediately closes

    can you help me figure it out?

    #2
    Hello gabcon1414,

    Welcome to the NinjaTrader forums!

    Below is a link to an example strategy that uses the ATR you may find helpful.
    Hello, the indicator I use plots the ATR with a period of 10 and multiplier of 4 as a dotted line on the chart (image attached). Using this, if the price reaches within 2 ticks to this level, it gives a signal for a breakout. My question is, how would I be able to create a strategy that trails an entry 2 ticks above this level


    Please enable TraceOrders and print the price that you are using for the stop price and limit price as well as the current bid price.


    Are you seeing that the stop loss stop price is below the bid and the target limit price is above the bid?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      I'm sorry but I am using the strategy builder and I'm not totally sure on how to do what you asked me..

      I was able to print the ATR variable and the variable does work as intended, it is assuming the values I am telling it to.

      It is also working when I use it to determine my enter point. But as I am trying to use it to get the PL or TP it just doesn't use them and goes on until it automatically exit on session close. It should take losses and profits way more fast...

      I created an example here of how I am doing it. IT'S GOING FROM THE ENTRY SIGNAL (LONG) AND TAKING A VALUE IN DOLLARS (THE CURRENCY) OF THE ATR*25.. IS IT WRONG? sorry my keyboard went caps all alone ahahClick image for larger version

Name:	image.png
Views:	93
Size:	55.7 KB
ID:	1259212

      Comment


        #4
        Hello gabcon1414,

        Unfortunately, you cannot use dynamic prices for SetStopLoss() and SetProfitTarget() in the Strategy Builder.

        Instead you will need to use Exit orders in the actions section of the conditions and actions.

        This forum thread discusses this.
        When using Strategy Builder, if I want to set the target at a point that price action seems to dictate, I need to be able enter that. The options seem to be there but the strategy will not run any time I use a formula. For example: Let's say I want to set the price to exit the strategy at a distance dictated by the previous


        Try modeling your script after the ATRTrailingStrategyBuilder​ example. Calculate the stop price using offsets, then supply this as the stop price to the 'Exit long position by a stop order'.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          I will try, thank you! Is the example you quoted in the link you provided? Also... Should I need more help can I still type here?

          Also..using the exit long by a stop order, I can only use price points as a reference?
          Thanks!

          Comment


            #6
            Hello gabcon1414,

            Yes, the example is in the link in post # 2.

            We are happy to answer any further questions you may have.

            You can use any number for stop price, (such as a calculated value or an indicator plot value) however that number must be a valid price for the stop price.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Ok! I have one last question which may seem easier...

              Could you tell me how to setup the enter long position in such a way that it enters the trade it the price at the entry goes UP twelve points?

              Click image for larger version

Name:	image.png
Views:	82
Size:	17.8 KB
ID:	1259236

              Comment


                #8
                Hello gabcon1414,

                It sounds like after a condition is true, you want to place a buy stop order with the stop price 12 ticks above the current market price. (Buy limit would be below the ask, buy stop would be above the ask).

                For this order to stay alive, you would need to save the stop price to a variable, and then re-submit the order on each new bar with that saved stop price. The Offset would be set to Ticks to add 12 ticks to the Close price.

                This example linked below demonstrates keeping an order alive by saving the stop price to a variable and then re-submitting the order on each new bar.
                Chelsea B.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by lightsun47, Today, 03:51 PM
                0 responses
                4 views
                0 likes
                Last Post lightsun47  
                Started by 00nevest, Today, 02:27 PM
                1 response
                8 views
                0 likes
                Last Post 00nevest  
                Started by futtrader, 04-21-2024, 01:50 AM
                4 responses
                44 views
                0 likes
                Last Post futtrader  
                Started by Option Whisperer, Today, 09:55 AM
                1 response
                13 views
                0 likes
                Last Post bltdavid  
                Started by port119, Today, 02:43 PM
                0 responses
                9 views
                0 likes
                Last Post port119
                by port119
                 
                Working...
                X