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

How to enter on OPEN exit on CLOSE of current bar using Strategy Builder Wzard?

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

    How to enter on OPEN exit on CLOSE of current bar using Strategy Builder Wzard?

    I'm sure it's obvious once you know how to do it, but I can't figure it out. Using one-minute bars and a condition of (previous bar = Bearish Engulfing candlestick) I want to sell the open of the current bar and exit by buying the close of the current bar.

    #2
    Hi Calvin, thanks for writing in. This will require the use of IsFirstTickOfBar. The first set will be if(IsFirstTickOfBar == true && <entry condition>) and the exit will be

    if(Position.MarketPosition == MarketPosition.Long(or Short)) and the strategy will keep track of the current bar by using a variable. I have an example of this here:

    https://ninjatrader.com/support/foru...ce#post1190417

    To check the market position, select "Current Market Position" on the left side, and then "MarketPosition>Long" on the right side. IsFirstTickOfBar can also be found in the Misc folder.

    Kind regards,
    -ChrisL
    Last edited by NinjaTrader_ChrisL; 07-18-2022, 09:10 AM.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      I was only able to follow some of what you said. Here is what I was able to put together:

      SET !
      IfFirstTickOfBar = True
      CandleStickPattern(ChartPattern BearishEngulfing, 4)[0] = 1
      Do the following
      EnterShort(DefaultQuantity, "").

      SET 2
      BarsSinceEntryExecution(0, "", 0) = 0
      Do the following
      ExitShort(DefaultQuantity. "")

      It seems to do what I want. Would you please take a look at it and let me know if there's anything else I need to do?
      Many thanks for your help. Calvin

      Comment


        #4
        Hi Calvin, I sent you an example that demonstrates how to detect when a bar has changed. The exit should be when the ActiveBar changes AND MarketPosition == Long.
        Chris L.NinjaTrader Customer Service

        Comment


          #5
          I am not sure how to create a new thread. But here is my question. Can you create a strategy that allows you to Enter a trade on the close of one bar and Exit on the next bar close?

          Comment


            #6
            Hi, thanks for posting, The builder is able to read the first tick of the bar using IsFirstTickOfBar, so you will need to run the script with Calculate = OnEackTick to enter the market at the start of the bar. I have a related example here for you to reference:

            Hi, I'm currently working on a strategy that is utilizing OnTickChange data using the linked method. I am using a Tick Chart. The strategy uses onTickChange to make intrabar entry, and does so fine with the Set1 and Set2, but if/when profit target is hit, it will submit another order after the profit target if the


            Unfortunately, I do not have a ready-made example of what you are asking about specifically.
            Chris L.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by terofs, Today, 04:18 PM
            0 responses
            3 views
            0 likes
            Last Post terofs
            by terofs
             
            Started by nandhumca, Today, 03:41 PM
            0 responses
            4 views
            0 likes
            Last Post nandhumca  
            Started by The_Sec, Today, 03:37 PM
            0 responses
            3 views
            0 likes
            Last Post The_Sec
            by The_Sec
             
            Started by GwFutures1988, Today, 02:48 PM
            1 response
            5 views
            0 likes
            Last Post NinjaTrader_Clayton  
            Started by ScottWalsh, 04-16-2024, 04:29 PM
            6 responses
            33 views
            0 likes
            Last Post ScottWalsh  
            Working...
            X