PDA

View Full Version : Starting Simple - Not working


GoBoks
10-18-2007, 05:43 PM
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

NinjaTrader_Josh
10-18-2007, 08:59 PM
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.
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/HelpGuideV6/MaxEntriesPerDirection.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.

GoBoks
10-19-2007, 05:21 PM
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:confused:

NinjaTrader_Josh
10-19-2007, 06:11 PM
It is because your entry conditions are wrong in your code.
This is what you have so far right now
if (Close[1] > Median[2])
{
EnterLong(DefaultQuantity, "Enter Iain Long");
DrawArrowUp("My up arrow" + CurrentBar, 0, 0, Color.Lime);
}

// Condition set 2
if (Close[1] > Median[2])
{
DrawArrowDown("My down arrow" + CurrentBar, 0, 0, Color.Red);
EnterShort(DefaultQuantity, "Enter Iain Short");
}It should be this
if (Close[1] > Median[2])
{
EnterLong(DefaultQuantity, "Enter Iain Long");
DrawArrowUp("My up arrow" + CurrentBar, 0, 0, Color.Lime);
}

// Condition set 2
if (Close[1] < Median[2])
{
DrawArrowDown("My down arrow" + CurrentBar, 0, 0, Color.Red);
EnterShort(DefaultQuantity, "Enter Iain Short");
}

GoBoks
10-20-2007, 09:54 PM
Thanks for that Josh.
I must have changed that sometime and forgotten about it. :eek: 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.

NinjaTrader_Josh
10-20-2007, 09:59 PM
My pleasure. If you have any other questions feel free to ask us any time.