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.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    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.

        <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

        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.
            <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by denymachado, Today, 04:39 AM
            0 responses
            2 views
            0 likes
            Last Post denymachado  
            Started by byteman, Yesterday, 11:59 AM
            5 responses
            31 views
            0 likes
            Last Post byteman
            by byteman
             
            Started by Irukandji, 03-21-2025, 04:05 AM
            4 responses
            51 views
            0 likes
            Last Post Irukandji  
            Started by Zadomani, 03-24-2025, 11:39 PM
            2 responses
            40 views
            0 likes
            Last Post Zadomani  
            Started by Darkslide_Tom, 03-23-2025, 11:08 PM
            4 responses
            19 views
            0 likes
            Last Post Darkslide_Tom  
            Working...
            X