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 NullPointStrategies, Today, 05:17 AM
          0 responses
          41 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          124 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          64 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          41 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