Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Previous price on "On Price Change" strategy

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

    Previous price on "On Price Change" strategy

    A buy order will be executed when the following is met

    The current price (Close[0]) is 1 tick higher than the previous closed bar's high (High[1])
    +
    the previous price (Close[??]) was equal to the previous bar's high (High[1]).

    How do I point to the previous price change since Close[1] would point to the previous bar, not the previous price change?

    Thanks!

    #2
    Hello Ousher, thanks for writing in.

    You can keep track of the last changed price by saving the last price at the end of OnBarUpdate e.g:

    Code:
    private double lastPrice = -1;
    protected override void OnBarUpdate()
    {
    Print("lastPrice " + lastPrice);
    Print("Close[0] " + Close[0]);
    Print("");
    
    if(Close[0] != lastPrice)
    lastPrice = Close[0];
    }
    Best regards,
    -ChrisL

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, Yesterday, 05:17 AM
    0 responses
    56 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    132 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    73 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    45 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