NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Strategy Development

Strategy Development Support for the development of custom automated trading strategies using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 05-24-2008, 08:41 PM   #1
Dobbes
Member
 
Join Date: Apr 2008
Posts: 35
Thanks: 0
Thanked 0 times in 0 posts
Default Trouble Scaling out

After wrestling with the reference sample, I was able to come up with this, and I don't understand why it isn't working. Whenever I backtest it, it simply scales out everything at the set profit target, instead of scaling out half and letting the second half scale with the trailing stop.

Code:
public class jhk : Strategy
    {
        #region Variables
        // Wizard generated variables
        private int myInput0 = 1; // Default setting for MyInput0
        // User defined variables (add any user defined variables below)
        #endregion

        /// <summary>
        /// This method is used to configure the strategy and is called once before any strategy method is called.
        /// </summary>
        protected override void Initialize()
        {
            EntriesPerDirection = 1;
            EntryHandling         = EntryHandling.UniqueEntries;
            
            SetStopLoss(CalculationMode.Ticks, 10, false);
            SetProfitTarget("Long1a", CalculationMode.Ticks, 20);
            SetProfitTarget("Short1a", CalculationMode.Ticks, 20);
            SetTrailStop(CalculationMode.Ticks, 8);

            CalculateOnBarClose = true;
        }

        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {
            // Condition set 1
            if (CrossAbove(SMA(6), SMA(10), 1)
                
            {
                EnterLong(1,"Long1a");
                EnterLong(1, "Long1b");
                DrawArrowUp("My up arrow" + CurrentBar, false, 0, 0, Color.Lime);
            }

            // Condition set 2
            if (CrossBelow(SMA(6), SMA(10), 1)
                
            {
                EnterShort(1, "Short1a");
                EnterShort(1, "Short1b");
                DrawArrowDown("My down arrow" + CurrentBar, false, 0, 0, Color.Red);
            }
Dobbes is offline  
Reply With Quote
Old 05-25-2008, 03:51 AM   #2
NinjaTrader_Dierk
Administrator
 
NinjaTrader_Dierk's Avatar
 
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
Default

I suggest debugging your code as per here: http://www.ninjatrader-support.com/v...ead.php?t=3418

Also: TraceOrders coudl be of value too. Please check out the docs.
NinjaTrader_Dierk is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
NTMARKETPOSITION = Trouble / Bug BIGRED Automated Trading 24 09-15-2008 11:03 PM
Trouble when connecting to IB JohnG Historical NinjaTrader 6.5 Beta Threads 8 03-18-2008 10:04 AM
strategy trouble volguy Strategy Development 1 02-21-2008 02:02 AM
Patystem trouble. Bunker Connecting 2 10-02-2006 06:47 AM
trouble connecting to eSignal eah Installation and Licensing 2 03-08-2006 08:51 AM


All times are GMT -6. The time now is 06:22 PM.