Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OnPriceChange and Crossover

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

    OnPriceChange and Crossover

    I have been debugging my code and I am lost. I have set my strategy to OnPriceChange and checking IsFirstTickOfBar to find the crossover. If I say CrossAbove(fast,slow,1), I believe it looks at the current bar. If I set Crossover(fast,slow,2), it returns it for current and previous bar and so the strategy gets executed twice. I want to check if the crossover happened during the last bar.

    When I am on playback, I noticed that the bar closed above on the previous bar, but the first tick of the bar the crossover is false (it went down by 1 tick). I still would like to take the trade based on the previous bar, no matter what the current bar returns.

    How do I make sure that in both scenarios it looks only at the previous bar.
    \
    Thanks!!
    Last edited by Graci117; 01-24-2024, 08:32 PM.

    #2
    Hello Graci117,

    Thank you for your post.

    You will need to create your own condition instead of using CrossAbove or CrossBelow, as these functions cannot exclude the current bar.

    For example,

    Code:
    if (fast[2] < slow[2] && fast[1] > slow[1])
    //do something
    ​
    Please let us know if you have any other questions.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, Today, 05:17 AM
    0 responses
    44 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
    65 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