Buy Close sell Open AAPL
- This topic has 4 replies, 2 voices, and was last updated 1 year ago by .
Viewing 5 posts - 1 through 5 (of 5 total)
Viewing 5 posts - 1 through 5 (of 5 total)
Similar topics:
Forums › ProRealTime English forum › General trading discussions › Buy Close sell Open AAPL
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).
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 27 28 29 30 |
// 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 parameter DEFPARAM CumulateOrders = False // Define intraday trading window ONCE timeSell = 153000 ONCE timeBuy = 220000 // Define position size ONCE positionSize = 10 // Define indicators of Moving Avarage ma1 = Average[200](close) ma2 = close[0] > ma1 // Define a strong close in percentage c1 = 3 c2 = (DClose(0) - DClose(1))/DClose(1) * 100 // Open long position IF NOT LongOnMarket AND Time = timeBuy AND ma1 AND c2 >= c1 THEN BUY positionSize SHARES AT MARKET ENDIF // Sell long position If LongOnMarket AND Time = timeSell THEN SELL AT MARKET ENDIF |
When i backtest i get 10 trades only and the system doesnt sell the positions the day after.
It 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.
Hi 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.
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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
// 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 parameter DEFPARAM CumulateOrders = False // Define intraday trading window ONCE timeSell = 153000 ONCE timeBuy = 220000 // Define position size ONCE positionSize = 50 // Define indicators of Moving Avarage trend positive or negative ma1 = Average[200](close) ma2 = close[0] > ma1 ma3 = close[0] < ma1 // Define indicators of ADX trend indicator if its strong or weak trend1 = ADX[14] > 30 trend2 = ADX[14] < 30 // Define a strong close in percentage c1 = 3 c2 = (DClose(0) - DClose(1))/DClose(1) * 100 c3 = -3 // Open long position IF NOT LongOnMarket AND Time = timeBuy AND ma1 AND c2 > c1 AND trend1 THEN BUY positionSize SHARES AT MARKET ENDIF // Sell long position If LongOnMarket AND OpenTime = timeSell THEN SELL AT MARKET ENDIF // Open short position IF NOT ShortOnMarket AND Time = timeBuy AND ma3 AND c2 < c1 AND trend2 THEN SELLSHORT positionSize SHARES AT MARKET ENDIF // Close short position IF ShortOnMarket and OpenTime = timeSell THEN EXITSHORT AT MARKET ENDIF |
Here is the final version, either short or buy close depending on the trend and sell/covers the day after.
Want to add it works very poorly overall on other stocks. But it was a fun project 🙂 On to the next!
Find exclusive trading pro-tools on