Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Stop Trading After Price/Pips Reached

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

    Stop Trading After Price/Pips Reached

    Hey guys,

    I am new and coming from MT4 programming. I would like to convert some of my strategies to NT but I don't see any programming guide other than the pointy clicky interface thing.

    I need to know how to schedule trading to start and stop after a profit target is reached every day.

    It's very simple to do in MT4 so I assumed it was available in the more advanced NT7 but the forums do not yield much in the way of programming information.

    Also how do I manage lots? I don't see anywhere to calculate my lot sizes for the positions I would like to take to achieve my goals.

    Thanks,
    David

    #2
    Hello,

    There are a few key properties and methods that you can use to accomplish both of these objectives.

    To schedule the strategy to begin trading at a certain time, you can create a time filter using C#'s DateTime class. Then, to set the strategy to stop trading after a certain amount of profit or loss have been reached, you can obtain trade performance metrics within NinjaScript. We have two reference samples that will demonstrate both concepts, and provide information on the relevant properties and methods needed. These reference samples will walk you through each step of the process, and you can combine the two concepts together in your script:

    http://www.ninjatrader.com/support/f...ead.php?t=3226

    http://www.ninjatrader.com/support/f...ead.php?t=4084

    To determine your lot sizes, I assume you will want to base this calculation off of your account cash value and the number of pips between your entry price and stop loss. You can identify the stop loss point based on the logic in your code, and you can use the GetAccountValue() method to find your account's cash value:

    http://www.ninjatrader.com/support/h...countvalue.htm

    We have a few resources available for tackling the coding side of NinjaScript, in addition to the Strategy Wizard info that you've seen. The best point to begin will depend upon your current knowledge of C#. Once you can work with C#, you've covered 95% of the learning curve for NinjaScript, as NinjaScript itself is simply a set of libraries for C#. You can find our coding tutorials at the link below, but if you are not yet familiar with coding in C#, the best place to begin will be one of the many free educational resources for C# available online.

    http://www.ninjatrader.com/support/h..._resources.htm
    Dave I.NinjaTrader Product Management

    Comment


      #3
      Dave thank you for the reply. It's my first attempt into the C# language arena. It looks pretty familiar to me. It should be quickly picked up. I did find a few reference samples.

      Is there any kind of documentation like MQL has for something like AccountBalance() AccountEquity()? If I had a roadmap I could pick it up fairly quickly on my own but the only thing I can really find are on these forums and they are hard to search.

      Again thank you for the expedient reply.

      Comment


        #4
        Originally posted by DigitalCrypto View Post
        Dave thank you for the reply. It's my first attempt into the C# language arena. It looks pretty familiar to me. It should be quickly picked up. I did find a few reference samples.

        Is there any kind of documentation like MQL has for something like AccountBalance() AccountEquity()? If I had a roadmap I could pick it up fairly quickly on my own but the only thing I can really find are on these forums and they are hard to search.

        Again thank you for the expedient reply.
        There is a complete NinjaScript language guide and tutorials in the NT Help, which you can reach by hitting the standard Windows Help F1 key from anywhere within NinjaTrader.

        Comment


          #5
          That F1 key is very powerful. Yes I found it last night and I'm on my way. :0)

          It is a pleasure to code on NinjaTrader. So clean. So efficient. I have to unlearn some bad habits.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by arvidvanstaey, Today, 02:19 PM
          4 responses
          11 views
          0 likes
          Last Post arvidvanstaey  
          Started by samish18, 04-17-2024, 08:57 AM
          16 responses
          60 views
          0 likes
          Last Post samish18  
          Started by jordanq2, Today, 03:10 PM
          2 responses
          9 views
          0 likes
          Last Post jordanq2  
          Started by traderqz, Today, 12:06 AM
          10 responses
          18 views
          0 likes
          Last Post traderqz  
          Started by algospoke, 04-17-2024, 06:40 PM
          5 responses
          47 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Working...
          X