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.
    BertrandNinjaTrader Customer Service

    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.

        BertrandNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Davidtowleii, Today, 12:15 AM
        0 responses
        3 views
        0 likes
        Last Post Davidtowleii  
        Started by guillembm, Yesterday, 11:25 AM
        2 responses
        9 views
        0 likes
        Last Post guillembm  
        Started by junkone, 04-21-2024, 07:17 AM
        9 responses
        68 views
        0 likes
        Last Post jeronymite  
        Started by trilliantrader, 04-18-2024, 08:16 AM
        4 responses
        22 views
        0 likes
        Last Post trilliantrader  
        Started by mgco4you, Yesterday, 09:46 PM
        1 response
        12 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Working...
        X