CumulateOrders is not working ?
Forums › ProRealTime English forum › ProOrder support › CumulateOrders is not working ?
- This topic has 13 replies, 4 voices, and was last updated 5 years ago by Vonasi.
-
-
08/13/2018 at 8:31 PM #78106
Hi folks,
A. I would like that my system accumulates positions every time my conditions are met (this can happen on two consecutive candles for instance). I’m using the following code as parameter but it is not working
1DEFPARAM CumulateOrders=TrueEvery time I am in a position and the conditions are met again, the system doesn’t buy a new position.
B. My exit rules are either stop loss at 2% below low of candle of entrance or once a target profit of 15% is reached. Because of that, I obviously don’t want the system to accumulate positions and sell those altogether if I get 15% return on the first shares bought (before accumulation) ot if we reach the stop-loss level of the first shares bought for instance. Is the system treating every buy as a separate “bundle” and consequently only sells a bundle if conditions are met for this bundle ?
Thanks for your help !!
08/13/2018 at 9:30 PM #78109Did you set the max number of contracts to something greater than 1 at launch time?
ProBackTest doesn’ t care about it and works correctly, while ProOrder DOES need to know the max number of contracts it is allowed to trade.
08/13/2018 at 9:43 PM #7811108/13/2018 at 9:55 PM #78113Try replacing 10,000 with 1, or 100,000 with 100,000,000.
08/14/2018 at 4:48 PM #7815908/14/2018 at 5:14 PM #78162You may be best to share the code as without it we are just guessing. You might just have an IF ONMARKET in the wrong place for all we know. It must be a coding error as cumulate orders works fine in all the codes I test it in.
08/14/2018 at 5:22 PM #78164every time the signal is met.
Are you sure the signal is met multiple times in your strategy? Try to GRAPH the variable that trigger the signal.
08/14/2018 at 6:50 PM #78177Here is the full code. It is a code for going short (and not long as I said for comfort reasons in my previous messages).
C4, C5 and C6 are to define the type of candle I’m looking for (length of shadows, length of candle as % of close price, etc.).
In order to check what Prorealtest does, I took a stock and noted down on paper every candle that respect my rules. This code shorts the right candles except when I’m already in short position. If two following candles respect my rules, Probacktest always shorts on the first one and never on the second. If it was a mistake in my code, Prorealtest would sometimes short on the first candle, sometimes on the second.
12345678910111213141516171819202122232425262728293031323334//ParametersDEFPARAM CumulateOrders=TrueDEFPARAM Preloadbars=30// Conditions to enter short positionsindicator1=average[20](close)indicator2=indicator1[1]c1= indicator1<indicator2indicator3=indicator1[8]indicator4=indicator1[9]c2=indicator3<indicator4c3=high>high[2]queuesouscoeur=min(open,close)-lowqueuesouscoeurenpctrange=queuesouscoeur/(high-low)c4= queuesouscoeurenpctrange<0.27queuesurcoeur=high-max(open,close)queuesurcoeurenpctrange=queuesurcoeur/(high-low)c5= queuesurcoeurenpctrange>0.45queuesurcoeur= high-max(open,close)queuesurcoeurenpctcloture= queuesurcoeur/closec6= queuesurcoeurenpctcloture>0.035IF NOT shortonmarket AND c1 AND c2 AND c3 AND c4 AND c5 AND c6 THENSELLSHORT 10000 CASH AT MARKETsl=high*1.02Buy at sl stopENDIFIF shortonmarket thenExitshort at sl stopendif// Stops and targetsSET TARGET %PROFIT 1508/14/2018 at 6:53 PM #7817808/14/2018 at 7:03 PM #78179May I come back to the second point of my first post as it seems that the system sells all positions together and doesn’t respect the stop loss rule of the first short position taken. It seems to decide to sell everything based on the stop loss level or 15% target profit as calculated on the second candle of entry.
B. My exit rules are either stop loss at 2% (above) below low of candle of entrance or once a target profit of 15% is reached. Because of that, I obviously don’t want the system to accumulate positions and sell those altogether if I get 15% return on the first shares bought (before accumulation) ot if we reach the stop-loss level of the first shares bought for instance. Is the system treating every buy as a separate “bundle” and consequently only sells a bundle if conditions are met for this bundle ?
08/14/2018 at 7:05 PM #7818008/14/2018 at 7:09 PM #7818108/14/2018 at 7:20 PM #78182Thank you, I replaced Buy and put Exitshort instead.
You see the full code. I don’t know what you mean by pending orders, I never used that.I see on the chart that on a given moment, while the system did accumulate positions as wanted, Prorealtest didn’t respect my stoploss rule of 2% above the high of the first candle of entry and sold all accumulated positions at 15% profit calculated on the second candle of entry. He should have sold my first short position at stop loss level whereas I still would hold the second short position (for which its stop loss level was never reached).
08/15/2018 at 8:33 AM #78223If the last bit of your code is now like this:
123456789101112IF c1 AND c2 AND c3 AND c4 AND c5 AND c6 THENSELLSHORT 10000 CASH AT MARKETsl=high*1.02Exitshort at sl stopENDIFIF shortonmarket thenExitshort at sl stopendif// Stops and targetsSET TARGET %PROFIT 15…then every time the entry conditions are met then your SL value will be changed.
The following is a pending order:
1Exitshort at sl stopIt places an order on the market to close all trades at whatever the value of SL is. STOP is at an inferior price and LIMIT is at a superior price.
There is no way to have different values of stop loss or take profit for different positions. You can either exit all trades at a certain price with a pending order or use the SET instruction to place orders a set distance from each individual position but every time you change the value it changes the distance for all open trades.
With partial closure you could make this work by selling parts of your position at different levels but although partial closure works in back testing it is not yet possible to forward test using it in demo. I’m not sure if it works in live trading but then again I would never run anything live that has not been forward tested so that is irrelevant anyway.
-
AuthorPosts
Find exclusive trading pro-tools on