Code help – Simple strategy

Forums ProRealTime English forum ProOrder support Code help – Simple strategy

  • This topic has 15 replies, 4 voices, and was last updated 5 years ago by avatarshug.
Viewing 15 posts - 1 through 15 (of 16 total)
  • #4595

    Hi guys,

    This one is driving me nuts. I’m trying to code a very simple strategy:

    “If close within 10%  of range – buy on open next day. Then sell on first profitable opening.”

    This is what I got so far:

    I got as far as to enter correctly, but I cant exit without at least a days delay. I seems that PRT doesnt work “in the moment”, it looks at an entire bar and takes action the next day. Is there a way to exit as it happens? In this case I want to get out as soon as we open with a win.

     

    #4597

    Hello Noren,

    You are right, each condition are tested only once at each new bar open. This Prorealtime engine behaviour will be soon changed to a whole new way to deal with it : each condition will be tested on every timeframe bars. From the one you are trading to the smaller one below it.

    What you can do here with your strategy is to simply test if the price goes up or down at each new bar. So if you are long and price has raised up, exit your position and vice-versa.

    #4600

    Hi Nicolas,

    I’m not following, how will that help me? Wouldnt I still get a one day delay with PRT’s behavior?

    Even if price goes up, it could still close below. I need to confirm that open above entry before I could do anything and exit immediately once that happens… Perhaps its just not possible without those engine changes…

    Cheers

     

    #4605

    It will help your strategy not to wait an entire day (if you are trading on a daily basis) to see what happened. The backtest engine will loop all timeframes from the daily one to the 1 minute one to test each of your strategy conditions.

    #4606

    Could you kindly provide a simple example to help me understand better?

    #4608

    While your strategy is running on a Daily timeframe (1 bar = 1 day = 24 hours), on backtest, all your conditions will be tested like this :

    Backtest of the X bar on Daily TF -> conditions tested on each 1 hour bar -> conditions spotted on the Nth bar of the day -> conditions tests on each minute of the Nth bar previously spotted -> Found the minute where the conditions occured -> Execute SL/TL/TRAILING or anything else on the prices of the bar -> Go on next Y bar on Daily TF -> and so on ..

    #4620

    That I understand, what I dont get is how the actual code for that would look like. I mean what does the code looks like where I check if the price is above entry and exit in the same bar?

    #4626

    Your code don’t have to be adapted to this future improvement of the backtest engine. Actually, if you want to deal with your orders, you can browse all the instructions available in the online prorealtime documentation, Probacktest specific, here : http://www.prorealcode.com/documentation/category/probacktest/

    Also, if you want to store your price entry whenever you enter the market, you just have to create new variables and store the open price. Then, make conditional loop for anything you want around this data.

    Hope, that I understand clearly your question 🙂

     

    #4657

    Nicolas I feel that there is a bit of a language barrier here 🙂

    I know that there is online documentation, i’ve read it, but i’m still stuck. Could you please provide an actual code example that implements what you are saying. That will allow me to study your solution in a different way.

    Cheers

    #4658

    Ok, please find below your strategy modified :

     

    #4660

    Great I will try take a closer look tomorrow. Thank you very much for your patience Nicolas!

     

    ps.

    Great site, it is much needed! Not a lot of help out there when it comes to PRT.

    #4663

    Thanks a lot Jerry. I count on you to spread the good news : “PRT SUPPORT? GO PROREALCODE.COM” 🙂

    #4684

    Great stuff Nicolas, works like a charm now, thanks!

    Yeah, you can definitely count on me spreading the word. I’m also here to stay  😉

    #70082

    Nicolas Hi

    I have just came across your code above, (the one you helped Jerry with), I’m no programmer but I thought it would have been simple to modify the same code for just sell trades, couldn’t be further from the truth. What my missing? Its not a massive code, could you share the same code for just sell trades? That would be great if you could. I’m in the process of learning the coding language and the platform most of my trading for the last 7 years is through cmc markets but i’m looking at joining I.G Index to get access to the prorealtime  platform.

    #70108

    Hi Shug, below might be the code for SellShort?

    Results for Long and Short attached on DAX @ 5 min TF  spread  = 2 on 10k bars only!

    I only did 5 min TF out of interest, the strategy (I believe? ) is for Daily TF?

     

     

     

Viewing 15 posts - 1 through 15 (of 16 total)

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