Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

SetStopLoss Intrabar and Calculate on bar close=true

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

    SetStopLoss Intrabar and Calculate on bar close=true

    hallo...

    I selected in the general section of my strategy Calculate on bar close=True
    but I want to move the trailing stop intrabar ... is possible?

    Exemple:

    if (High[0] >= (Position.AvgPrice + Target1*TickSize) && High[0] < (Position.AvgPrice + Target2*TickSize))
    SetStopLoss("EntryLong", CalculationMode.Price, Position.AvgPrice, false);


    I wish that in the same bar where you are in the market ... if it touches the barrier is moved to the trailing stop me in the same candle .. Instead I saw that I brought him back in the next sequence

    (I apologize for my bad english)

    Thanks

    #2
    You could achieve the same goal by setting Calculate on bar close = false and processing your entry logic on the first tick of each bar: http://www.ninjatrader.com/support/h...ttickofbar.htm

    You would then process your exit logic on each tick.

    Let me know if backtesting is a concern for you as this would involve additional code to make it work similarly in a backtest.

    Let me know if I can further assist.
    LanceNinjaTrader Customer Service

    Comment


      #3
      About backtest i no have problem...i run trade system in real time..
      if i set Calculate on bar close = false my ts changes because
      i want to wait until the close of the candle to generate the input signal in the candle market in the next sequence (I can not do this with the Calculate on bar close = false ........i use renko candle and i need to wait the plot of the candle)
      Last edited by turbofib; 01-08-2014, 03:20 PM.

      Comment


        #4
        When a bar closes with COBC = true it performs calculations. A Bar is not marked as closed until the first tick of the next bar.

        By setting COBC = false you could perform all calulations at the same time by using FirstTickOfBar.

        You would however need to change the bar reference location. So instead of looking at a value like Open[0] you would look at Open[1] to get the same value.

        Please see example here: http://www.ninjatrader.com/support/h...ttickofbar.htm
        LanceNinjaTrader Customer Service

        Comment


          #5
          Thank you very much .. ..

          Comment


            #6
            Originally posted by turbofib View Post
            Thank you very much .. ..
            I make a trial :

            I setting COBC = false

            if (FirstTickOfBar) Print(Time[0] + " Open[0]" + Open[0] + "Close[0]" + Close[0]+ " Open[1]" + Open[1] + "Close[1]" + Close[1] );

            i see that Open[0] is not Open Candle Renko
            I saw that the open [0] is not the open real candle posted on DATA BOX

            Comment


              #7
              This is expected with Renko bars as the Open[0] of the renko bar can change from its initial opening price.

              I would however expect Open[1] to match what you see on the chart.

              This forum post refers to backtesting and while I know you're not backtesting it may help you better understand renko bars: https://www.bigmiketrading.com/ninja...ko-charts.html

              Let me know if I can further assist.
              LanceNinjaTrader Customer Service

              Comment


                #8
                I read the post on bigmiketrading but it didn't help me to convert the program from COBC=true to COBC=false
                in my program i'm doing a comparison between 2 candles Ex:
                Close[0]> Close[1]

                how do i represent the same concept with cobc=false? is there any command to access the previous bar?

                Comment


                  #9
                  If you're calculating on FirstTickOfBar AND COBC = false then your comparison would be

                  Close[1] < Close[2]



                  Let me know if I can further assist.
                  LanceNinjaTrader Customer Service

                  Comment


                    #10
                    with COBC = false
                    if i write
                    Close[1] < Close[2] ...calculates the last 2 tick in the current bar and not the last two price bars (close 1 bar ago < close 2 bar ago)..is correct?

                    Comment


                      #11
                      While Close[0] would get the most current tick when COBC = false Close[1] will get the previous bar's close

                      Close[2] will get the bar value from 2 bars ago, not the Tick value. When looking at historical value we only have the OHLC values of each bar, not the intrabar data.

                      Let me know if I can further assist.
                      LanceNinjaTrader Customer Service

                      Comment


                        #12
                        How can i write into the program this following instructions with candle renko to setting COBC = false
                        (if (Close)[1]<0 and (Close[0]>Open[0])
                        (In the example i want to entry long when the previous candle renko is negtive and close current bar is positive)

                        Comment


                          #13
                          Originally posted by turbofib View Post
                          How can i write into the program this following instructions with candle renko to setting COBC = false
                          (if (Close)[1]<0 and (Close[0]>Open[0])
                          (In the example i want to entry long when the previous candle renko is negtive and close current bar is positive)
                          You would simply shift the index values back one... again all of this assumes you are only calculating on FirstTickOfBar
                          Code:
                          if(Close[2]<Open[2] && Close[1]>Open[1])
                          Let me know if I can further assist.
                          LanceNinjaTrader Customer Service

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by devatechnologies, 07-17-2024, 12:33 PM
                          4 responses
                          19 views
                          0 likes
                          Last Post devatechnologies  
                          Started by mtamaku, Today, 10:11 AM
                          1 response
                          10 views
                          0 likes
                          Last Post mtamaku
                          by mtamaku
                           
                          Started by samish18, Today, 10:06 AM
                          0 responses
                          7 views
                          0 likes
                          Last Post samish18  
                          Started by dbennett3, Yesterday, 10:49 AM
                          1 response
                          20 views
                          0 likes
                          Last Post marcus2300  
                          Started by Touch-Ups, Today, 08:42 AM
                          0 responses
                          18 views
                          0 likes
                          Last Post Touch-Ups  
                          Working...
                          X