No new order until next day

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #252204 quote
    kvacksa87
    Participant
    Junior

    Hi, I needed help with a script that doesn’t make a new buy until the nextday. If it makes a sell, it doesn’t matter if it’s a profit or loss. So after 00.00 it’s fine for it to go into buy again. If it doesn’t make a sell, I want it to continue running until it gets a signal to do so.

    #252205 quote
    robertogozzi
    Moderator
    Master
    #252206 quote
    Iván González
    Moderator
    Master

    Hi,you can handle this easily by checking when a new day starts and using a variable to mark whether a trade has already been made during the current day.
    Here’s a working example that does exactly what you described:

    ONCE lastTradeDay = 0
    
    newDay = day <> day[1]
    
    // Reset permission to trade when a new day starts
    IF newDay THEN
       lastTradeDay = 0
    ENDIF
    
    // Buy signal: close crosses above 30-period average
    setuplong = close CROSSES OVER average[30](close)
    
    // Entry: only if no position is open and no trade has been made today
    IF NOT OnMarket AND lastTradeDay = 0 AND setuplong THEN
       BUY 1 CONTRACT AT MARKET
    ENDIF
    
    // Exit: close crosses below 30-period average
    IF OnMarket AND close CROSSES UNDER average[30](close) THEN
       SELL AT MARKET
       lastTradeDay = 1 // mark that a trade has already been made today
    ENDIF
    
    GRAPH lastTradeDay COLOURED("red")
    GRAPH newDay COLOURED("blue")
    GRAPH setuplong COLOURED("lime")
    
    robertogozzi and kvacksa87 thanked this post
    2025-10-06_18-45.png 2025-10-06_18-45.png
    #252208 quote
    robertogozzi
    Moderator
    Master

    The link above seems not to work, here is the code:

    OTD = Barindex - TradeIndex(1) > IntradayBarIndex  // limits the (opening) trades till  1 per day (OTD One Trade per Day)
    if time >= StartE And time <= StartL and OTD  then //and not onmarket then
       IF conditionsmet then
          buy N shares AT MARKET
       ENDIF
    endif
    kvacksa87 and Iván González thanked this post
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.

No new order until next day


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
kvacksa87 @kvacksa87 Participant
Summary

This topic contains 3 replies,
has 3 voices, and was last updated by robertogozzi
4 months, 3 weeks ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 10/06/2025
Status: Active
Attachments: 1 files
Logo Logo
Loading...