Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Setting up my StopLoss Under the Low of Candle, Once it triggered my Strategy

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

    Setting up my StopLoss Under the Low of Candle, Once it triggered my Strategy

    Hi, My Name is Roberto. I have been trying to set up my StopLoss under the Low of the Candle[0], once the Strategy has been triggered. I have reviewed every single video and Forum there is, but I cannot find the right setup for this to happen. Please help!

    This is What I Have so far...


    .......
    protected override void OnBarUpdate()
    {
    if (BarsInProgress != 0)
    return;

    if (CurrentBars[0] < 2)
    return;

    // Set 1
    if ((Open[0] > Close[0])
    && (Open[1] > Close[1])
    && (Open[2] > Close[2])
    && (Open[3] > Close[3])
    && ((Close[0] - Low[0]) > (Open[0] - Close[0]))
    && (((Close[0] - Low[0]) / (Open[0] - Close[0])) >= ProporcionLowVela))
    {
    entryOrder = EnterLong(Contratos, "LongN" + CurrentBar);
    Draw.ArrowUp(this, Convert.ToString(CurrentBars[0]), false, 0, (Low[0] - (2 * TickSize)) , Brushes.Lime);
    }
    {

    }
    }

    protected override void OnStateChange()

    {
    CalculateOnBarClose = false;
    }

    protected override void OnOrderUpdate(Order order, double limitPrice, double stopPrice, int quantity, int filled, double averageFillPrice, OrderState orderState, DateTime time, ErrorCode error, string nativeError)
    {
    // Set 1
    if (entryOrder == order && order.OrderState == OrderState.Filled)

    {
    SetStopLoss(entryOrder.Name, CalculationMode.Price, Low[0] - 2 * TickSize, false);
    }

    #2
    Hi Roberto,

    you can try this

    Code:
    protected override void OnBarUpdate()
    {
        if (BarsInProgress != 0)
            return;
    
        if (CurrentBars[0] < 2)
            return;
    
        // Set 1
        if ((Open[0] > Close[0])
            && (Open[1] > Close[1])
            && (Open[2] > Close[2])
            && (Open[3] > Close[3])
            && ((Close[0] - Low[0]) > (Open[0] - Close[0]))
            && (((Close[0] - Low[0]) / (Open[0] - Close[0])) >= ProporcionLowVela))
        {
            SetStopLoss("LongN" + CurrentBar, CalculationMode.Price, Low[0] - 2 * TickSize, false);
            EnterLong(Contratos, "LongN" + CurrentBar);
            Draw.ArrowUp(this, Convert.ToString(CurrentBars[0]), false, 0, (Low[0] - (2 * TickSize)) , Brushes.Lime);
        }
    }

    Comment


      #3
      Hello Roberto, thanks for your question.

      I agree with MojoJojo with the example. The SetStopLoss method needs to be called in OnBarUpdate before the order is submitted to get a stop loss relative to the current market price. We also have this example that demonstrates a more advanced order handling technique for protective orders:



      Please let me know if I can assist any further.

      Comment


        #4
        Thanks a lot, you cannot imagen how much I have been trying this. I really appreciate it!!!!!

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Today, 05:17 AM
        0 responses
        46 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        126 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        66 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        42 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        46 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X