Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Please teach me how to program about the following two things

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

    Please teach me how to program about the following two things


    Hi, I am a newbie ninja trader.

    I am posting this because I wanted to ask how to program the following two things.

    1. buy at today's close and sell at tomorrow's close

    2. buy at today's close and sell at a higher close than the value you bought during the next 5 days. If not, sell at the closing price of the 5th day.​

    #2
    Hello silver211,

    Thanks for your post.

    Something you could consider is creating a time comparison condition to check if the Time is the end time of the session, check if you are in a Flat market position (Posiition.MarketPosition == MarketPosition.Flat), and then submit your order by calling your Entry order method, such as EnterLongLimit()/EnterShortLimit(), to submit an order to the Close price of that candle.

    You could then check if the Time is a certain time, check if you are in a Long or Short Market position, and call your Exit order to exit the position once the Time reaches the specified time again on the next day.

    A Day comparison could also be added to your conditions to see if the current Day is a specific day of the week.

    A double variable could be created and you could save the Close price to the variable when you submit your Entry order. You could then compare if the current Close price is greater than that variable when the Time is a specific time.

    Ultimately, it would be up to you to come up with the specific logic to accomplish the specific strategy you want to create.

    See the help guide documentation below for more information.

    Creating Time Comparisons: https://ninjatrader.com/support/help..._builder.htm#H owToCreateTimeComparisons
    Creating Variables: https://ninjatrader.com/support/help...standingTheInp utsAndVariablesScreen
    Creating Market Position Comparisons: https://ninjatrader.com/support/help..._builder.htm#H owToCreateMarketPositionComparisons
    How to Use User-Defined Inputs and Variables: https://ninjatrader.com/support/help..._builder.htm#H owToUseUserDefinedInputsAndVariables
    Entering a market position: https://ninjatrader.com/support/help...MarketPosition
    Exiting a market position: https://ninjatrader.com/support/help...MarketPosition

    NinjaTrader utilizes the C# programming language for developing indicators and strategies.

    The best way to begin learning NinjaScript is to use the Strategy Builder. With the Strategy Builder, you can set up conditions and variables and then see the generated code in the NinjaScript Editor by clicking the View Code button.

    Here is a link to our publicly available training videos for you to view at your own convenience.

    Automate your Trading with NinjaTrader's Strategy Builder: https://www.youtube.com/watch?v=VxU4...We0Nf&index=11

    NinjaScript Editor 401 - https://www.youtube.com/watch?v=H7aDpWoWUQs&list=PL3-s3qsUnfLSC7zCAc5ZmVnauWXkWe0Nf&index=14

    I am also linking you to the Educational Resources section of the Help Guide to help you get started with NinjaScript:
    https://ninjatrader.com/support/help..._resources.htm

    If you are new to C#, to get a basic foundation for the concepts and syntax used in NinjaScript I would recommend this section of articles in our help guide first:
    https://ninjatrader.com/support/help...g_concepts.htm

    And the MSDN (Microsft Developers Network) C# Language Reference.
    https://ninjatrader.com/support/help...erence_wip.htm


    Please let us know if we may further assist.​
    Last edited by NinjaTrader_BrandonH; 03-08-2023, 09:23 AM.
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      Dear customer survice,

      Thank you for reply..

      I am currently using strategy builder.

      If i buy at today's closing price and sell at tomorrow's closing price

      Is it correct to execute the "Entrylong" instruction at close(1) and the "Exitlong" instruction at close(0)?

      close(1) is the previous day's high, right?​

      Comment


        #4
        Hello silver211,

        Thanks for your note.

        Close[1] will refer to the previous bar's close price. Close[0] will refer to the current bar's close price. If you are using 1-Minute bars, Close[1] would refer to the previous minute bar's close price and Close[0] would refer to the current bar's close price.

        You could use the Prior Day OHLC indicator (Indicators folder > Prior Day OHLC > 'Value plot' parameter > 'Prior High') to get the prior day's High price in a strategy condition.

        Note that EnterLong() will submit a market order to the current market price.

        I suggest watching the Strategy Builder 301 video linked in post # 2 and working through the tutorials on the Educational Resources help guide page linked in post # 2 below to gain a good understanding of working with the Strategy Builder before trying to create your strategy.

        Please let me know if I may assist further.

        Brandon H.NinjaTrader Customer Service

        Comment


          #5
          Dear, customer service

          I would like to watch the Strategy Builder 301 video, but the link is broken and I cannot see it. The video seems to be private.

          Could you please reiterate the correct link?

          Comment


            #6
            Hello silver211,

            Thanks for your note.

            We have a new and updated training video called 'Automate your Trading with NinjaTrader's Strategy Builder'. A link to this training video could be found below. I have also modified the link in my previous post to reflect this.

            NinjaTrader's Strategy Builder empowers traders of all levels with point-and-click automated trading strategy development. Create your own advanced automated...


            Please let me know if I may assist further.
            Brandon H.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by leojimenezp, Today, 08:40 AM
            3 responses
            9 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by ZeroKuhl, Today, 10:22 AM
            1 response
            3 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by mtamaku, Yesterday, 11:08 AM
            11 responses
            25 views
            0 likes
            Last Post mtamaku
            by mtamaku
             
            Started by gyilaoliver, Today, 03:31 AM
            4 responses
            19 views
            0 likes
            Last Post gyilaoliver  
            Started by vit007, Today, 05:09 AM
            3 responses
            28 views
            0 likes
            Last Post backtester831  
            Working...
            X