Announcement

Collapse
No announcement yet.

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.

    Comment


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

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by charlesugo_1, 05-26-2026, 05:03 PM
      0 responses
      52 views
      0 likes
      Last Post charlesugo_1  
      Started by DannyP96, 05-18-2026, 02:38 PM
      1 response
      142 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      160 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 05-10-2026, 08:12 PM
      0 responses
      96 views
      0 likes
      Last Post CarlTrading  
      Started by Hwop38, 05-04-2026, 07:02 PM
      0 responses
      276 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Working...
      X