Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Change Target Price after Multi Touch w/no fill

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

    Change Target Price after Multi Touch w/no fill

    Hi.

    Should this code work? I am trying to create a code in my strategy with a multi time frame with the secondary time frame being 1 second so that it can count how many times the price hit the target during the main bar for each second. So say it hit the target 20 times in the last 20 seconds without filling the strategy moves the profit target from 2 ticks to 1 tick or even breakeven. Do I have it right or am I even close? I tried to make the Close [1][0] like that but it wouldn't allow it so I was hoping that if I used the BarsInProgress==1 it would use seconds instead of the main timeframe of say 1 minute. It's a bit hard to backtest so I wanted to know if I am even close before I try to figure the testing part out. Thank you for any help.

    if (BarsInProgress == 1)
    {
    if (Close[0] == Position.AvgPrice +2 * TickSize)
    {
    TargetTouch = TargetTouch +1;
    }
    if (TargetTouch >= 20)
    {
    SetProfitTarget("Long 1a", CalculationMode.Price, Position.AvgPrice +1 * TickSize);
    }
    }

    #2
    Hi cre8it8, without having tested it I think the concept is fine, Close[0] in BarsInProgress 1 would be the added series price. However if you wish to backtest most accurately by executing on the 1 second series, then please use the Exit() methods for your target / stop orders, you can designate a BarsInProgress parameter here to submit the order to.

    ExitLongLimit(int barsInProgressIndex, bool liveUntilCancelled, int quantity, double limitPrice, string signalName, string fromEntrySignal)

    Comment


      #3
      Thanks for the info!

      Comment


        #4
        Originally posted by cre8it8 View Post
        Hi.

        Should this code work? I am trying to create a code in my strategy with a multi time frame with the secondary time frame being 1 second so that it can count how many times the price hit the target during the main bar for each second. So say it hit the target 20 times in the last 20 seconds without filling the strategy moves the profit target from 2 ticks to 1 tick or even breakeven. Do I have it right or am I even close? I tried to make the Close [1][0] like that but it wouldn't allow it so I was hoping that if I used the BarsInProgress==1 it would use seconds instead of the main timeframe of say 1 minute. It's a bit hard to backtest so I wanted to know if I am even close before I try to figure the testing part out. Thank you for any help.

        if (BarsInProgress == 1)
        {
        if (Close[0] == Position.AvgPrice +2 * TickSize)
        {
        TargetTouch = TargetTouch +1;
        }
        if (TargetTouch >= 20)
        {
        SetProfitTarget("Long 1a", CalculationMode.Price, Position.AvgPrice +1 * TickSize);
        }
        }
        Comparing doubles can be tricky. You may want to Round2TickSize, the Position.AvgPrice +2 * TickSize quantity.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        666 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        377 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        110 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        575 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        580 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X