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

Help with Simple Doji Strategy

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

    Help with Simple Doji Strategy

    Hey

    Im having trouble with the development of a simple doji strategy.
    basically i want to go long when i have a doji and the past candlestick is negative and exit when i have a doji and positive last candle

    I have programmed before, but im unfamiliar with C# and i used tds thinkorswim platform to code this previously,which was java based
    ive been through the help modules and im still having trouble
    basically the issue its giving me is that risk parameter is undefined, and Id also like to know if the orders are being submitted, i think some indicators meet the criteria but is missed

    #2
    Hello tecnus,

    Thanks for your post and welcome to the NinjaTrader forums!

    In C# the coding for your conditions are pretty straightforward, for example:

    if (Close[0] == Open[0] && Close[1] < Open[1]) // if the current bars close is equal to the open and if the previous bars close is less than the previous bars open.
    {
    EnterLong();
    }

    You can confirm that you are in a position by checking the MarketPosition, Reference: https://ninjatrader.com/support/help...etposition.htm

    You may also want to review the Managed Orders section of the helpguide which gives you an overview of orders and limits within the managed approach: https://ninjatrader.com/support/help...d_approach.htm


    An alternative you may want to consider is using the NT8 strategy builder which is a great tool for creating strategies without knowing the details of C#/Ninjascript coding syntax. As the strategy builder converts it inputs to actual C# code you can also see how coding is done and perhaps build your knowledge of C#/Ninjascript.

    Here is a link to the strategy builder info from the helpguide (which includes short videos): https://ninjatrader.com/support/help...gy_builder.htm
    Here is a link to a recording of a strategy builder training webinar: https://youtu.be/HCyt90GAs9k?list=PL...ZmVnauWXkWe0Nf
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Hey Paul
      Thanks for the help, i managed to get a basic code up and running but now it doesnt execute any trades, any time its supposed to, it says risk settings undefined, cancels or backs out of any orders and crashes

      also is there any way to make the doji check less stringent, for example right now it wants the exact same number, but id be fine if it was within .5 pips

      Thanks

      Comment


        #4
        Hello tecnus,

        Thanks for your reply.

        Yes, you can add an offset to either side by using TickSize which would be 1/10 pip. For example, if ((Close[0] >= Open[0] && Close[0] - Open[0] <= 5 * TickSize) || (Close[0] <= Open[0] && Open[0] - Close[0] < 5 *TickSize))
        {
        // do something
        }
        Please note I have not tested this and it is presented as one possible way this could be done. You would need to test/debug to ensure it meets your needs.

        Please send your strategy and log and trace files to PlatformSupport[at]NinjaTrader[dot]Com. Mark the e-mail subject Atten:Paul and include a link to this thread.

        The strategy file can be found in Documents>NinjaTrader8>bin>Custom>Strategies the file will have a .CS extenstion.

        For the log and trace files, please follow the steps below to manually attach your log and trace files to your e-mail so I may investigate this matter further.

        Open your NinjaTrader folder under My Documents.
        Right click on the 'log' and 'trace' folders and select Send To> Compressed (zipped) Folder.
        Send the 2 compressed folders as attachments to the email.
        Once complete, you can delete these compressed folders.

        edit: corrected e-mail address.
        Last edited by NinjaTrader_PaulH; 09-29-2017, 07:25 AM.
        Paul H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Max238, Today, 01:28 AM
        3 responses
        30 views
        0 likes
        Last Post Max238
        by Max238
         
        Started by timko, Today, 06:45 AM
        2 responses
        12 views
        0 likes
        Last Post NinjaTrader_ChristopherJ  
        Started by habeebft, Today, 07:27 AM
        0 responses
        4 views
        0 likes
        Last Post habeebft  
        Started by Tim-c, Today, 03:54 AM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Started by rocketman7, Today, 01:00 AM
        1 response
        10 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Working...
        X