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, i.ToString()+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 tentacle, Today, 08:49 PM
    0 responses
    2 views
    0 likes
    Last Post tentacle  
    Started by Amaria77, Today, 08:21 PM
    0 responses
    6 views
    0 likes
    Last Post Amaria77  
    Started by jleira, Today, 07:08 PM
    0 responses
    2 views
    0 likes
    Last Post jleira
    by jleira
     
    Started by varsha, Today, 06:33 PM
    0 responses
    20 views
    0 likes
    Last Post varsha
    by varsha
     
    Started by NtFan, Today, 04:12 PM
    1 response
    8 views
    0 likes
    Last Post NtFan
    by NtFan
     
    Working...
    X