Trailing buy order
Forums › ProRealTime English forum › ProBuilder support › Trailing buy order
- This topic has 8 replies, 2 voices, and was last updated 8 years ago by absent1980.
-
-
06/26/2016 at 1:50 PM #9861
Hi everyone,
Just wondered if you could advise on few things.
- How to code trailing BUY orders based on a price difference from a previous order?
- How to code current remaining account balance or percentage from it?
Thanks.
06/27/2016 at 8:38 AM #9867Hello,
You can try these codes for trailing stop functions:
http://www.prorealcode.com/blog/learning/trailing-stop-max-favorable-execution-mfe/
http://www.prorealcode.com/blog/trading/complete-trailing-stop-code-function/
To retrieve the current balance of your account, you need first to set a variable with the balance amount at the launch of the algorithm, because it is not possible to get it with code. Then just add the strategy profit to it and you’ll get the current balance amount:
12initialbalance = 9500 //set it one time at script launchcurrentbalance = initialbalance + STRATEGYPROFIT06/29/2016 at 12:58 AM #9979Thank you, much appreciated.
06/29/2016 at 6:50 PM #9995I looked at some examples of cumulative orders but not entirely sure how to translate them into a buying order such as:
Buying 1st order at price x, 2nd order at price x + variable, 3d order at the price of a previous order + variable
There are examples for shares but there is no equivalent for spreadbetting where position expressed as £pp
Example:
12345DEFPARAM CumulateOrders = TrueIf CountOfPosition < 2 THENBuy 1 shares at 2 LimitBuy 1 shares at 3 LimitEndif06/29/2016 at 7:02 PM #9999You can find example of adding positions in the TRADEPRICE instruction page :
06/29/2016 at 9:15 PM #10004Tried suggested code but system constantly adds positions at stated interval, how to limit them to 3 ?
12345678IF c1 THENBUY Positionsize PERPOINT AT MARKETENDIFIf CountOfPosition < 2 thenENDIFIF BARINDEX-TRADEINDEX(1)>increment AND Close-TRADEPRICE(1)>increment*2 AND LongOnMarket THENBUY positionsize perpoint at marketENDIFThank you.
06/29/2016 at 9:39 PM #1000506/29/2016 at 10:26 PM #10006Done that. Still buying/selling orders continuously until exit. I need to limit them to 3 or 4 max. Any ideas? Thanks
06/30/2016 at 12:40 AM #10008Seems to be working now. Thank you for your advice.
-
AuthorPosts
Find exclusive trading pro-tools on