Can you backtest for a universe of securities?
Forums › ProRealTime English forum › ProOrder support › Can you backtest for a universe of securities?
- This topic has 17 replies, 5 voices, and was last updated 4 years ago by
robertogozzi.
-
-
08/22/2021 at 8:28 PM #175947
Can you backtest a trading strategy for a universe of securities?
Or you have to backtest individually?
Also, how do you start an automatic trading strategy? I found this video but the options are not available in the newer version:
https://www.prorealtime.com/en/videos_tutorial/143_3_ways_to_start_a_trading_system_with_proorder
It would bet ime for prorealtime to make new help videos, they are all of the previous version!
08/22/2021 at 8:30 PM #175948Can you make an strategy that scans a universe of securities for certain criteria and if they are met, opens a position? Or that is not possible either?
08/22/2021 at 8:37 PM #17594908/22/2021 at 8:48 PM #17595008/22/2021 at 8:50 PM #175952Thank you, I thought so. What’s the maximum securities you can start an algo on? And how do you start it?
Here is the algo I’m coding, if someone can help me with a couple of doubts I would appreciate it:
momentum burst algo123456789101112131415161718192021222324252627282930// Conditions to enter long positionsIF NOT LongOnMarketAND c1 = close > close[1]*1.035AND c2 = close[1] <= close [2]*1.02AND c3 = close[2] <= close [3]AND c4 = EstimatedVolume > volume[1]AND c5 = average[7]/average[65]>=1.05AND c6 = close =>4THENBUY 10 CONTRACTS AT MARKETENDIF// Stops and targets : Enter your protection stops and profit targets hereSET STOP LOSS AT LOWEST [0]// Conditions to exit long positionsIf LongOnMarket ANDclose >= POSITIONPRICE*(1+(LOWEST[0]-POSITIONPRICE)/POSITIONPRICE)*4)THENSELL 5 CONTRACTS AT MARKETENDIF// conditions to trail the restIf LongOnMarket ANDclose >= POSITIONPRICE*(1+(LOWEST[0]-POSITIONPRICE)/POSITIONPRICE)*4)THENSET SET STOP %TRAILING 5There’s a missing characters in the 2nd and 4th lines, and I can’t see why.
Then, I don’t know if the trailing stop after selling 1/2 position would be set for the remaining shares or the initial positions.
Finally, how could I code a trailing stop that changes every day to the lowest of the previous day?
thanks!
08/22/2021 at 8:53 PM #175953I don’t have that button! here my screen
08/22/2021 at 9:22 PM #175958Make lines 2-10 one line.
Remove AT from line 15.
Make lines 18-21 one line.
Make lines 26-29 one line.
Remove first SET from the last line.
08/22/2021 at 9:52 PM #17596008/22/2021 at 10:24 PM #175962Add a missing ENDIF at the end.
08/22/2021 at 10:37 PM #175963Thanks roberto you are a great guy, hope you are killing it with your trading. I still get an error at line 2 and 4 of missing characters:
If instead of setting a trail stop, I wanted to set a stop moving at the low of previous day every day, how would that be coded?
And if I wanted to close the position or take a partial after X days?
1234567891011121314151617181920// Conditions to enter long positionsIF NOT LongOnMarket AND c1 = close > close[1]*1.035 AND c2 = close[1] <= close [2]*1.02 AND c3 = close[2] <= close [3] AND c4 = EstimatedVolume > volume[1] AND c5 = average[7]/average[65]>=1.05 THENBUY 10 CONTRACTS AT MARKETENDIF// Stops and targets : Enter your protection stops and profit targets hereSET STOP LOSS LOWEST [0]// Conditions to exit long positionsIf LongOnMarket ANDclose >= POSITIONPRICE*(1+(LOWEST[0]-POSITIONPRICE)/POSITIONPRICE)*4)THENSELL 5 CONTRACTS AT MARKETENDIF// conditions to trail the restIf LongOnMarket AND close >= POSITIONPRICE*(1+(LOWEST[0]-POSITIONPRICE)/POSITIONPRICE)*4)THENSET STOP %TRAILING 5ENDIF08/23/2021 at 3:02 AM #175965Estimatedvolume can’t be used in strategies, it is reserved for screeners only. Remove it.
Stop loss:1SET STOP LOSS abs(TradePrice - low[1])To close after X (5 in my example) candles:
123If (barindex - tradeindex) = 5 and LongOnMarket thenSell at MarketEndif08/23/2021 at 7:16 AM #175968Sorry, for the Stop Loss on the previous Low, the correct line is this one with a pending order:
1SELL at Low[1] STOP08/23/2021 at 9:15 AM #175973What, estimated volume can’t be used in strategies?! that’s a fail.
Can I manually insert an estimate of the volume (for instance, if it’s the first hour multiply *4 or so on?). Or another more automatic way, like calculating the current time, the time the market closes, and then making an extrapolation? (I guess this is what estimated volume does…).
Even without the estimated volume, I keep getting a character missing on lines 1 and 3 of this part of the code! Any solution? I don’t see any problem with it.
123IF NOT LongOnMarket AND c1 = close > close[1]*1.035 AND c2 = close[1] <= close [2]*1.02 AND c3 = close[2] <= close [3] AND c5 = average[7]/average[65]>=1.05 THENBUY 10 CONTRACTS AT MARKETENDIFThanks again guys
08/23/2021 at 10:39 AM #175978You can add any value using variables (with a different name than keywords), such as MyEstimatedVol.
Post your complete code.
I suggest that you make separate conditions and assign them to variables, such as c1=…, C2=…, etc…
This will make it easier to check conditions for errors and your code will run faster and smoother.
08/23/2021 at 10:41 AM #175979not sure if this will help but I would normally write that like this:
1234567c1 = close > close[1]*1.035c2 = close[1] <= close [2]*1.02c3 = close[2] <= close [3]c5 = average[7]/average[65]>=1.05IF NOT LongOnMarket AND c1 AND c2 AND c3 AND c5 THENBUY 10 CONTRACTS AT MARKETENDIFor
123IF NOT LongOnMarket AND (close > close[1]*1.035) AND (close[1] <= close [2]*1.02) AND (close[2] <= close [3]) AND (average[7]/average[65]>=1.05) THENBUY 10 CONTRACTS AT MARKETENDIF(Roberto got in just before me!)
1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on