Stopping second trade if first completes quickly

Forums ProRealTime English forum ProOrder support Stopping second trade if first completes quickly

Viewing 10 posts - 1 through 10 (of 10 total)
  • #96535

    Most of my strategies are for Wall Street, which can move very quickly. This means that sometimes a trade is triggered and completed quickly, sometimes within the time period I allow for a trade to trigger. I can’t seem to find a way to stop a second (or sometimes third) trade from setting up.

     

    Eg After a hammer, I might allow 3 candles for a trade to trigger. Sometimes the trade will trigger and reach target within the first candle, but the conditions eg a hammer within the last 3 candles is still the case, so a second trade is now set up.

     

    I’ve tried using ” Not Onmarket” but can’t seem to get it working how I’d like it to ie a maximum of one trade per set up.

     

    I’m sure there is a very simple way of doing this, but I can’t seem to work it out, so any help would be much appreciated.

     

    Many thanks in advance.

    #96536

    When the pattern is detected set a variable, say FLAG=1.

    Add it to your conditions to enter a trade.

    Clear that variable when 3, or whatever number you prefer, bars have elapsed or when you are OnMarket.

    Should your trade enter and end within the same bar without updating the OnMarket status, you need to check if STRATEGYPROFIT is any different from STRATEGYPROFIT[1],  if it is then a trade was entered and exited so you can clear the above mentioned variable.

    1 user thanked author for this post.
    #96539

    Many thanks for your prompt reply.

    I have already tried doing something along these lines, but without success so far. I’ll persevere, and maybe add the code here if I still can’t get it to work.

    #96540

    Sorry, perhaps I should add, I have tried using “Not Onmarket”, but the problem isn’t that it enters a second trade at the same time, but simply once I’m not longer “OnMarket” (ie when the first trade is finished), then a second trade may be entered because I’m no longer in a trade.

    I don’t know how to use being “OnMarket” to keep the Flag at 0 when I’m no longer “OnMarket”, as I’m just using if-then-endif conditions to set up the trades.

    #96541

    Post your code, please.

    #96548

    I appreciate it’s not very elegant; it was originally just for an indicator but has converted into automated trading quite well, apart from this issue with second trades.

    #96570

    The 2nd trade Issue could be due to below as it is always going to be true?

    Line 118 and Line 134

     

    #96571

    You already have two flags: MyStopBuy and MyStopSell.

    To reset them when OnMarket, add these lines at line 6:

    The line activated by ELSE has the purpose of helping you detect a trade that has been triggered and closed within the same bar.

    Below the above snippet of code add this one to clear the two variables in case a trade opened and closed within the same bar:

    You check that you are not OnMarket now and were not the previous bar, yet STRATEGYPROFIT has changed.

    1 user thanked author for this post.
    #96630

    Many thanks for the help.

     

    I’ve removed that condition from lines 118 and 134, and have added in the 2 snippets of code, but the amended code will still trigger a second trade if the original trade opens and closes in the same candle.

    #96641

    You shouldn’t have removed those two conditions, otherwise the snippets of code are useless.

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

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