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 memonic, Yesterday, 01:23 PM
        2 responses
        12 views
        0 likes
        Last Post memonic
        by memonic
         
        Started by merc410, Today, 03:41 AM
        2 responses
        13 views
        0 likes
        Last Post merc410
        by merc410
         
        Started by sugalt, 04-30-2024, 04:02 AM
        2 responses
        13 views
        0 likes
        Last Post sugalt
        by sugalt
         
        Started by Ndakotan1313, 03-14-2024, 05:02 PM
        2 responses
        64 views
        0 likes
        Last Post blaise_code  
        Started by claxxical, 05-30-2017, 12:30 PM
        37 responses
        4,465 views
        0 likes
        Last Post Padan
        by Padan
         
        Working...
        X