Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Enter based on intracandle price

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

    Enter based on intracandle price

    I am having an issue entering based on intracandle price, it seems to enter on bar close only.

    My primary data series is a 15m chart, but i want to enter based on any time within a 15m candle that the criteria is met

    Here is my data series i am using:

    Code:
    AddDataSeries(BarsPeriodType.Minute, 15); // Use 15-minute bars
    AddDataSeries(Data.BarsPeriodType.Tick, 1);
    AddDataSeries(BarsPeriodType.Tick, 1);

    And this is what I am using for entry:

    Code:
    EnterLong(1, "Long_" + i); // Place a market order to enter long position​
    Does this look correct?

    #2
    Hello sofortune,

    Thank you for your post.

    What Calculate mode is your strategy using (OnBarClose, OnPriceChange, or OnEachTick)?

    If you are using Calculate.OnBarClose, the strategy will process OnBarUpdate() logic at the close of each bar.

    To have the strategy process logic intrabar you could set the Calculate mode to Calculate.OnPriceChange or Calculate.OnEachTick.

    Calculate.OnPriceChange means that OnBarUpdate() logic will process for each change in price. Calculate.OnEachTick means the strategy will process OnBarUpdate() logic for each incoming tick.



    Please let us know if we can assist further.​

    Comment


      #3
      Thanks, i was using OnBarClose

      For my purposes, it seems OnPriceChange and OnEachTick should give the same result?


      Is it necessary to reference the data series index in my enterlong() function?
      Last edited by sofortune; 05-16-2024, 08:48 AM.

      Comment


        #4
        Hello, I have changed it to OnPriceChange, and it is entering now before candle close.

        Is there a way to prevent it from taking multiple entries in a candle? I have code to prevent entering another position if already in position, but if it gets stopped or PT in the same candle, how can i prevent it from entering again after price changes again?

        Comment


          #5
          Hello sofortune,

          You can use a bool to limit entries once per bar. Set the bool to false after you call your entry method, then reset the bool back to true when IsFirstTickOfBar = true.

          For example,

          Code:
          private bool canTrade = true;
          protected override void OnBarUpdate()
          {
          if(<trade condition> && canTrade)
          {
          EnterLong();
          canTrade = false;
          }
          
          if(IsFirstTickOfBar)
          canTrade = true;
          }



          Please let us know if you have any further questions.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by CarlTrading, 03-31-2026, 09:41 PM
          1 response
          43 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 04-01-2026, 02:41 AM
          0 responses
          20 views
          0 likes
          Last Post CarlTrading  
          Started by CaptainJack, 03-31-2026, 11:44 PM
          0 responses
          30 views
          1 like
          Last Post CaptainJack  
          Started by CarlTrading, 03-30-2026, 11:51 AM
          0 responses
          47 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 03-30-2026, 11:48 AM
          0 responses
          38 views
          0 likes
          Last Post CarlTrading  
          Working...
          X