Some strategies need to have only one open buy and one open sell per day. If a buy position is open, it can only open next buy on day after and also if a sell position is open, it can only open next sell a day after. If a buy and a sell positions are open, ESB won’t enter any new position in same day. To achieve this, you need to store in memory the day number of current buy or sell. For example, if today is 85th day of the year and we have an open position, next time we want to open a new buy, first we check it shouldn’t be 85th day of the year. So, we should somehow store 85 in memory to check against entry conditions for any new order. We use KEEPER to store current day of last opened buy/sell order and in entry conditions we just check day of the year against this number which shouldn’t be equal.
Indicator:
Name: last_buy_day
Type: Keeper
Shift: 0
Parameters: PrevOrderIsBuy[0],PrevOrderOpenDayOFYear[0]
Indicator:
Name: last_sell_day
Type: Keeper
Shift: 0
Parameters: PrevOrderIsSell[0],PrevOrderOpenDayOFYear[0]
Buy expression: last_buy_day<>DayOfYear and (…)
Sell expression: last_sell_day<>DayOfYear and (…)
Replace dots with your current entry conditions. For example you can set ESB open only new position by cross of two moving average and you need only one buy/sell per day.
Buy expression: last_buy_day<>DayOfYear and (MA1 crossup MA2)
Sell expression: last_sell_day<>DayOfYear and (MA1 crossdown MA2)