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

Order Handling and V18

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

    Order Handling and V18

    I wanted to see wanted to see why would my strategies be entering multiple contracts, instead of just one per direction. This started last night with v18 and all ZenFire issues. I enter with just a, EnterLong(DefaultQuantity, ""); and EnterShort(DefaultQuantity, "");

    I do use the following too,
    Code:
    #region Breakeven and Trailing Stops
                // Resets the stop loss to the original value when all positions are closed
                   switch (Position.MarketPosition)
                {
                    case MarketPosition.Flat:
                        SetStopLoss(CalculationMode.Ticks, stopLossTicks);
                        previousPrice = 0;
                        break;
                    case MarketPosition.Long:
                        // Once the price is greater than entry price+ breakEvenTicks ticks, set stop loss to breakeven
                        if (Close[0] > Position.AvgPrice + breakEvenTicks * TickSize
                            && previousPrice == 0)
                        {
                            initialBreakEven = Position.AvgPrice + plusBreakEven * TickSize;
                            SetStopLoss(CalculationMode.Price, initialBreakEven);
                            previousPrice = Position.AvgPrice;
                            PrintWithTimeStamp("previousPrice = "+previousPrice);
                        }
                        // Once at breakeven wait till trailProfitTrigger is reached before advancing stoploss by trailStepTicks size step
                        else if (previousPrice    != 0 ////StopLoss is at breakeven
                                 && GetCurrentAsk() > previousPrice + trailProfitTrigger * TickSize
                            )
                        {
                            newPrice = previousPrice + trailStepTicks * TickSize;
                            SetStopLoss(CalculationMode.Price, newPrice);
                            previousPrice = newPrice;
                            PrintWithTimeStamp("previousPrice = "+previousPrice);
                        }
                        break;
                    case MarketPosition.Short:
                        // Once the price is Less than entry price - breakEvenTicks ticks, set stop loss to breakeven
                        if (Close[0] < Position.AvgPrice - breakEvenTicks * TickSize
                            && previousPrice == 0)
                        {
                            initialBreakEven = Position.AvgPrice - plusBreakEven * TickSize;
                            SetStopLoss(CalculationMode.Price, initialBreakEven);
                            previousPrice = Position.AvgPrice;
                            PrintWithTimeStamp("previousPrice = "+previousPrice);
                        }
                        // Once at breakeven wait till trailProfitTrigger is reached before advancing stoploss by trailStepTicks size step
                        else if (previousPrice    != 0 ////StopLoss is at breakeven
                                 && GetCurrentAsk() < previousPrice - trailProfitTrigger * TickSize
                            )
                        {
                            newPrice = previousPrice - trailStepTicks * TickSize;
                            SetStopLoss(CalculationMode.Price, newPrice);
                            previousPrice = newPrice;
                            PrintWithTimeStamp("previousPrice = "+previousPrice);
                        }
                        break;
                    default:
                        //autoStopA900Traded = false;
                        break;
                }
                #endregion
    but the trades are done back to back to back until margin is exceeded. The worse part is that it kills the strategy. My strategies were working just fine until last night.

    #2
    Please send me your log and trace files for today so that I may look into what occurred.

    You can do this by going to the Control Center-> Help-> Mail to Support.

    Please reference the following ticket number in the body of the email: http://www.ninjatrader.com/support/f...ad.php?t=62834
    LanceNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by ETFVoyageur, Today, 04:00 PM
    2 responses
    17 views
    0 likes
    Last Post ETFVoyageur  
    Started by dward123, 01-02-2024, 09:59 PM
    3 responses
    169 views
    0 likes
    Last Post bjunaid
    by bjunaid
     
    Started by AaronKTradingForum, Today, 03:44 PM
    1 response
    8 views
    0 likes
    Last Post AaronKTradingForum  
    Started by Felix Reichert, 04-26-2024, 02:12 PM
    11 responses
    80 views
    0 likes
    Last Post Felix Reichert  
    Started by junkone, 04-28-2024, 02:19 PM
    7 responses
    83 views
    1 like
    Last Post junkone
    by junkone
     
    Working...
    X