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

false long and short signal

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

    false long and short signal

    Hello,

    can somebody help me please.

    what's false at my code.


    The system should act the signals as shown on the attached picture

    I go Long: If the price of the current bar is higher or equal than the high of the last bar.

    I got Short: If the price of the current bar is lower or equal than the low of the last bar.

    The strategy should be long and short as well as on the attached screenshot.

    Thanks,
    Helga
    Attached Files

    #2
    Hello daxtrader,

    Thanks for your post.

    The strategy is using the EnterLong() and EnterShort() methods. These methods will observe if there is already a position in the opposite direction and will issue 1 order to first close the existing position and a 2nd order to then be in the desired direction. For example, the strategy is in a long position the method EnterShort() will issue 1 sell market to close the long position and a 2nd sell market order to then leave the strategy in a short position.

    The strategy is using Calculate on bar Close = true, this means the logic evaluations occur at the close of the bar, any market orders placed would occur on the next bar.

    You may want to add code to your conditions sets to also draw a dot on the chart to show what bar the conditions are evaluating as true to help understand where the conditions are true verses where the actual entries occur.
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Hello Paul,

      can you please show me the code.

      Thanks

      Comment


        #4
        Hello daxtrader,

        Thanks for your reply.

        Here is an example of drawing a blue dot 3 ticks below the low of the current bar:

        DrawDot ("test"+CurrentBar, true, 0, Low[0] - 3 * TickSize, Color.Blue);

        Reference: https://ninjatrader.com/support/help...7/?drawdot.htm
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Hello Paul,

          when I

          Enter Long + 1 tick
          Enter Short - 1 tick

          how should I include this in the strategy.

          // Condition set 1
          if (Open[0] >= MAX(High, lookback)[1])

          {
          EnterLong(DefaultQuantity );
          }
          // Condition set 2
          if (Open[0] <= MIN(Low, lookback)[1])

          {
          EnterShort(DefaultQuantity );
          }


          Best Regards,
          Helga

          Comment


            #6
            Hello daxtrader,

            Thanks for your post.

            You would not be able to specify the price using a market order as the market order is filled at the convenience of the market so you are more likely to have an entry however it will be at a price controlled by the market.

            If you wish to enter at a specific price, then you would need to use a limit order. For example: If you wish to buy with a standard limit order, you would need to place a limit order below the current market price OR if you wish to place a buy order above the market price you would need to use a buystoplimit order.

            Please review: https://ninjatrader.com/support/help...d_approach.htm
            Here is a link to all of the order methods: https://ninjatrader.com/support/help...er_methods.htm

            I would advise testing the methods and recommend that you place your limit order well away from the current price to better see how they work and avoid errors that would disable your strategy because the (order) price is incorrect. Keep in mind that while using CalculateOnBarClose = true, that the current bar is the latest complete bar and does not represent the actual current price on the bar that is forming on the right edge.

            Finally, as previously mentioned the EnterLong and EnterShort automatically close the opposite position by placing a second order. The limit orders do not do this so you would need to think about adding targets and stops or using Exit methods as shown in the links above.
            Paul H.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by funk10101, Today, 12:02 AM
            1 response
            10 views
            0 likes
            Last Post NinjaTrader_LuisH  
            Started by GLFX005, Today, 03:23 AM
            1 response
            6 views
            0 likes
            Last Post NinjaTrader_Erick  
            Started by nandhumca, Yesterday, 03:41 PM
            1 response
            12 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by The_Sec, Yesterday, 03:37 PM
            1 response
            11 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by vecnopus, Today, 06:15 AM
            0 responses
            1 view
            0 likes
            Last Post vecnopus  
            Working...
            X