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 Brevo, Today, 01:45 AM
    0 responses
    3 views
    0 likes
    Last Post Brevo
    by Brevo
     
    Started by aussugardefender, Today, 01:07 AM
    0 responses
    3 views
    0 likes
    Last Post aussugardefender  
    Started by pvincent, 06-23-2022, 12:53 PM
    14 responses
    239 views
    0 likes
    Last Post Nyman
    by Nyman
     
    Started by TraderG23, 12-08-2023, 07:56 AM
    9 responses
    384 views
    1 like
    Last Post Gavini
    by Gavini
     
    Started by oviejo, Today, 12:28 AM
    0 responses
    6 views
    0 likes
    Last Post oviejo
    by oviejo
     
    Working...
    X