Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

InsideBars triggering Stop orders

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

    InsideBars triggering Stop orders

    Hi,

    I have an indicator that identifies a pattern of two consecutive inside bars. I would like to set a strategy that places a stop order (either buy or sell) when the currentbar passes the high (buy) of the or the low (sell) of the second inside bar.


    Click image for larger version

Name:	NTInsBarExample.png
Views:	142
Size:	15.2 KB
ID:	1198407

    Here is my script logic:

    if ( High[0]<=High[1] && High[1]<=High[2] && Low[0]>=Low[1] && Low[1]>=Low[2] ) //checks for inside/inside bar
    {

    if (High[0]>High[1]) // if high of current bar breaks the high of inside bar then buy
    {
    EnterLongStopLimit(Convert.ToInt32(DefaultQuantity ), (High[1] + .25), (High[1] + .25), @"IBCloseLongEntry");
    SetStopLoss(@"IBCloseLongEntry", CalculationMode.Ticks, 16, false);
    SetProfitTarget(@"IBCloseLongEntry", CalculationMode.Ticks, 4);
    }

    // Set 2
    if (Low[0]<Low[1]) // if low of current bar breaks the los of inside bar then sell
    {
    EnterShortStopLimit(Convert.ToInt32(DefaultQuantit y), (Low[1] - .25), (Low[1] - .25), @"IBCloseShortEntry");
    SetStopLoss(@"IBCloseShortEntry", CalculationMode.Ticks, 16, false);
    SetProfitTarget(@"IBCloseShortEntry", CalculationMode.Ticks, 4);
    }

    It does not seem to take the entries as expected. I am using calculate on each tick (as I think I would need that to enter the stop order on the current bar and would not want to wait til bar close).

    Any suggestions on making this strategy work?

    #2
    Hello hpedmd,

    Thank you for your note.

    It looks like you're placing your stop limit orders on the incorrect side of the market. Buy Stop Limit orders would need to be placed below the current market price, and Sell Stop Limit orders above the current price. Also, you should be calling SetStopLoss and SetProfitTarget right before the entry, not after it - putting these after the entry can cause issues.

    Limit orders, however, you could place as you're trying to do. If you change these to EnterLongLimit and EnterShortLimit do you see the entries placed as you'd expect?

    Thanks in advance; I look forward to assisting you further.

    Comment


      #3
      Hi Kate W.

      Thank you for your response. I think in this case it would be a sell stop order at 1 tick below the low of the inside bar. I only want to sell if the bar (with Grey 1) crosses below the stop.

      Click image for larger version

Name:	NTInsBarExample.png
Views:	92
Size:	13.1 KB
ID:	1198567

      Here is just an example of a sell stop order (not necessarily meeting my criteria). It would only fill if the price goes below it.

      Click image for larger version

Name:	SLM example.GIF
Views:	94
Size:	41.6 KB
ID:	1198568

      Comment


        #4
        Hello hpedmd,

        Thank you for your reply.

        I must have needed more coffee on Friday afternoon because that's my fault - Sell stops go below the current price, Buy Stops above.

        The issue I really note is that you're trying to place your order 1 tick below the low of the inside bar, but only after the price breaches that bar's low - which means it would need to already be to the point you'd be trying to place the order at by the time that order is placed.

        In this case, I would recommend just using a market order when Low[0] < Low[1]:

        if (Low[0]<Low[1]) // if low of current bar breaks the low of inside bar then sell
        {
        SetStopLoss(@"IBCloseShortEntry", CalculationMode.Ticks, 16, false);
        SetProfitTarget(@"IBCloseShortEntry", CalculationMode.Ticks, 4);
        EnterShort(Convert.ToInt32(DefaultQuantity), @"IBCloseShortEntry");
        }

        Please let us know if we may be of further assistance to you.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Yesterday, 05:17 AM
        0 responses
        54 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        130 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        72 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        44 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        49 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X