Forums › ProRealTime English forum › ProOrder support › Help to code basic stochastic strategy › Reply To: Help to code basic stochastic strategy
Apologies Vonasi, and thanks for moving the post to correct forum.
I have managed to create some simple code using the “Simplified Creation” tool, just to get familiar with the backtesting tool. Just entered fixed TP and SL points for now.
I am testing the strategy on the South Africa 40 Cash Index.
The very basic strategy is that when stochastic goes below a certain level, e.g. 20, price will typically continue in the same direction for a few more points (ie becoming more oversold). Also will play around with the code once it is working properly to test many different strategies just based on the stochastic indicator and different R:R.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
// Definition of code parameters DEFPARAM CumulateOrders = False // Cumulating positions deactivated // Conditions to enter long positions indicator1 = Stochastic[14,3](close) c1 = (indicator1 <= 20) IF c1 THEN SELLSHORT 1 CONTRACT AT MARKET ENDIF // Stops and targets SET STOP pLOSS 200 SET TARGET pPROFIT 200 |
For now my three challenges:
a. When I enter a “Spread” to be taken into account, the number of trades become significantly less, not sure why this is happening?
b. I would like to add some code to only allow trades during certain timeframes, e.g. when the ALSI market is open from 08:30 – 17:30 GMT+2
c. Need to add a reset level, otherwise it could open trades if TP or SL reached while stochastic is still below the entry level