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 Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      648 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      369 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      108 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      572 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      574 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X