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.
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:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
ONCElastTradeDay=0
newDay=day<>day[1]
// Reset permission to trade when a new day starts
IFnewDayTHEN
lastTradeDay=0
ENDIF
// Buy signal: close crosses above 30-period average
setuplong=closeCROSSES OVERaverage[30](close)
// Entry: only if no position is open and no trade has been made today
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.