0
votes

I was wondering if anyone has been able to "place a trade" on the close of the day that a certain condition was met. To be clear, I am looking for the following (using a simple example):

  1. 5 day moving average crosses over 10 day moving average on day X.
  2. "Long Open" trade is placed using the close price on day X.

I am aware that since the calculation is made using the closing price, It would technically be impossible for a computer to know to place the trade prior to the closing price. In real life, we can visualize these numbers before the close, so I was wondering if anyone has been able to emulate this effect.

Currently the way tradingview places trades using the strategy tester is:

  1. 5 day moving average crosses over 10 day moving average on day X.
  2. "Long Open" trade is placed using the open price on day X+1.
1

1 Answers

1
votes

In strategy, set process_orders_on_close to true, this give:

strategy("My Script",process_orders_on_close=true)