Trade execution in different scenarios

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #215781 quote
    RichardVeen
    Participant
    Junior

    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 quote
    robertogozzi
    Moderator
    Master

    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.

    RichardVeen thanked this post
    #215814 quote
    PeterSt
    Participant
    Master

    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 :

    JustTraded = 0
    
    If not OnMarket and not JustTraded then
      // Scenario 1 - set c01 condition for Entry.
      // [...]
      If c01 then
        // E.g. Buy 
        JustTraded = 1
      endif
    endif
    
    If not OnMarket and not JustTraded then
      // Scenario 2 - set c02 condition for Entry.
      // [...]
      If c02 then
        // E.g. Buy 
        JustTraded = 1
      endif
    endif
    
    If not OnMarket and not JustTraded then
      // Scenario 3 - set c03 condition for Entry.
      // [...]
      If c03 then
        // E.g. SellShort 
        JustTraded = 1
      endif
    endif
    

    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 …

    RichardVeen thanked this post
    #215819 quote
    RichardVeen
    Participant
    Junior

    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?
    Contract = 1 
    Tick = 1 
    
    BUY contract at HIGH + Tick

     

    • Scenario 2: Buy/Sell  2 ticks over the high or low of the previous candle
    • Code: see below -> is this correct?
      Contract = 1
      Tick = 2
      
      BUY contract at HIGH[1] + Tick

       

    • Code: see below -> is this correct?
    • Contract = 1 
      Tick = 4
      
      BUY contract at HIGHEST[5] + Tick

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

    #215824 quote
    PeterSt
    Participant
    Master

    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) :

    GraphOnPrice Highest[5](Close) as "Highest Close of last 5"
    #215835 quote
    JS
    Participant
    Senior
    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 quote
    PeterSt
    Participant
    Master
    I think that Richard uses the word “tick” to refer to a point or a pip. See first post. 🙂
    RichardVeen thanked this post
    #215893 quote
    RichardVeen
    Participant
    Junior
    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 quote
    GraHal
    Participant
    Master
    As Contract and Point are ‘PRT reserved terms’ it needs to be as below
    BUY 1 contract at HIGH[1] + 1*Point
    
    BUY 1 contract at Highest[5](High[1]) + 1*Point
    RichardVeen thanked this post
    #215923 quote
    JS
    Participant
    Senior

    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…

    RichardVeen thanked this post
Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.

Trade execution in different scenarios


Platform Support: Charts, Data & Broker Setup

New Reply
Author
Summary

This topic contains 9 replies,
has 5 voices, and was last updated by JS
2 years, 8 months ago.

Topic Details
Forum: Platform Support: Charts, Data & Broker Setup
Language: English
Started: 06/07/2023
Status: Active
Attachments: No files
Logo Logo
Loading...