Close position when new candle

Forums ProRealTime English forum ProBuilder support Close position when new candle

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

    Hi again

    I have watched tutorials but I cant figure out how the code is for closing a position after a candle when a new candle begins. Please can someone help me with that.

    #147907

    Simply add these lines at the beginning of your code, just after DEFPARAM’s:

    when you are not OnMarket they are ignored, otherwise they will close any trade opened the previous candle.

     

    1 user thanked author for this post.
    #147910

    Is it possible too close position after X sec or X min?

    #147913

    You can only count bars, read https://www.prorealcode.com/topic/define-a-time-stop/#post-147903.

    If you are using a minute or second TF, yes it’s possible.

     

    #147916

    You are the best!

    But in a one minute TF I cant close a postion after 50 s? In that case i need to work with multiple timeframes?

    #147918

    Yes, “Second” is the smallest TF (and tick isn’t possible yet..)

    1 user thanked author for this post.
    #147921

    But if I am in a 1 minute TF I cant define it too stop after x secs?

    #147922

    But if I am in a 1 minute TF I cant define it too stop after x secs?

    Yes, you can do it

    1 user thanked author for this post.
    #147923

    How do I write that code? I am in 1m TF and want it to stop after 50s.

    #147936

    There you go (run it from a 1-second TF):

    line 8 checks for MySecond being 50 or greater, since it may happen not to have that candle on such a small TF.

    Searching this forum for the words MTF and Multi Time Frame will return many links to examples, documentations, blogs and many topics.

     

    1 user thanked author for this post.
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