Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

help with profit target, stop loss

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

    help with profit target, stop loss

    note I use the wizard.

    I first tried to include a stop loss and profit target of 10% in either direction and even though the price traveled there it was never triggered...what might be the common problem there?

    Then, I took one simple instrument that I knew went to the Price range (changed from percent to price) I input, and got bizarre results. See chart and the code below. All stop out and most of them at the same as teh entry price.

    ///<summary>
    /// This method is used to configure the strategy and is called once before any strategy method is called.
    ///</summary>
    protectedoverridevoid Initialize()
    {
    Add(VOLMA(MADaysShort));
    Add(VOLMA(MADaysLong));
    SetStopLoss(
    "long", CalculationMode.Price, 0.5, false);
    SetProfitTarget(
    "long", CalculationMode.Price, 0.7);
    CalculateOnBarClose =
    true;
    }
    ///<summary>
    /// Called on each bar update event (incoming tick)
    ///</summary>
    protectedoverridevoid OnBarUpdate()
    {
    // Condition set 1
    if (CrossAbove(VOLMA(MADaysShort), VOLMA(MADaysLong), 1))
    {
    EnterLong(DefaultQuantity,
    "long");
    }
    }
    #region
    Attached Files

    #2
    Originally posted by meegwell View Post
    note I use the wizard.

    I first tried to include a stop loss and profit target of 10% in either direction and even though the price traveled there it was never triggered...what might be the common problem there?

    Then, I took one simple instrument that I knew went to the Price range (changed from percent to price) I input, and got bizarre results. See chart and the code below. All stop out and most of them at the same as teh entry price.

    ///<summary>
    /// This method is used to configure the strategy and is called once before any strategy method is called.
    ///</summary>
    protectedoverridevoid Initialize()
    {
    Add(VOLMA(MADaysShort));
    Add(VOLMA(MADaysLong));
    SetStopLoss(
    "long", CalculationMode.Price, 0.5, false);
    SetProfitTarget(
    "long", CalculationMode.Price, 0.7);
    CalculateOnBarClose =
    true;
    }
    ///<summary>
    /// Called on each bar update event (incoming tick)
    ///</summary>
    protectedoverridevoid OnBarUpdate()
    {
    // Condition set 1
    if (CrossAbove(VOLMA(MADaysShort), VOLMA(MADaysLong), 1))
    {
    EnterLong(DefaultQuantity,
    "long");
    }
    }
    #region
    CalculationMode.Price will take you out at the stated prices of 0.5 or 0.7, which in each case looks correct. You may want to use CalculationMode.Ticks instead.

    Comment


      #3
      meegwell, please give the suggestion from koganam below a try - if you would like to revisit your former approach expressing the stops / targets in %, please keep in mind 10% would be designated by 0.1 and not 10.

      Comment


        #4
        if calculationmode.price is correct, it was generated by the wizard as the stoploss and profit target, why is it stopping me out at the same price as entry price as seen on the attachment corresponding to the code?

        Thanks for the input,

        Meegwell

        Comment


          #5
          You submit a stop market order basically at the price of 0.5 - that would trigger immediately in backtest. I would suggest not using price mode from the wizard, it's only meant as an option to be able to set the price explicitly as needed, which is a task done via manual coding.

          The percent or tick modes suit your strategy better here.

          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
          573 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X