Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 funk10101, Today, 09:43 PM
    0 responses
    4 views
    0 likes
    Last Post funk10101  
    Started by pkefal, 04-11-2024, 07:39 AM
    11 responses
    36 views
    0 likes
    Last Post jeronymite  
    Started by bill2023, Yesterday, 08:51 AM
    8 responses
    44 views
    0 likes
    Last Post bill2023  
    Started by yertle, Today, 08:38 AM
    6 responses
    26 views
    0 likes
    Last Post ryjoga
    by ryjoga
     
    Started by algospoke, Yesterday, 06:40 PM
    2 responses
    24 views
    0 likes
    Last Post algospoke  
    Working...
    X