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

I need help creating this specific tick counter

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

    I need help creating this specific tick counter

    Click image for larger version

Name:	Open trade bot.png
Views:	271
Size:	151.7 KB
ID:	1174635 (x axis- points) (y axis- profit) (instrument: /ES)

    -When the market reaches (1) an ATMShort & ATMLong will be placed at (2) essentially creating a LongStraddle.
    -If either side is entered, each of their respective stops will be placed at (1) resulting in a 1point loss and it will keep looping until we reach our profit or max risk tolerance.


    How can I structure my script in a way that (2) will be activated after, lets say: 10 theoretical losses have occurred so that way I can save myself from those initial 10 losses?

    I assume that I use an indicator like : "Constant Lines", or a drawing like: "Horizontal line" to mark the location of (1) and when the market reaches this point, it begins counting how many times it goes 1point in either direction then returns back to (1) to count a "loss".

    I am new to programming but I learn quick any guidance would greatly help.




    #2
    Hello Don22Trader1,

    Thank you for your post.

    Are you intending to use this with futures, or were you hoping to use this with Options instruments? Just so you know, there is no NinjaScript support for Options, if you were thinking of using something like this on an Options instrument.

    You would need to use the unmanaged approach in order to set up a OCO pair for entry. This would be require somewhat advanced programming skill with NinjaScript.

    This post from our forums demonstrates setting up an OCO type entry with the unmanaged approach:



    I would suggest starting small, familiarizing yourself with NinjaScript first, and then tackling something more complex like this once you're comfortable with the Managed approach. This forum post contains a number of resources to help you get started learning NinjaScript.

    Hello i m trying to write automatic trader. How can i write in the C# langue :''in 8 range bar when delta imbalance occur (range bar finishes green ,delta is red) ,buy when the next bar starts?


    Can you clarify, do you only want to start entering trades after 10 1 tick moves away from the price marked at 1 and directly back to it again? I'm a little confused by this last section of your post:

    How can I structure my script in a way that (2) will be activated after, lets say: 10 theoretical losses have occurred so that way I can save myself from those initial 10 losses?

    I assume that I use an indicator like : "Constant Lines", or a drawing like: "Horizontal line" to mark the location of (1) and when the market reaches this point, it begins counting how many times it goes 1point in either direction then returns back to (1) to count a "loss".
    Any further detail you can provide here would be very helpful.

    Thanks in advance; I look forward to assisting you further.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      This will be used for futures trading.

      I understand the long straddle is used for options.
      For futures trading I cannot buy and sell at the same price which is why I have two entries placed 1 point (4 ticks) away on either side of (1);
      the left side is a short entry (sell stop), the right side is a long entry (buy stop), with their respective stop loss placed at (1) which is a 1point (4 tick) loss.

      The bot needs to count the theoretical amount of times the market moved from (1), then touched my theoretical entry on either side placed at (2), then came back to touch the theoretical stop loss placed at (1). After 10 losses the bot will activate the real entries that will be placed at (2) and will keep looping until max risk is reached or profit is taken.

      I am still very new to ninjascript so thank you for the links to the other posts I will research further.
      If you have any idea how to help on this I would greatly appreciate it.

      Comment


        #4
        Hello Don22Trader1,

        Thank you for your reply.

        How are you wanting to determine where point (1) is? Are you using, say, the market open price? Determining this from an indicator or other calculation? Does the price of (1) stay fixed or move with the market?

        If the price continues to move beyond the (2) point in either direction and does not return to (1), what would the desired behavior be?

        If the price moves beyond the (2) point and later returns to the (1) point, does this count, or are we only wanting to count moves where it only goes up/down by a point and returns immediately?

        Thanks in advance; I look forward to assisting you further.
        Kate W.NinjaTrader Customer Service

        Comment


          #5
          Click image for larger version

