Limiting accumulating orders & Fuse

Forums ProRealTime English forum ProOrder support Limiting accumulating orders & Fuse

Viewing 13 posts - 1 through 13 (of 13 total)
  • #25746

    Hi all. This is following on from a discussion I had with @Raul. I thought I would post it as a new topic to get wider views. Two questions which could be of use/interest to all:

    1)  When we use the following in our strategies

     

     

    …is it possible to limit the number of orders that can be accumulated in a day? I’m thinking about minimising the risk of allowing orders to “uncontrollably” accumulate, for example in the instance of an unexpected macro event or natural disaster. It would be especially useful on fx strategies overnight.  For example, if a strategy on average returns 3 trades a day I may want to limit number of trades in 1 day to let’s say 10. If you have wide stops (which occasionally I do) it is possible to accumulate orders without getting stopped out or the fuse(s) being triggered and then potentially getting a big loss at the end of the trading period when all positions are closed.

    2) I have seen the suggestions for fuses on this site, in particular from https://www.prorealcode.com/documentation/quit/  and https://www.prorealcode.com/blog/learning/max-profit-loss-day-trading-strategy/.

    Is it possible to have a “real time” fuse which works out your P&L midway during a trade(s) instead of when the position(s) is(are) closed. It can then stop a strategy if the loss is greater than x no matter how many positions are open. This is connected (but separate) to the first question.

    In an ideal world you could have a situation where you could accumulate orders up to a maximum amount AND have a real time fuse for added safety.

     

    Thanks

    #25833
    1. About your first question, here is a code snippet that should meet your requirements (forum coding, not tested):

    2. I think you already have what needed in this blog article? : https://www.prorealcode.com/blog/learning/max-profit-loss-day-trading-strategy/

    2 users thanked author for this post.
    #25839

    Thanks Nicolas. I’ll look and test that bit of code. Quick query: I want to be able to accumulate orders (but up to the max of 10 in this example). Should the code be “defparam cumulateorders=false”. I’m just checking. I would have thought it should be “true” but with the rest of the code to limit it at 10 orders.

    With regards to question 2, will the code calculate the max loss of the trading day (which is what I’m interested in) real time and mid way through a trade? I thought it only did this once a position was closed. Again just checking.

    Thanks again for taking the time to take a look. Really appreciated.

    #25848

    Oh my bad, of course you have to set cumulateorders to “true”, good point!

    and no .. as you know it already, proorder will only read once the code in a bar, we have to wait for MTF support to come in a near future.

    1 user thanked author for this post.
    #25850

    No worries. That’s nothing compared to the mistakes I make.

    Just so I’m clear, the code snippet in the fuse will recalculate at the end of each bar (completely understand this bit) and will take into account open positions? I know it is not strictly “real time” but it is as close as we can get at the moment. Therefore you don’t have to wait for your stop to be hit and close the position?

    #25862

    No, this code snippet will not take into account the current open positions..

    You could give it a try with this one instead:

    Again, not tested, forum coding!

     

    1 user thanked author for this post.
    #25993

     

    2 users thanked author for this post.
    #26294

    Hi Jonjon

    Whilst it looks you have a solution, it’s possibly worth mentioning that when you set an autotrade up – the figure that you put in the box (see picture) will also limit the number of positions.

    If you have set your coding to 10 but only enter 2 in this box – it will limit your accumulated trades to “2” etc…

    #26297

    Thanks Big Hug. I forgot about that. I may use it in addition to one of the other solutions above for extra safety

    #135891

    How to limit daily loss on % of account and no operate to Next day???

    Need Code.

    Thanks!

    #135892

    No operate Before next day

    #208121

    Hello,

    lastindex <> tradeindex…puis quelques lignes plus bas lastindex = tradeindex ?! Pour moi qui ne suis pas codeur ni informaticien c’est assez déroutant. J’ai quelques rudiments en code et je peux programmer des petites choses simples avec PRT, mais là c’est ce genre de “logique” sur laquelle je bloque et qui fait que je n’avance pas. je pensais suivre en intégralité la formation proposée ici par Nicolas. J’espère que ces questions sont abordées en détail pour bien comprendre, car il faut se mettre à la place d’un non initié, c’est totalement contre intuitif. En effet, en maths à l’école on apprend depuis toujours que A = A + X n’est possible que si X = 0. Merci

    Hello, lastindex <> tradeindex…then a few lines down lastindex = tradeindex?! For me, who am not a coder or a computer scientist, it’s quite confusing. I have some coding basics and I can program simple little things with PRT, but it’s this kind of “logic” that I’m stuck on and that’s stopping me moving forward. I thought I would follow the entire training offered here by Nicolas. I hope that these questions are addressed in detail to fully understand, because you have to put yourself in the shoes of an uninitiated person, it is totally counter-intuitive. Indeed, in math at school we have always learned that A = A + X is only possible if X = 0. Thank you

    #208148

    @Reg7

    Only post in the language of the forum that you are posting in. For example English only in the English speaking forums and French only in the French speaking forums.

    Thank you 🙂

     

Viewing 13 posts - 1 through 13 (of 13 total)

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