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

Starting Simple - Not working

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

    Starting Simple - Not working

    I decided to start with a simple script with the wizard, and go from there. The strategy does not work as expected, and cannot get the expected result.

    The strategy: Enter a long position if the Close of the Last bar is above the Median of the previous. Enter a short if the Close is below. (Step 1 - Simple) I can't get that simple thing to work....

    What I would expect is that the position would increment each time the close fills the requirements.

    Thanks
    Attached Files

    #2
    Hi GoBoks,

    The reason your strategy is not incrementing the position is because the default settings is to only allow one entry per direction. You can change this in the strategy dialog window when you first start the strategy. The option is in the bottom half of the window and is in the "Order Handling" section. It is called "Entries Per Direction".

    If you don't want to have to set this every single time you can unlock your code and add this line to the Initialize() method.
    Code:
    EntriesPerDirection = 10;
    10 is just an arbitrary number that you can decide on your own. You can read up more on this here. http://www.ninjatrader-support.com/H...Direction.html

    To unlock your code go to Tools->Edit NinjaScript->Strategy->select your strategy->Unlock Code. Note: After you unlock the code you cannot use the wizard anymore.
    Last edited by NinjaTrader_JoshP; 10-19-2007, 01:26 PM.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      One solved.

      Thanks Josh for that. That is one problem solved, one that I was going to work towards.

      The main problem however is that the strategy does not enter on the cross of a close over a median.

      If close (1) > Median(2) Enter LONG
      If close (1) < Median(2) enter SHORT

      This is giving me an entry Long on the first entry that should have gone short - so the strategy is not working as expected.

      I have enclosed a bmp of the first sections with what I am expecting.

      Regards

      GoBoks
      Attached Files
      Last edited by GoBoks; 10-19-2007, 05:26 PM.

      Comment


        #4
        It is because your entry conditions are wrong in your code.
        This is what you have so far right now
        Code:
        if (Close[1] > Median[2])
        {
            EnterLong(DefaultQuantity, "Enter Iain Long");
            DrawArrowUp("My up arrow" + CurrentBar, 0, 0, Color.Lime);
        }
        
        // Condition set 2
        [COLOR=Red][B]if (Close[1] > Median[2])[/B][/COLOR]
        {
            DrawArrowDown("My down arrow" + CurrentBar, 0, 0, Color.Red);
            EnterShort(DefaultQuantity, "Enter Iain Short");
        }
        It should be this
        Code:
        if (Close[1] > Median[2])
        {
            EnterLong(DefaultQuantity, "Enter Iain Long");
            DrawArrowUp("My up arrow" + CurrentBar, 0, 0, Color.Lime);
        }
        
        // Condition set 2
        [COLOR=Red][B]if (Close[1] < Median[2])[/B][/COLOR]
        {
            DrawArrowDown("My down arrow" + CurrentBar, 0, 0, Color.Red);
            EnterShort(DefaultQuantity, "Enter Iain Short");
        }
        Last edited by NinjaTrader_JoshP; 10-19-2007, 06:17 PM.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Thanks

          Thanks for that Josh.
          I must have changed that sometime and forgotten about it. Also, what I had been working on prior which I had not gotten to work was with the days (bars) past, and looking at the incorrect series expecting something different.

          Thanks again.

          Comment


            #6
            My pleasure. If you have any other questions feel free to ask us any time.
            Josh P.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Jonafare, 12-06-2012, 03:48 PM
            5 responses
            3,986 views
            0 likes
            Last Post rene69851  
            Started by Fitspressorest, Today, 01:38 PM
            0 responses
            2 views
            0 likes
            Last Post Fitspressorest  
            Started by Jonker, Today, 01:19 PM
            0 responses
            2 views
            0 likes
            Last Post Jonker
            by Jonker
             
            Started by futtrader, Today, 01:16 PM
            0 responses
            8 views
            0 likes
            Last Post futtrader  
            Started by Segwin, 05-07-2018, 02:15 PM
            14 responses
            1,792 views
            0 likes
            Last Post aligator  
            Working...
            X