New to pro trader and need help writing a simple algo
Forums › ProRealTime English forum › ProOrder support › New to pro trader and need help writing a simple algo
- This topic has 7 replies, 3 voices, and was last updated 3 years ago by robertogozzi.
-
-
05/13/2020 at 3:31 AM #131414
I am fairly new to pro trader real time. I need help writing the following algos:
Algo 1: Go long
- For all stock instruments, check if today’s opening price is greater than yesterday’s closing price by at least 1%, if so proceed to step 2
- Check if current price is greater than today’s opening price by at least 3%, if so execute a long position
Algo 2: Go short
- For all stock instruments, check if today’s opening price is less than yesterday’s closing price by at least 1%, if so proceed to step 2
- Check if current price is less than today’s opening price by at least 3%, if so execute a short position
Once I have this algo defined, how do I run a backtest?
Thanks for your help
05/13/2020 at 7:11 AM #131427There you go (not tested):
123456789101112131415DEFPARAM CumulateOrders = falseL1 = open > (close[1] * 1.01)S1 = open < (close[1] * 0.99)L2 = close > (open * 1.03)S2 = close < (open * 0.97)Lcond = L1 and L2Scond = S1 and S2If Lcond and not LongOnMarket thenBuy 1 contract at marketEndifIf Scond and not ShortOnMarket thenSellshort 1 contract at marketEndifSet Stop pLoss 50Set Target pProfit 100this code will do a Stop & Reverse, if needed.
If you don’t want this then replace LONGONMARKET and SHORTONMARKET with ONMARKET.
05/13/2020 at 7:18 AM #131428I’m a new bod also, but you can learn a lot from the free videos, https://www.prorealcode.com/courses/training-program-introduction-programming-prorealtime/ and there’s a 2nd course payable but likely worth a look… this will get you into the basics.
05/13/2020 at 7:22 AM #131429To backtest it, just set the backtest period after setting enough units for your TF, capital, spread and commissions if any, then click on the start backtest button.
You may also want to tick the tick-by-tick option.
On YouTube you’ll find a ProRealTime channel with many tutorials.
05/13/2020 at 11:38 PM #131576This is great thank you guys for the prompt reply! I want to develop a trading strategy that is instrument agnostic. So for the backtesting how do I apply the algorithm written above to the various markets like FTSE 100, FTSE AIM etc. Can I only backtest one instrument at a time or can I apply it to the entire market?
As I am not familiar with the abilities or limitations of the Pro Trade system. Can you also clarify whether algorithms can be applied to either individual securities or an entire market similar to how the screener works?
I have accessed the algorithm tool and it looks as though I can only apply it to one security at a time, please kindly clarify
Thanks again for you help
05/13/2020 at 11:49 PM #131577Version 10.3 (currently the one supported by IG) only allows 1 instrument at a time.
Version 11.x (supported by PRT and IB, maybe BINCK as well) allows up to 3 different instruments to be backtested at any one time.
You will have to duplicate your strategy and name it differently for each instrument.
05/13/2020 at 11:53 PM #131578Thanks Roberto for your help
As I am not familiar with the abilities or limitations of the Pro Trade system. Can you also clarify whether algorithms can be applied to either individual securities or an entire market similar to how the screener works?
I have accessed the algorithm tool and it looks as though I can only apply it to one security at a time, please kindly clarify
05/14/2020 at 12:08 AM #131579No, algortithms can be applied only to one instrument with v10.3 (see info on the Help menu) and 3 instruments on v11.x.
If you have v11.x (premium) you can add up to 3 different strategies to your backtest (see atteched pic).
In any case, whatever version you have you can launch multiple instances of ProBackTest, so on v10.3 you can backtest up to 1, 2, 3 strategies at a time, while on v11.x yoy can backtest up to 3, 6, 9 different strategies at a time.
PRT have a YouTube channel with many video tutorials about the many features and tools they have.
-
AuthorPosts
Find exclusive trading pro-tools on