Buy Close sell Open AAPL
Forums › ProRealTime English forum › General trading discussions › Buy Close sell Open AAPL
- This topic has 4 replies, 2 voices, and was last updated 1 year ago by andyafonso.
-
-
01/20/2023 at 3:41 PM #207770
Hi again!
I have a hard time figuring out why my system doesnt do what i want it to do.
I want to buy the close if it’s above moving average 200 and closing above 3%.
Then i want to sell this position the day after at open.
Since i live in Sweden the trading hours for the NY stockxchange is 15:30 -> 22:00.
Stock is AAPL (just an example).
123456789101112131415161718192021222324252627282930// Buy a strong close and sell the open in a strong trend.// Instrument: AAPL, 30min, 9:30 - 4:00 Eastern Time, 1 point spread, account size: 10.000 Euro// ProOrder code parameterDEFPARAM CumulateOrders = False// Define intraday trading windowONCE timeSell = 153000ONCE timeBuy = 220000// Define position sizeONCE positionSize = 10// Define indicators of Moving Avaragema1 = Average[200](close)ma2 = close[0] > ma1// Define a strong close in percentagec1 = 3c2 = (DClose(0) - DClose(1))/DClose(1) * 100// Open long positionIF NOT LongOnMarket AND Time = timeBuy AND ma1 AND c2 >= c1 THENBUY positionSize SHARES AT MARKETENDIF// Sell long positionIf LongOnMarket AND Time = timeSell THENSELL AT MARKETENDIFWhen i backtest i get 10 trades only and the system doesnt sell the positions the day after.
01/20/2023 at 4:19 PM #207772It opens trades at 22:00 (when the 21:30 candle closes) and exits at 15:30 (when the 15:00 candle closes, provided there is one).
Try replacing Time with OpenTime.
1 user thanked author for this post.
01/20/2023 at 4:48 PM #207775Hi again,
Got it to work now, thanks alot! The system is closing the position after 30 min now (16:00) instead of 15:30. I guess when i change the time the system will not find a closing candle to sell it on.
01/20/2023 at 5:51 PM #20778112345678910111213141516171819202122232425262728293031323334353637383940414243444546// Buy or Sell a strong/weak close and sell the open in a strong/weak trend.// Instrument: Tesla, 10min, 9:30 - 4:00 Eastern Time, 1 point spread, account size: 10.000 Euro// ProOrder code parameterDEFPARAM CumulateOrders = False// Define intraday trading windowONCE timeSell = 153000ONCE timeBuy = 220000// Define position sizeONCE positionSize = 50// Define indicators of Moving Avarage trend positive or negativema1 = Average[200](close)ma2 = close[0] > ma1ma3 = close[0] < ma1// Define indicators of ADX trend indicator if its strong or weaktrend1 = ADX[14] > 30trend2 = ADX[14] < 30// Define a strong close in percentagec1 = 3c2 = (DClose(0) - DClose(1))/DClose(1) * 100c3 = -3// Open long positionIF NOT LongOnMarket AND Time = timeBuy AND ma1 AND c2 > c1 AND trend1 THENBUY positionSize SHARES AT MARKETENDIF// Sell long positionIf LongOnMarket AND OpenTime = timeSell THENSELL AT MARKETENDIF// Open short positionIF NOT ShortOnMarket AND Time = timeBuy AND ma3 AND c2 < c1 AND trend2 THENSELLSHORT positionSize SHARES AT MARKETENDIF// Close short positionIF ShortOnMarket and OpenTime = timeSell THENEXITSHORT AT MARKETENDIFHere is the final version, either short or buy close depending on the trend and sell/covers the day after.
01/20/2023 at 5:56 PM #207784Want to add it works very poorly overall on other stocks. But it was a fun project 🙂 On to the next!
1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on