Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Stoploss and Profittarget Problem

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

    Stoploss and Profittarget Problem

    Hi there, i have read many Hours in this forum, but i don´t find a solution.

    Here is my problem

    i will trade a 30 min bar. the ATR of this bar is 20 ticks for example. If i enter this bar i will make a profit target of this 20 ticks. I will make a stoploss of this 20 ticks. The Position will be stopped out or will go in profit. If the Position is closed, with or without Profit the next bar has a range of 15 ticks for example. So i need a PT of entry + 15 and a Stoploss of Entry -15. How can i make this ?

    please help me

    #2
    You could directly use SetProfitTarget and SetStopLoss set to CalculationMode.Ticks for this, as they would automatically reference your entryPrice directly when issuing the needed bracket orders (those Set Methods would be OCO'ed as well).

    Comment


      #3
      hi,

      thanks for your fast reply, but if i use the normal setstoploss ans setprofittarget i can only use normal values.

      i the 30 min bar 40 ticks i need 40 ticks stop and profit from entry if the bar has got 30 ticks i need 30 ticks SL and PT. How i can set the ticksize of PT and SL to the ticksize of my entrybar ?

      Comment


        #4
        You would need to custom code to achieve this - record the range of your entry bar at time of entry and then call SetStopLoss / SetProfitTarget to place the exit bracket at your desired values.

        Comment


          #5
          hi this is what i´m locking for, but i have no idea how i make this ?

          is there a reference oder a code sample ? Sorry ..

          Comment


            #6
            Sorry, I'm not aware of a direct sample for this, the general idea is like demonstrated in this snippet below -

            Code:
             
            if (Position.MarketPosition == MarketPosition.Flat)
            {
            SetProfitTarget(CalculationMode.Ticks, 20);
            }
            
            if (CrossAbove(SMA(Fast), SMA(Slow), 1))
            {
            range = Math.Abs(High[1] - Low[1]);
            EnterLong();
            }
            
            if (Position.MarketPosition == MarketPosition.Long)
            SetProfitTarget(CalculationMode.Price, Position.AvgPrice + range);

            Comment


              #7
              Thx bertrand

              entry and PT work, SL don´t work

              Here is my Code

              Code:
              protected override void OnBarUpdate()
                      {
                          // Condition set 1
                          
                          if (Position.MarketPosition == MarketPosition.Flat)
                              {
                              SetProfitTarget(CalculationMode.Ticks, 20);
                              }
              
                          if (entry condition)
                              {
                              range = Math.Abs(High[0] - Low[0]);
                              EnterLong();
                                  }
                          if (Position.MarketPosition == MarketPosition.Long)
                          SetProfitTarget(CalculationMode.Price, Position.AvgPrice + range);
                          SetStopLoss(CalculationMode.Price, Position.AvgPrice - range);
                      }
              Last edited by thunderbolt78; 03-02-2010, 06:59 AM.

              Comment


                #8
                What error do you get with the targets? You would need to reset those as well when flat...

                Comment


                  #9
                  i have no error,

                  if i run the script with setstoploss and setprofittarget only Profittargt will filled. No Stoploss will triggered. I i run

                  if (Position.MarketPosition == MarketPosition.Long)
                  // SetProfitTarget(CalculationMode.Price, Position.AvgPrice + range);
                  SetStopLoss(CalculationMode.Price, Position.AvgPrice - range);

                  i have an Entry and after this the position will be stopped out but not with the right range.

                  Comment


                    #10
                    Please run the strategy with TraceOrders = true in your Initialize(), this will give you insight into it's order behavior -

                    Comment


                      #11
                      May I ask how you guys post your codes in that blue box?

                      Comment


                        #12
                        Just wrap code tags around it...the rhomb symbol when you post...

                        Looks then like below -

                        Code:
                         
                        MyCodeIsHappyInThisBox

                        Comment


                          #13
                          Sorry Bertrand. is this "#" the rhomb symbol you are talking about? when you say wrap code tags around it, do you mean that I paste the code inbetween "
                          Code:
                          " and "
                          "?

                          Comment


                            #14
                            Thanks Bertrand! Got it now!

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                            0 responses
                            601 views
                            0 likes
                            Last Post Geovanny Suaza  
                            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                            0 responses
                            347 views
                            1 like
                            Last Post Geovanny Suaza  
                            Started by Mindset, 02-09-2026, 11:44 AM
                            0 responses
                            103 views
                            0 likes
                            Last Post Mindset
                            by Mindset
                             
                            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                            0 responses
                            559 views
                            1 like
                            Last Post Geovanny Suaza  
                            Started by RFrosty, 01-28-2026, 06:49 PM
                            0 responses
                            558 views
                            1 like
                            Last Post RFrosty
                            by RFrosty
                             
                            Working...
                            X