Add condition referencing last trade direction

Forums ProRealTime English forum ProOrder support Add condition referencing last trade direction

Viewing 4 posts - 1 through 4 (of 4 total)
  • #53328

     I would like one of the conditions in the algorithm to depend on the direction of the last trade. 

    An example for simplicity: IF some set of conditions are met AND the last trade was a short position THEN take a long position… and vise versa.

    I haven’t been able to find an easy solution to call the last trade direction, so any help would be greatly appreciated! 

    #53329

    You need to set a variable when you either go LONG or SHORT, so that it will later let you know if the last trade was going northwards or southwards. If trades are open not so frequently you might decide to reset the variable to ZERO after “n” candlesticks have elapsed. It’s up to you.

    Roberto

    1 user thanked author for this post.
    #220361

    Hi,

    I am using a solution like the above which works fine for last trade direction but not if the trade opens and closes within the same bar. In that circumstance the variable does not change because we are Not OnMarket at the close of the bar.

    I have tried various solutions but just can’t seem to nail it.

    Any suggestions would be much appreciated.

    Thanks, Matt

    #220364

    This snippet will do:

    it will only work when you do not accumulate trades.

    But you can also use these new instructions to tell Long from Short trades (https://www.prorealcode.com/documentation/shorttriggered/):

    N is the bar reference [1], [2], ec…  [0] is assumed by default and can be omitted.

     

    1 user thanked author for this post.
Viewing 4 posts - 1 through 4 (of 4 total)

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