Code problem with time conditions

Forums ProRealTime English forum ProOrder support Code problem with time conditions

Viewing 8 posts - 1 through 8 (of 8 total)
  • #62809

    Hi I got 2 questions about my code.

    1. I want to take entry between 17:20-17:30 if my signal i active, but it seems that the entry is in the next bar? It should be in the signal bar.

    2. I also want to do my exit between 17:20-17:30, is it possible to do a “noExitBeforeTime” and “noExitAfterTime”? The idea is to sell between 17:20-17:30 if the position is in profit. After 5 bars I will sell anyway.

    CodeProblem-1

    #62834

    ProOrder ALWAYS runs strategies when the signal bar closes and opens a trade, if conditions are met, afterwards, that’s why there’s one bar difference, though it may be just microseconds!  This is true as of the caurrent version, the new one in the works is said to behave differently.

    As for your 2nd question, to exit after n bars you may use the expression

    which returns the number of bars elapsed since the trade was started. If you want to add a condition to exit only if in profit you have to just check the current (closing) price and TradePrice as

    see line 15 at https://www.prorealcode.com/documentation/tradeprice/, where both condition are used to exit a Profitable trade after 5 bars have elapsed.

    1 user thanked author for this post.
    #62899

    Thanks!

    So I will allways miss the GAP to the next bar? This will happen often since I will trade daily timeframe. I got the version 10.3.

    And the same will be in point number 2, if I want to sell on the bar when stockmarket close at 17:30, the sell will be next morning?

    #62918

    So I will allways miss the GAP to the next bar? This will happen often since I will trade daily timeframe. I got the version 10.3. And the same will be in point number 2, if I want to sell on the bar when stockmarket close at 17:30, the sell will be next morning?

    Yes that’s how it behaves.

    #62940

    You could exit manually at 17:30 via the IG App on your phone then start your Daily TF Algo again later before you go to bed and before midnight?

    Ha … I just thought of another way … if you leave your PC / Laptop running it appears that you could set an Alert and an associated Trigger to sell / buy and then this will close your Algo. All external interference with an Algo will close it down!

    I’ve not tried about with date/ time so test it out and let us know how you get on?

    See attached
    GraHal

    1 user thanked author for this post.
    #71195

    Hi Thought my problem was related to this and so I added it here.

    I want to close a trade after 5 bars so wrote:

    However this closes every subsequent trade on the first bar. I’ve tried a once Trade = 1 after the close the trade instruction doesn’t work either.

    Any help with this would be appreciated

     

     

     

    #71199

    Found a solution

    This will close if c5 is in the sell conditions for a long trade

    #71247

    I’m glad that you found your solution Dymjohn.

    Can I ask you to please use the ‘Insert PRT Code’ button in future posts as it makes everything much more readable for others. I’ve tidied up your posts here for you.

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

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