Name:	IMG-2187.jpg
Views:	350
Size:	387.3 KB
ID:	1174774
          The location of (1) is simply calculated by a measured 2 leg movement shown here. |(A-B)-C|=D.
          I mark this location with a drawing (Horizontal Line) and this location will be fixed.
          I use no other indicator besides the price action itself.

          When the market reaches (1) It might hang around there for sometime until it chooses a direction, so we will be incurring a loss for every time it crosses like I explained in my last post so I need it to read a certain amount of theoretical loss before I go in with real orders.

          The orders placed at (2) will be simple ATM orders with a profit of 30pts (120 ticks) an a stop loss of 1point (4ticks).
          Lets say the market chooses direction and we only reach 29 points and then return to (1). it will count it as 1 loss and will keep looping until 30 points in either direction is reached.

          our max risk would be 30 losses- basically a 30 point loss. and so I will exit for a total loss of 30pts and try again another day.

          I was researching that you can "tag" a drawing, not entirely sure what it means, but I was thinking of structuring it this way:
          - We will "tag" our horizontal line as a benchmark.
          - I manually place the 'beginning' of the horizontal line, in line with point (A) and it will extend to infinity so that way it will keep counting from this specific price I marked.
          -When we finally reach our profit or exit after our max risk is reached, the Horizontal Line will no longer extend to infinity, instead it will be cut off at the timestamp we exit the play so that way it will stop counting.
          -A new horizontal drawing will begin a new count.


          I don't know if this structure is the right way of think of it, so I hope you understand what I'm trying to achieve.

          Comment


            #6
            Hello Don22Trader1,

            Thank you for your reply.

            This would be theoretically possible, but what you're describing would be extremely complex to program and I would not recommend tackling this yourself unless you've got considerable skill in programming NinjaScript and C# manually. To further clarify, I'm still confused if you would immediately be submitting the OCO orders or simply counting the number of times it goes up less than 120 ticks and returns to (1) before actually placing any orders. Further, if the price just goes up or down in one direction and never comes back down to 1 the strategy may not take any orders at all if you're counting that first..

            First, in order for NinjaTrader to be able to detect a manually drawn line from a strategy, you would have to loop through the drawing objects collection, find that specific line, and get the information from its anchors to determine the price of (1). I've attached an example script that finds a user drawn line.

            From there, you'd need to check when the price hits that initially, perhaps by flipping a bool to true when the price is initially hit, then checking if that bool is true and the price is again the same on the subsequent price updates and is not at least the price of (1) + 120 ticks - if that happens, flip the bool back to false and do not increment a counter, if that does not occur and the bool is true and the price has returned to the same price as (1), increment a counter variable. If that counter reaches 10, then it sounds like you'd actually want to start submitting orders. At that point you'd want to refer to the OCO linked entry order example above, which would require you to use the unmanaged approach for submitting orders.

            With the Unmanaged approach, NinjaTrader has many safety mechanisms that were present in the Managed approach turned off. There are critical issues that must be considered and your strategy must be programmed in a manner that addresses these concerns. Failure to do so may result in a serious adverse affect on your trading account. You can read about those here:



            Now, if you're wanting to use ATM Strategies with this, there's further considerations for using those from within a NinjaScript Strategy:



            Here is a link to our help guide on the methods used for submitting these from a NinjaScript Strategy:



            Overall, I would highly recommend enlisting the help of a NinjaScript programmer or consultant to assist, as we cannot create, debug, or modify a script on your behalf. You can certainly contact one of our professional NinjaScript Consultants or Educators who would be eager to create or modify this script at your request or assist you with your script. Please let me know if you would like a list of professional NinjaScript Consultants or Educators who would be happy to create or modify any script at your request or assist you in learning NinjaScript.

            Please let us know if we may be of further assistance to you.
            Attached Files
            Kate W.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by guillembm, Yesterday, 11:25 AM
            2 responses
            9 views
            0 likes
            Last Post guillembm  
            Started by junkone, 04-21-2024, 07:17 AM
            9 responses
            68 views
            0 likes
            Last Post jeronymite  
            Started by trilliantrader, 04-18-2024, 08:16 AM
            4 responses
            20 views
            0 likes
            Last Post trilliantrader  
            Started by mgco4you, Yesterday, 09:46 PM
            1 response
            11 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by wzgy0920, Yesterday, 09:53 PM
            0 responses
            10 views
            0 likes
            Last Post wzgy0920  
            Working...
            X