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 1 year ago by JS.
-
-
06/07/2023 at 7:21 PM #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
06/08/2023 at 12:45 AM #215799Yes, 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.
06/08/2023 at 7:20 AM #215814Hi 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 :
12345678910111213141516171819202122232425262728JustTraded = 0If not OnMarket and not JustTraded then// Scenario 1 - set c01 condition for Entry.// [...]If c01 then// E.g. BuyJustTraded = 1endifendifIf not OnMarket and not JustTraded then// Scenario 2 - set c02 condition for Entry.// [...]If c02 then// E.g. BuyJustTraded = 1endifendifIf not OnMarket and not JustTraded then// Scenario 3 - set c03 condition for Entry.// [...]If c03 then// E.g. SellShortJustTraded = 1endifendifPay 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.
06/08/2023 at 8:41 AM #215819Hi 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 11234Contract = 1Tick = 1BUY 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?
1234Contract = 1Tick = 2BUY contract at HIGH[1] + Tick
- Scenario 3: Buy/Sell 4 ticks over the high or low of the highest/lowest of the last 5 candles
- Code: see below -> is this correct?
-
Scenario 31234Contract = 1Tick = 4BUY contract at HIGHEST[5] + Tick
I hope you understand what I mean….and I hope you can help me
06/08/2023 at 9:32 AM #215824All 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) :
1GraphOnPrice Highest[5](Close) as "Highest Close of last 5"06/08/2023 at 10:24 AM #215835Hi, 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
06/08/2023 at 3:39 PM #215866I 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.
06/09/2023 at 10:11 AM #215893Hi,
Yes, with a ‘tick’ I mean point.
So if I mean point then the instructions will be:
Scenario 1:
Contract = 1
Point = 1BUY contract at HIGH + Point
Scenario 2:Contract = 1Point= 2BUY contract at HIGH[1] + PointScenario 3:Contract = 1Point= 4BUY contract at Highest[5](High[1]) + PointIs this correct?
06/09/2023 at 10:45 AM #215895As Contract and Point are ‘PRT reserved terms’ it needs to be as below
123BUY 1 contract at HIGH[1] + 1*PointBUY 1 contract at Highest[5](High[1]) + 1*Point1 user thanked author for this post.
06/09/2023 at 4:16 PM #215923Hi 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.
-
AuthorPosts
Find exclusive trading pro-tools on