Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Basic strategy by NT wizard

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

    Basic strategy by NT wizard

    Hi,
    I am trying to learn ninja script programming by myself. As a first step I wanted to make a script which enters short if previous bar is green (close higher than open) and enters long if previous bar is red (close lower than open). It seemed very simple to make it in the wizard, but the script does not make what it should make.
    Can you help me?
    Attached Files

    #2
    Hello Borsz,

    Thank you for your post.

    On the historical executions they will occur one bar after the condition is true. This will also occur when using CalculatOnBarClose = True on the real-time data. Please try setting this to CalculateOnBarClose = False and advise if the real-time trades (not historical or backtest) are correct.

    Comment


      #3
      Hi Patrick,

      Thanks for you quick reply.
      I modified to CalculateOnBarClose = False and ran it real time, but there is still problem existing: after reaching SL/TP inside a bar, it immeadiately enters again in the same bar. While, I want only 1 entry per candle: short entry at open of current candle if prev. candle was long; long entry at open of current candle if prev. candle was short.
      How can I manage it in the wizard?

      Comment


        #4
        Hello Borsz,

        Thank you for your response.

        You can use the BarsSinceExit to wait one bar before the next entry: http://www.ninjatrader.com/support/h...ssinceexit.htm

        Comment


          #5
          Hi Patrick,

          You mean just simply add BarsSinceExit == 1 conditon to the script in the wizard?
          I tried it but now it does not tarde at all.
          Thanks,
          Peter

          Comment


            #6
            Borsz,

            If you added this check to all the conditions then I would expect this to not work.

            Essentially, the BarsSinceExit() requires that there was an initial entry and then exit.

            Since there is no initial entry at the start the strategy, there is no exit to handle this condition.

            You would want to have a separate condition to have the initial entry. Then have the regular conditions for exit, and then the BarsSinceExit() would be working at this point.
            Cal H.NinjaTrader Customer Service

            Comment


              #7
              Yes, it sounds logical and right.
              and how to add an initial eentry?
              Thanks a lot,
              Peter

              Comment


                #8
                Peter,

                The images that I have attached below show how to create a sample Initial Entry and then use that to get a starting basis. The rest shows how to use the BarsSinceExit() with the condition.
                Attached Files
                Cal H.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by traderqz, Today, 12:06 AM
                2 responses
                4 views
                0 likes
                Last Post traderqz  
                Started by RideMe, 04-07-2024, 04:54 PM
                5 responses
                28 views
                0 likes
                Last Post NinjaTrader_BrandonH  
                Started by f.saeidi, Today, 08:13 AM
                1 response
                7 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by DavidHP, Today, 07:56 AM
                1 response
                6 views
                0 likes
                Last Post NinjaTrader_Erick  
                Started by kujista, Today, 06:23 AM
                3 responses
                11 views
                0 likes
                Last Post kujista
                by kujista
                 
                Working...
                X