Order placing in code
Forums › ProRealTime English forum › ProOrder support › Order placing in code
- This topic has 8 replies, 2 voices, and was last updated 4 years ago by
Lialh.
-
-
07/07/2020 at 12:18 PM #138622
Hi
Once you conditions have been met is it possible to place an order to trigger at a predetermined point NOT at market.
i.e ALL the conditions are met but your order would be X pips higher than the current price at your trigger point Or when c1 and C2 and c3 and c4 are met. So then effectively placing an order etc ?
07/07/2020 at 2:20 PM #138640Yes, you can use pending orders. Use STOP pending orders when the entry price il worse than current price, LIMIT pending orders when it’s better (higher if yiu sell or lower if you buy):
123456// Long tradesBUY 1 CONTRACT AT MyEntryPrice STOP //current price is lowerBUY 1 CONTRACT AT MyEntryPrice LIMIT //current price is higher// Short tradesSELLSHORT 1 CONTRACT AT MyEntryPrice STOP //current price is higherSELLSHORT 1 CONTRACT AT MyEntryPrice LIMIT //current price is lowerBe warned that pending orders expire after one bar, so you need to place then again next bar if still needed.
Set TP & SL as usual.
07/07/2020 at 2:55 PM #138647Thanks Roberto ,
So if i envisaged myentryprice may not be hit for 5 or more bars after initial conditions were me how would be best to cope with that ?
07/07/2020 at 3:18 PM #138650If your conditions are met keep placing them again and again, bar after bar, until those conditions are no more met (or orders are triggered and you do not want to enter again until NEW conditions are met).
07/07/2020 at 3:34 PM #138651Once the conditions are met for placing an order at myentrypoint – i want the order to stay current until the entry point is achieved. The initial conditions to trigger myentrypoint will not be met going forward from the point of order as these are historical conditions to trigger my entry point.
When you say keep placing the order bar after bar how is this coded to express the order is valid until achieved ? Regardless of the initial conditions to initially achieve the first placement of myentrypoint.
07/07/2020 at 4:00 PM #138652There you go:
123If MyConditions AND Not OnMarket THEN //make sure your conditions are still met to place a pending orderBUY 1 CONTRACT AT MyEntryPrice STOP //or LIMITENDIFMyConditions can be any condition or combination of conditions linked either with AND or OR.
1 user thanked author for this post.
06/22/2021 at 1:18 PM #172140There you go:
Hi Roberto,Thanks for the below (and to SlowlySlowly for asking).I am still struggling though as the code doesn’t read properly.Essentially, what I need is to find and ‘set the order price’ at a high of that particular bar that the other conditions are met, and then to keep that order in place for the next 10 bars until it triggers.I can’t seem to still get that right in the code though.Do you perhaps have any ideas on how to do that? I have used your code below, but I think that I am doing something wrong though.Thanks.‘insert PRT code’123If MyConditions AND Not OnMarket THEN //make sure your conditions are still met to place a pending orderBUY 1 CONTRACT AT MyEntryPrice STOP //or LIMITENDIFMyConditions can be any condition or combination of conditions linked either with AND or OR.
06/22/2021 at 2:28 PM #172142There you go:
123456789101112131415161718192021222324252627282930313233343536373839404142DEFPARAM CumulateOrders = FALSEONCE CondL = 0ONCE Count = 0ONCE Entry = 0ONCE Dist = 10 //minimum distance from current price required by the broker// to place pending orders//reset variables when on marketIF OnMarket THENCondL = 0Count = 0Entry = 0ENDIF//increnment countIF Count > 0 THENCount = Count + 1//reset count and conditions after 10 bars have elapsedIF Count > 10 THENCount = 0CondL = 0Entry = 0ENDIFENDIF// LONG conditionIF close crosses over Average[200] thenCondL = 1Count = 1Entry = highENDIF// entryIF Entry > 0 AND Not OnMarket THENIF (close + Dist) < Entry THENBUY 1 Contract AT Entry STOPELSIF (close - Dist) > Entry THENBUY 1 Contract AT Entry LIMITELSEBUY 1 Contract AT MarketENDIFENDIF// exitIF close crosses under Average[200] and LongOnMarket thensell at marketENDIF06/23/2021 at 8:50 AM #172176 -
AuthorPosts
Find exclusive trading pro-tools on