Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Another Coding Question

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

    Another Coding Question

    I'm stuck on another coding question... And since I have taken a crash course the past 48 hours and got this far I don't mind asking..

    No trades are being taken. What do I have out of place?

    // Make sure this strategy does not execute against historical data
    if (Historical)
    return;


    // Submits an entry limit order at the current low price to initiate an ATM Strategy if both order id and strategy id are in a reset state
    // **** YOU MUST HAVE AN ATM STRATEGY TEMPLATE NAMED 'AtmStrategyTemplate' CREATED IN NINJATRADER (SUPERDOM FOR EXAMPLE) FOR THIS TO WORK ****
    if (Close[1] > KeltnerChannel(2, 10).Upper[1]
    && Close[0] < Close[1]
    && ADX(14)[1] >= ADX(14)[0])
    atmStrategyId = GetAtmStrategyUniqueId();
    orderId = GetAtmStrategyUniqueId();
    AtmStrategyCreate(Cbi.OrderAction.Sell, OrderType.Market, orderId, "AtmStrategyTemplate", atmStrategyId);

    // Check for a pending entry order
    if (orderId.Length > 0)

    if (Position.MarketPosition == MarketPosition.Flat && orderId.Length == 0 && atmStrategyId.Length == 0)
    {
    string[] status = GetAtmStrategyEntryOrderStatus(orderId);

    // If the status call can't find the order specified, the return array length will be zero otherwise it will hold elements
    if (status.GetLength(0) > 0)
    {
    // If the order state is terminal, reset the order id value
    if (status[2] == "Filled" || status[2] == "Cancelled" || status[2] == "Rejected")
    orderId = string.Empty;
    }

    } // If the strategy has terminated reset the strategy id
    else if (atmStrategyId.Length > 0 && GetAtmStrategyMarketPosition(atmStrategyId) == Cbi.MarketPosition.Flat)
    atmStrategyId = string.Empty;


    if (atmStrategyId.Length > 0)
    {
    Last edited by mreisinger; 11-13-2014, 09:41 PM.

    #2
    mreisinger, in which environment do you test this script? Do you see any log errors in the Control Center when you test it?

    I would only expect trades in realtime or market replay if you entry condition triggers, so not in backtesting from the charts or the Strategy Analyzer.

    Comment


      #3
      I was backtesting in Market Replay. Now I am getting a CS1501 error in this line:

      AtmStrategyCreate(Cbi.OrderAction.Sell, OrderType.Market, orderId, "AtmStrategyTemplate", atmStrategyId);

      Comment


        #4
        I would expect so, you miss the limit and stop price parameters as well as the TimeInForce.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        61 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        39 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        21 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        23 views
        0 likes
        Last Post TheRealMorford  
        Started by Mindset, 02-28-2026, 06:16 AM
        0 responses
        51 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Working...
        X