System won't take extra new positions?
Forums › ProRealTime English forum › ProOrder support › System won't take extra new positions?
- This topic has 14 replies, 3 voices, and was last updated 6 years ago by
Bard.
-
-
08/09/2017 at 4:22 PM #42813
Hi
Can anyone figure out why the code to increase the number of positions up to a max of 3 positions (based on 30 tic increases per position) does not work?
£/$ 1 Hour — 3.8 tic spread. Date: 01/01/17 to 01/06/17.121IF Close-TRADEPRICE(1)>30 AND LongOnMarket AND COUNTOFPOSITION = 1 THEN...I’ve simplified the system to the point where there are no other criteria for extra positions (#2 and #3) other than an increase of 30 tics from the last position taken. When the market moves eg over 50 tics no other extra position (#2) is taken?
Even changing/reducing the tic move required in the code from to Close-TRADEPRICE(1)>30 to Close-TRADEPRICE(1)>10 and also changing Close-TRADEPRICE(1)>60 to Close-TRADEPRICE(1)>20 still does not result in any extra positions being taken after a 10 or 20 tic increase/decrease in price? Please see screenshot with altered (from 30 tics moves) 10 tic and 20 tic moves not being taken.
Thanks for any help,
Cheers
BardPyramid Positions1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798// Definition of code parametersDEFPARAM CumulateOrders = TRUE // Cumulating positions deactivated// Conditions to enter long positionsindicator1, ignored = CALL "Ehler's Univ Osc SuperSmoother"c1 = (indicator1 CROSSES OVER -0.8)IF Not LongOnMarket AND c1 THENBUY 10 PERPOINT AT MARKETENDIF// Conditions to enter extra long positions//second orderIF Close-TRADEPRICE(1)>30 AND LongOnMarket AND COUNTOFPOSITION = 1 THENBUY 10 PERPOINT AT MARKETENDIF//third orderIF Close-TRADEPRICE(1)>60 AND LongOnMarket AND COUNTOFPOSITION = 2 THENBUY 10 PERPOINT AT MARKETENDIF// Conditions to enter short positionsindicator1, ignored = CALL "Ehler's Univ Osc SuperSmoother"c2 = (indicator1 CROSSES UNDER 0.8)IF NOT ShortOnMarket AND c2 THENSELLSHORT 10 PERPOINT AT MARKETENDIF// Conditions to enter extra short positions//second orderIF TRADEPRICE(1)-Close>30 AND ShortOnMarket AND COUNTOFPOSITION = 1 THENSELLSHORT 10 PERPOINT AT MARKETENDIF//third orderIF TRADEPRICE(1)-Close>60 AND ShortOnMarket AND COUNTOFPOSITION = 2 THENSELLSHORT 10 CONTRACTS AT MARKETENDIF//---------------------------------------------------------------------------------------------------////Function : Choppiness Index//p= 21 -- also use 100//MaxHi=Highest[p](High)///MinLo=lowest[p](low)//chop=100 * LOG( SUMMATION[p](AverageTrueRange[1](close))/log(10) / ( MaxHi - MinLo)) / (LOG(p)/log(10))//return chop as "Choppiness Index"//Function : Ehler's Univ Osc SuperSmootherbandedge= 50 //25whitenoise= (Close - Close[2])/2if barindex>bandedge then// super smoother filtera1= Exp(-1.414 * 3.14159 / bandedge)b1= 2*a1 * Cos(1.414*180 /bandedge)c2= b1c3= -a1 * a1c1= 1 - c2 - c3filt= c1 * (whitenoise + whitenoise[1])/2 + c2*filt[1] + c3*filt[1]filt1 = filtif ABS(filt1)>pk[1] thenpk = ABS(filt1)elsepk = 0.991 * pk[1]endifif pk=0 thendenom = -1elsedenom = pkendifif denom = -1 thenresult = result[1]elseresult = filt1/pkendifendif//RETURN result COLOURED(66,66,255) as "Universal Oscillator", 0 as "0"08/09/2017 at 8:56 PM #42831Hi,
I’m just in forum quick reading mode, haven’t tried the code, but at first glance, your picture shows GBPUSD, and your code shows IF TRADEPRICE(1)–Close>30 but it doesn’t feel like the forex pair can jump a full 30 between your close and tradeprice(1), in other words let’s say your tradeprice(1) was 1.3 on gbpusd it won’t jump to 31.3
So I guess either you wanted 30 ticks (tick size is 0.00001 for this one) and could try to replace your 30 by 30*ticksize, or maybe you rather wanted 30 pips (pipsize is 0.0001 which is different from the ticksize) and could try to replace your 30 by 30*pipsize
08/09/2017 at 10:29 PM #4283608/11/2017 at 1:00 PM #43027Thanks Noobywan and Nicolas,
So the code above is still incorrect? D’oh! I added “cumulative orders,” although without adding a “count of positions” code it just takes a trade regardless of no actual crossing of the 0.8 / -0.8 Oscillator threshold.
So then the “count of positions” and “if on market” code was then added but the system took long trades at lower prices than the original opening positions defying the >30 ticks requirement for the 2nd and 3rd positions. It then took 4 positions instead of the maximum of 3. Changing to 30*pipsize or 30*ticksize didn’t fix it.
If the “if on market” code is not added to the original 1st position which needs to cross the 0.8 or -0.8 oscillator thresholds for entry (but is added on the 2nd and 3rd positions (no oscillator threshold required just >30 ticks)) then it will take cumulative positions albeit again incorrectly buying at lower prices for long trades…. (From experience I would never average down when trading).
Reversing the order of the “Close-Tradeprice” for the short side actually produced the same number of trades and profit? Although initially it was clearly incorrectly written back to front for the short side. The system still defied the >30 for 2nd and 3rd positions and bought long positions at lower prices…(Adding a graph for “count of positions” and removing “buy 10 contracts” replacing it with “buy 10 perpoint,” just mirrored the actual trade positions chart segment, e.g. +10 or +20 for £10/tic or £20/tic trades)?
Currently it is just taking one long position then closing it out and going short and then long again etc, (with “if on market” code for each of the 3 positions and oscillator crosses only for the position #1 and >30 tick “increases” for positions #2 and #3).
And that is, with all the gratefully received feedback, where I’m at with my Amos Hostetter pyramiding coding attempt! What I’m currently obviously missing to make it buy a maximum of 3 positions with 30 tick differences between each position genuinely escapes me as I have tried many different code permutations. I have spent a lot of hours on something that I thought would just take 30 minutes to achieve…
(As an aside, I’ve yet to find any system (even those on lease) that can come anywhere near my intraday % returns when I was a disciplined (and time rich) discretionary trader. However, the market turmoil and volatility post Credit Crunch was “tricky” as I then became heavily biased to the short side and it negatively impacted my trading style (eg taking a £9k spot £/$ short loss in 24 hours, closing out the £9k loss, as per my money management rules, and then watching it go back to breakeven a few hours later.. Lol) which is why I got interested in automated trading).
Thanks again,BestBard08/17/2017 at 1:38 PM #44111Hi @Nicolas, “What I’m currently obviously missing to make it buy a maximum of 3 positions with 30 tick differences between each position genuinely escapes me as I have tried many different code permutations.”
Maybe it’s a case of I “can’t see the wood for the trees” but if you could tell me where I’m going wrong that would be appreciated as I’ve read and re-read you comments on the other page?
P.s. @Noobywan, right, pips = 4 decimal places and ticks 5. thanks.
Cheers
Bard08/17/2017 at 1:48 PM #44112I edited your code, you’ll find below the strategy part that deal with putting orders on market by comparing your 30 or 60 pips (didn’t tested):
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748// Definition of code parametersDEFPARAM CumulateOrders = TRUE // Cumulating positions deactivated// Conditions to enter long positionsindicator1, ignored = CALL "Ehler's Univ Osc SuperSmoother"c1 = (indicator1 CROSSES OVER -0.8)IF Not LongOnMarket AND c1 THENBUY 10 PERPOINT AT MARKETENDIF// Conditions to enter extra long positions//second orderIF Close-TRADEPRICE(1)>30*pipsize AND LongOnMarket AND COUNTOFPOSITION = 1 THENBUY 10 PERPOINT AT MARKETENDIF//third orderIF Close-TRADEPRICE(1)>60*pipsize AND LongOnMarket AND COUNTOFPOSITION = 2 THENBUY 10 PERPOINT AT MARKETENDIF// Conditions to enter short positionsindicator1, ignored = CALL "Ehler's Univ Osc SuperSmoother"c2 = (indicator1 CROSSES UNDER 0.8)IF NOT ShortOnMarket AND c2 THENSELLSHORT 10 PERPOINT AT MARKETENDIF// Conditions to enter extra short positions//second orderIF TRADEPRICE(1)-Close>30*pipsize AND ShortOnMarket AND COUNTOFPOSITION = 1 THENSELLSHORT 10 PERPOINT AT MARKETENDIF//third orderIF TRADEPRICE(1)-Close>60*pipsize AND ShortOnMarket AND COUNTOFPOSITION = 2 THENSELLSHORT 10 CONTRACTS AT MARKETENDIF08/17/2017 at 4:27 PM #44128Thanks Nicolas,
Btw, where did you mention using pipsize on the other page?:
https://www.prorealcode.com/topic/increase-number-of-position-based-on-30-tic-moves/There’s no pyramiding if you leave the command “Not longonmarket” in the first position (of three total positions) code which is why I didn’t think it worked using *pipsize.
123IF Not LongOnMarket AND c1 THENBUY 10 PERPOINT AT MARKETENDIF“Not longonmarket” has to be removed to allow pyramiding of positions?
Looking at the pyramiding rule of buying (or selling) if there has been a 30 pip increase (or decrease) it still takes e.g. Short positions when the difference of 30 pips has not been met?
In the first two screenshots I’m wondering why it’s shorting more positions when the second screenshot is showing a higher price than the previous trade, it should only be opening new positions if the market is moving in it’s favour? Ditto for screenshots 3 and 4. (all part of one short trade that has taken far too many positions, -£110 at £10/pip). Ditto for long trades in screens 5 & 6.
£/$ Spot 1 Hour — Jan 3rd 2016 – 1st June 2017.
Univ Osc = -0.9 and 0.9 cut off. Univ Oscillator Bandedge = 100 (a slightly imbalanced number but it has produced good results in the past on Daily charts too)35 trades. 401% Return, Drawdown = 22.9%. Although the attached equity graph shows about a 70% drawdown??
If it’s extended forward by 6 months at a time it’ll make a profit each time/test.Richard Dennis used a Drawdown cut off at 50%. Kevin Davey uses 40%. This because they had/have multiple system running.
08/17/2017 at 4:31 PM #4413408/17/2017 at 7:28 PM #4414210/25/2018 at 11:52 PM #83552Hello @Nicolas, I’ve revisited this system code after @Vonasi pointed out why a similar code wasn’t adding new positions at £10/tick.
(#82651)The COUNTOFPOSITION=1 code, should be COUNTOFPOSITION=10.
The idea was to buy or sell up to a max of 3 positions at a time (at £10/tick,= £30/tick max exposure) based on moves in the market in my favour of greater than 30 ticks for each individual new trade. I’m still not sure it’s following that rule as I see some trades with far more than 30 ticks difference when the second position is taken? (That’s even when you account for the fact that the system can’t enter until the next bar which might open a lot higher if you’re long or lower if you’re short).
It seems the only way I can stop the excessive pyramiding of positions (because CumulateOrders = TRUE) is to add this not very friendly or concise COUNTOFPOSITION = 40 code see below, but even then the short side takes too many trades?
Cheers
BardThe whole strategy is here below: $/CHF, 4 HOURS, 3.8 spread — 04/01/17 – 25/10/18
(Ehlers Universal Osc Bandedge is optimised at 124, but it really doesn’t need an optimised value as any value over 75 is stable and I normally find 100 to be reliable (= £73k profit). Pls see “stable bandedge” screenshot). I’m looking forward when we can optimise by drawdown too, but was reminded of a workaround today when I saw an old post of mine (“How to optimise a look back period”) where you’d mentioned using MAE and making a percentage distribution in Excel.Ps/ Having a lot of trouble using Safari v12 and this blog. The Insert Code is not working and when I post it adds html coding within my text?
12345678//exit all ordersIf COUNTOFPOSITION = 40 THENSELL AT MARKETendifIf COUNTOFPOSITION = 40 THENEXITSHORT AT MARKETendif1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162// Definition of code parametersDEFPARAM CumulateOrders = TRUE // Cumulating positions deactivated// Conditions to enter long positionsindicator1, ignored = CALL "Ehler's Univ Osc SuperSmoother" [bandedge]c1 = (indicator1 CROSSES OVER -0.9)IF c1 THEN //"If Not LongOnMarket AND" --> DOESN'T PYRAMID using this CODEBUY 10 PERPOINT AT MARKETENDIF// Conditions to enter extra long positions//second long orderIF Close-TRADEPRICE(1)>30*pipsize AND COUNTOFPOSITION = 10 THENBUY 10 PERPOINT AT MARKETENDIF//third long orderIF Close-TRADEPRICE(1)>60*pipsize AND COUNTOFPOSITION = 20 THENBUY 10 PERPOINT AT MARKETENDIF// Conditions to enter short positionsindicator1, ignored = CALL "Ehler's Univ Osc SuperSmoother" [bandedge]c3 = (indicator1 CROSSES UNDER 0.9)IF c3 THENSELLSHORT 10 PERPOINT AT MARKETENDIF// Conditions to enter extra short positions//second short orderIF TRADEPRICE(1)-Close>30*pipsize AND COUNTOFPOSITION = 10 THENSELLSHORT 10 PERPOINT AT MARKETENDIF//third short orderIF TRADEPRICE(1)-Close>60*pipsize AND COUNTOFPOSITION = 20 THENSELLSHORT 10 PERPOINT AT MARKETENDIF//exit all ordersIf COUNTOFPOSITION = 40 THENSELL AT MARKETendifIf COUNTOFPOSITION = 40 THENEXITSHORT AT MARKETendifGRAPH COUNTOFPOSITIONThe COUNTOFPOSITION works for the long side (no more than £40/tick at any one time, if it hit’s 40 it closes it on the next bar, but reaches 210 ( £210/tick) on the short side, (please see “too many short positions” graph image).
Cheers,
Bard10/25/2018 at 11:59 PM #83555Okay so it worked on the second edit and submit, not sure why every first attempt at posting and then submitting it doesn’t insert PRT code properly as this is the second time today this has happened? Also I am not sure why “The COUNTOFPOSITION works for ” paragraph is at the very bottom of my post, it was above the PRT code. Might be better to use Firefox…
10/29/2018 at 2:03 PM #8372710/31/2018 at 7:26 PM #83890Thanks @Nicolas, I added the negative symbols for: COUNTOFPOSITION = -10 and COUNTOFPOSITION = -20, but it’s still the
CHOKE TRADES TO STOP TOO MANY SHORT POSITIONS1"If COUNTOFPOSITION = -40 THEN EXITSHORT AT MARKET"code that stops the system from otherwise taking too many short entries? The two screenshots show what happens if the -40 code is REM’d out or not REM’d out. Wondering what else needs to be modified on the short code to get it to just take a maximum of £30/tick (3 positions)?
Also shouldn’t the Walk Forward be doing more repetitions if it was still in profit at the end of the first OOS date? (pls see 3rd screenshot). Cheers,
11/09/2018 at 4:47 PM #84500Hi Nicolas, I could do with a little help here to figure out what is stopping this long and short code from working and only taking a maximum of 3x £10/tick? I have to use “If COUNTOFPOSITION = -40 THEN EXITSHORT AT MARKET” to stop it overtrading.
Pls see screenshot “Way too many shorts.png” (and longs )
Cheers
Bard11/09/2018 at 7:58 PM #84512Ignore the last comment @Nicolas!
I’ve spotted the problem: The code needed If NOT ShortOnMarket for the original trade and subsequent trades:123IF TRADEPRICE(1)-Close>30*pipsize AND ShortOnMarket AND COUNTOFPOSITION = -10 AND c5 THENSELLSHORT 10 CONTRACTS AT MARKETENDIF -
AuthorPosts
Find exclusive trading pro-tools on