Help to code basic stochastic strategy

Forums ProRealTime English forum ProOrder support Help to code basic stochastic strategy

Viewing 9 posts - 1 through 9 (of 9 total)
  • #85799

    Hi from complete ProRealTime noob. Have started watching the training videos and hope to contribute in the near future.

    Could someone assist with the code for a very simply strategy to play around with.

    Enter: When stochastics reaches a certain level, e.g. 95

    Exit: TP 1 x atr and SL 1 x atr

    #85801

    Welcome to the forums.

    Please try to post in the correct forum with future topics. I have moved your post to the ProOrder forums which is the best place to find strategy coding solutions.

    #85809

    A little more detail on the exact strategy might be helpful to save someone the time writing something that is not what you exactly have in mind. Stochastic settings, average true range period, single position or multiple positions held, do you want the ATR stop and target to be adjusted at each bar closure or fixed at the levels when a trade is opened etc etc?

    #85811

    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.

    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

    #85814

    Maybe the above is something like what you want? It resets to trade again when the stochastic returns over 20.

    I would suggest using GRAPH to show the TIME and/or C2 to double check it is trading when you actually want it to.

    I have put in an ATR stop which will change the stop and target levels at each bar close. Move lines 13 to 16 to within your IF THEN SELLSHORT ENDIF section of code to have it fixed at the ATR at the time of the conditions being met.

    I’m not sure why the spread should effect your trade quantity.

    1 user thanked author for this post.
    #85815

    When I enter a “Spread”

    where are you entering “Spread” … in your code (post an example) or in the box that gets ticked and is called Spread?

    #85817

    I am ticking the box “Spread” and entering the typical point spread in this market

    #85818

    Thanks a lot for the help Vonasi!

    #85819

    Thanks a lot for the help Vonasi!

    No problem – I hope it helps.

    Just click on the ‘Thanks’ button in any future posts where you want to thank someone and it will be highlighted on their post and give them a warm fuzzy glow inside! 🙂

    2 users thanked author for this post.
Viewing 9 posts - 1 through 9 (of 9 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login