Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Can you program OrderEntry commands in a loop or only in explicit code

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

    Can you program OrderEntry commands in a loop or only in explicit code

    Hi Ninja,

    I would like my strategy to place multiple order entries at certain increments within a certain price range.

    Now, I can go ahead and code these order entry lines one by one with all the specific order prices and signal names etc, but is there also a way to do it in a loop?

    I want to do something similar to the below code, but sofar the strategy analyzer keeps hanging in the loop and does not execute a single order:

    Code:
                 
    // Set 1
                if (Longs == true)
                {    
                     while (StopPrice >= StartRange && StopPrice <= EndRange)
                    {    
                        StopPrice = StartRange + OrderIncrement;
                        EnterLongStopMarket(Convert.ToInt32(DefaultQuantity), StopPrice, StopPrice.ToString());
                    }
                }
    Is this way of coding at all possible (order entry in loops)?
    Hope you can help,

    Cheers,
    Vladja

    #2
    Hello Vladja,

    Thank you for your note.

    On each loop the same order is going to submitted, as the signal name remains the same. To have a new order created on each loop, you would need to modify the signalName.

    One way you could do this would be to use a for loop, and pass i to the signalName, making it unique on each loop.
    Code:
    for(int i=0; i<3; i++)
     EnterLongStopMarket(Convert.ToInt32(DefaultQuantity), StopPrice, [B]i.ToString()[/B]+StopPriceToString());
    Please let us know if you need further assistance.
    Alan P.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, Today, 05:17 AM
    0 responses
    52 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    130 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    70 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    44 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    48 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X