• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

does SetStopLoss function causes extra queries?

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

    does SetStopLoss function causes extra queries?

    1) In each OnBarUpdate, i have set `SetStopLoss`, so i think it executes on every tick.
    Does that cause to send extra queries to broker (plus, output order/log messages on every tick)?

    2) let's say, the solution is to move that inside condition (i.e. in OnExecution) , but i am mostly worried with MoveToBreakEven, because i use :


    Code:
    ...
    if(MarketPosition == MarketPosition.Long){
      if (TicksFromEntry > MoveToBE_Enough_ticks) {
          SetStopLoss (........);
      }
    }
    ...
    then once it goes over the BE_points, then on every next tick, it still causes to issue SetStopLoss. Should I code it more, to execute that command only once? or can i leave it as is (but i see the log appearing on every tick, that i dont like and only want to execute once).

    Should I use:


    Code:
    ... 
    ...
      if (TicksFromEntry > MoveToBE_Enough_ticks) {
         if(!be_executed) {
           SetStopLoss (........);
           be_executed=true;
         }
      }
    ...
    ...

    #2
    Hello selnomeria,

    Thanks for opening the thread.

    You are coming up with valid approaches to the issue you are facing. Calling SetStopLoss() on every tick can send extra updates that may modify the stop loss and perform the internal logic behind the method. If the price for the SetStopLoss() does not change from last time it was called no further action will be taken. However, calling it only as often as needed would be advised.

    Using a doOnce bool to control the breakeven so it occurs once would be a good solution.

    If you have any additional questions, please don't hesitate to ask.
    JimNinjaTrader Customer Service

    Comment


      #3
      so, as i understand, the problem arises when the price is different.
      so, as long as price is be same, calling SetStopLoss on every tick, causes:

      A) nothing at all
      B) just outputing log messages in LOG tab, but doesnt submits order to brokers
      C) B, also sending an command to broker (but broker doesnt react with same stoploss value)

      As i understand, B is right?
      Last edited by ttodua; 09-09-2017, 01:17 AM.

      Comment


        #4
        Hello selnomeria,

        You are on the right track, but to be exact, the order method will always have some sort of output feedback in the Output window with TraceOrders enabled. The behavior is between A and B. If the price does not change, there will not be a noted change in the log tab of the Control Center and there will not be an additional submission sent to the broker.
        JimNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by pjsmith, Today, 03:28 AM
        1 response
        8 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by Leeroy_Jenkins, Today, 06:54 AM
        0 responses
        3 views
        0 likes
        Last Post Leeroy_Jenkins  
        Started by rainbow47, Today, 06:10 AM
        0 responses
        9 views
        0 likes
        Last Post rainbow47  
        Started by stenberg98, Today, 04:53 AM
        2 responses
        7 views
        0 likes
        Last Post NinjaTrader_Marco  
        Started by wukefuha, Today, 03:20 AM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_Marco  
        Working...
        X