Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

stoploss at breakeven at T1

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

    stoploss at breakeven at T1

    Hi,

    I have a strategy- CalculateOnBarClose=false- trading 2 contracts.
    The entry orders are separated in 2 orders of 1 contract each with an unique signal. So the Profittarget and Stoploss can be set for each contract separately.
    The first contract is taken out by the profittarget for that contract.
    I move then the stoploss for the 2e contract to brealeven+1.
    The script is as follows:

    //*****************Move Stop to Breakeven+1 after T1

    if(Position.Quantity==1)
    SetStopLoss("ZLRL2",CalculationMode.Price,Position.AvgPrice+TickSize,false);

    if(Position.Quantity==-1)
    SetStopLoss("ZLRS2",CalculationMode.Price,Position.AvgPrice-TickSize,false);

    However it looks like that the original stoploss is still valid.
    I assumed that Position.AvgPrice is the average entry price of the 2 contracts.

    Could you pls tell me what I am doing wrong?

    #2
    Right, you would need to "invalidate" the SetStopLoss setting, since it stays effective once you called it. We'll look into and let you know.

    Comment


      #3
      Dierk,

      Could you pls confirm that Position.AvgPrice the entry price is.
      In the documentation I could not find any reference to an entry price.

      Comment


        #4
        That is correct.

        Comment


          #5
          Dierk,

          For the original setting of the stoploss I use the following script

          if(Position.MarketPosition==MarketPosition.Flat)
          {
          SetStopLoss("ZLRL1",CalculationMode.Ticks,Stoploss1,false);
          SetStopLoss("ZLRS1",CalculationMode.Ticks,Stoploss1,false);
          SetStopLoss("ZLRL2",CalculationMode.Ticks,Stoploss2,false);
          SetStopLoss("ZLRS2",CalculationMode.Ticks,Stoploss2,false);
          }

          and for the new setting I use

          //*****************Move Stop to Breakeven+1 after T1

          if(Position.Quantity==1)
          SetStopLoss("ZLRL2",CalculationMode.Price,Position.AvgPrice+TickSize,false);

          if(Position.Quantity==-1)
          SetStopLoss("ZLRS2",CalculationMode.Price,Position.AvgPrice-TickSize,false);


          Might it be possible that a stoploss can not be changed when the original setting uses

          CalculationMode.Ticks

          while the reset of the stoploss uses

          CalculationMode.Price

          Comment


            #6
            Changing the CalculationMode should work. I suggest verifying by a simple a possible strategy (only one entry).

            Comment


              #7
              Hi,

              Is there anybody out here who - trading two contracts -has developed a working exit strategy,where the stoploss is moved to breakeven the moment the first contract is taken out at T1.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by bortz, 11-06-2023, 08:04 AM
              47 responses
              1,610 views
              0 likes
              Last Post aligator  
              Started by jaybedreamin, Today, 05:56 PM
              0 responses
              9 views
              0 likes
              Last Post jaybedreamin  
              Started by DJ888, 04-16-2024, 06:09 PM
              6 responses
              19 views
              0 likes
              Last Post DJ888
              by DJ888
               
              Started by Jon17, Today, 04:33 PM
              0 responses
              6 views
              0 likes
              Last Post Jon17
              by Jon17
               
              Started by Javierw.ok, Today, 04:12 PM
              0 responses
              16 views
              0 likes
              Last Post Javierw.ok  
              Working...
              X