Trade execution in different scenarios

Forums ProRealTime English forum ProRealTime platform support Trade execution in different scenarios

  • This topic has 9 replies, 5 voices, and was last updated 10 months ago by avatarJS.
Viewing 10 posts - 1 through 10 (of 10 total)
  • #215781

    Hi,

    I want to enter the market with different scenarios, but I don’t whether that is possible, because I see often that a trade is being done ‘at market’.

    But is it also possible to trade the following scenarios:

    • Buy/Sell  1 tick over the high or low of the current candle
    • Buy/Sell  2 ticks over the high or low of the previous candle
    • Buy/Sell  4 ticks over the high or low of the highest/lowest of the last 5 candles
    #215799

    Yes, you can place multiple orders at MARKET, provided you use DEFPARAM CUMULATEORDERS=True at the beginning, as the platform has the control of the code.

    You can also place 2 or more pending orders, but, no matter whether you use DEFPARAM CUMULATEORDERS=True or DEFPARAM CUMULATEORDERS=False, all of them can be triggered as the platform has no more control of them once they are sent to the broker. The platform regains control of them at the closing of the candle at which time pending orders that have not been triggered are cancelled, but it can’t do anything with triggered orders, even if they are more than one.

     

    1 user thanked author for this post.
    #215814

    Hi Richard,

    Yes, you can do that all, and 1000+ scenario’s more.  As long as you realize that each scenario will cost you a certain number of lines of code. 🙂

    One thing should be key for you : make all work mutually exclusive or else it is going to be a mess.

    N.b.: Roberto assumed that you apply all the scenarios at the same time, hence that all take positions. I take it that that is not what you want.

    Example of how to go about with it :

    Pay attention to the fact that  a pending order (Limit or Stop) may not definitely imply JustTraded (the order may not be filled). You will see that in the next iteration (next call of your code when the current bar/candle finishes) by means of OnMarket being true or not.

    Have fun …

    1 user thanked author for this post.
    #215819

    Hi Peter, Roberto,

    As I read my description again, I realised that my description is not clear enough. Maybe scenario is not the correct word and it should be condition.

    I don’t to execute all the conditions in one code/script. I just want to know what is the code for the different condition so I can use it in different codes/scripts.

    For example:

    • Scenario 1: Buy/Sell  1 tick over the high or low of the current candle
    • Code: see below -> is this correct?

     

    • Scenario 2: Buy/Sell  2 ticks over the high or low of the previous candle
    • Code: see below -> is this correct?

       

    • Code: see below -> is this correct?

    I hope you understand what I mean….and I hope you can help me

     

     

    #215824

    All correct except for Highest needing a “designator”. https://www.prorealcode.com/documentation/highest/

    And of course take good care of what “tick” should be.

    You can use Graph and GraphOnPrice to check what’s happening. Example (not tested) :

     

     

    #215835
    JS

    Hi, I think that scenario 1 is not possible because in a “1 tick” time frame (it is actually not a time frame because ticks are not related to time) there is no “high” or “low”, the “tick”=open=high=low=close

    Scenario 2 is possible but then you need to properly refer to previous candle:

    If Close > High[1] then

    Buy 1 contract at Market

    EndIf

    Use a time frame of 2 ticks here.

    Scenario 3 is also possible with the proper refer:

    If Close > Highest[5](High[1]) then

    Buy 1 contract at Market

    EndIf

    Use a time frame of 4 ticks here

    #215866

    I think that Richard uses the word “tick” to refer to a point or a pip. See first post. 🙂

    1 user thanked author for this post.
    #215893

    Hi,

    Yes, with a ‘tick’ I mean point.

    So if I mean point then the instructions will be:

    Scenario 1:

    Contract = 1
    Point = 1

    BUY contract at HIGH + Point

     

    Scenario 2:
    Contract = 1
    Point= 2
    BUY contract at HIGH[1] + Point
    Scenario 3:
    Contract = 1
    Point= 4
    BUY contract at Highest[5](High[1]) + Point

    Is this correct?

     

    #215895

    As Contract and Point are ‘PRT reserved terms’ it needs to be as below

     

    1 user thanked author for this post.
    #215923
    JS

    Hi Richard,

    When the “ticks” change to “pips”… 😉

    Scenario 1.  Is not possible because the “High” and “Low” are not final until the candle is closed…

    Scenario 2.

    Buy 1 contract at (High[1] + 2 * pipsize) STOP

    SellShort 1 contract at (Low[1] – 2 * pipsize) STOP

    Scenario 3.

    Buy 1 contract at (Highest[5](High[1]) + 4 * pipsize) STOP

    SellShort 1 contract at (Lowest[5](Low[1]) – 4 * pipsize) STOP

    All these orders are “pending” orders…

    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