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

Newbie - Place order once from within OnBarUpdate

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

    Newbie - Place order once from within OnBarUpdate

    Hi,

    Newbie question - and I have been looking at the forum but I might just need a little pointing in the right direction.

    I simply want to place an order once from within OnBarUpdate and then not have it constantly resubmit on every tick - so I used a Boolean but when I do the order never gets to Sim101.....its not a real strategy just trying to get to grips with how NT works

    I have at the top....
    #region Variables
    privateint lotSize = 1; // Default setting for LotSize
    privatebool entrySubmitS = false;
    #endregion

    ...then further down I have....
    protectedoverridevoid OnBarUpdate()
    {
    if (entrySubmitS == false)
    {
    Print("OnBarUpdate(): S" + Time[0]);
    // Only allow entries if we in time zone
    if ((ToTime(Time[0]) >= 110000 && ToTime(Time[0]) < 143500))
    {
    // Entry Signal:
    EnterShortStop(LotSize, GetCurrentBid() + -15 * TickSize, "D2");
    EnterShortStop(LotSize, GetCurrentBid() + -
    20 * TickSize, "D3");
    entrySubmitS = true;
    }
    Print(
    "OnBarUpdate(): Out S" + Time[0]);
    }}

    ...so basically once we are in the time zone I want to put in those two orders and then stay at that position in the queue. Currently it resubmits on every tic update - naturally. But the Boolean switch when put in there to true stops even the inital order being sent in.



    Apologies if I have missed the obvious - the forum is great - I can see loads of great things I would like to try. Thanks

    #2
    OddNick, welcome to the forums - I think this happens because you never reset the switch to allow for new orders coming in, you can try this for example with

    if (Historical) return;

    at the OnBarUpdate() start, thus placing the order once in realtime and then stopping to see how it behaves.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Many thanks for that - it works great now I have done that.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by dcriador, Today, 12:04 PM
      0 responses
      0 views
      0 likes
      Last Post dcriador  
      Started by cutzpr, Today, 08:54 AM
      0 responses
      6 views
      0 likes
      Last Post cutzpr
      by cutzpr
       
      Started by benmarkal, Today, 08:44 AM
      0 responses
      12 views
      0 likes
      Last Post benmarkal  
      Started by Tin34, Today, 03:30 AM
      2 responses
      26 views
      0 likes
      Last Post Tin34
      by Tin34
       
      Started by sastrades, Yesterday, 09:59 AM
      2 responses
      42 views
      0 likes
      Last Post brucerobinson  
      Working...
      X