Skip next trade – TrendFollowing
Forums › ProRealTime English forum › ProOrder support › Skip next trade – TrendFollowing
- This topic has 11 replies, 4 voices, and was last updated 7 years ago by trendfollower86.
-
-
02/26/2017 at 6:53 PM #26447
Hello All!
I was wondering if you could help me. I would like to add a bit of code into my trend following system that skips the next trade if the previous trade were profitable.
The idea being that on trend following systems, periods of whipsawing often follow trending markets.
Anyone familiar with the turtle system should be aware of the above concept.
I’ve tried using positionperfp[1] but can’t figure out how to proceed.
Any help is appreciated. Thanks
02/26/2017 at 10:03 PM #26460Hello trendfollower86,
you can find a snippet below that shows an example of how the positionperf can be used to manage future orders.
12345678910111213if not onmarket thenperf = positionperf(1)endifif perf > 0.01 thennotrade = 1elsenotrade = 0endifif buyingcondition and notrade = 0 thenbuy at marketendif1 user thanked author for this post.
02/27/2017 at 9:57 AM #26487Thanks very much for your reply Derek.
I understand the code above, however the problem I have is that the code above will not only skip the next trade, but all other trades following a winner.
I imagine I need to put some kind of count function in the code so it counts to a maximum of 1 when a trade is skipped and then takes the next trade when reset.
02/27/2017 at 11:43 AM #26517I’m finding this thread interesting as it touches upon coding that would be really useful –
How do you register “signals” but not trade them and instead just “count” each signal and then code to trade the 5th signal for example.
This would be useful for counter trend signals such as the RSI where we know that the first, second and third can be misses but the fourth or fifth
brings home the bacon.
02/27/2017 at 11:55 AM #26520https://www.prorealcode.com/topic/count-crossovers-and-crossunders/
Got me thinking…
02/27/2017 at 1:51 PM #26531Ok. I have something like the following:
12345678910IF positionperf(1) > 0.01 thenSkipTrade = summation[Close CROSSES Over Upper100](1)EndIfLongEntry = (Not OnMarket or ShortOnMarket) AND BullSlope=1 and SkipTrade=1If LongEntry ThenBuy LongPoundsPerPoint PerPoint RoundedUp At Upper100 StopSet Stop pLoss ATR*2SkipTrade=0EndIfBut annoyingly, this doesn’t take any trades because SkipTrade never gets set to 1
02/27/2017 at 5:33 PM #26567The problem with all trades being skipped is probably caused by
1if perf > 0.01 thenYou can graph your Positionperformance when running a backtest to have the values for your system returned with the backtest results. Then you can enter the value you need (because honestly I don’t know what 0.01 is referring to).
Simply remove the sample code from above and add this line to your backtest:
1graph positionperf02/27/2017 at 5:35 PM #2656802/27/2017 at 5:37 PM #26569@trendfollower
Your code is wrong. If you refer to previous Derek’s post, you already have the needed code to achieve your request = no more trade if the previous one is a profit > 0
About your code, line 2, condition should be placed in parenthesis, and periods in brackets, you have apparently done a mistake while copy/paste code from another topic.
02/27/2017 at 7:14 PM #2658402/27/2017 at 7:18 PM #26585I’m not trying to achieve no more trades as you state. I am trying to skip the next trade if its previous trade was a winner. Then take the next trade regardless.
@Derek, not sure where your reference to ” if perf” has come from. I don’t have that in my code. If you are referring to“
IF positionperf(1) > 0.01 then". I am trying to say, if the last postion closed out and returned any kind of profit skip the next trade.
02/27/2017 at 7:52 PM #26591@Derek. Much appreciated. I have had some luck with this code:
123456<span class="token keyword">if</span> buyingcondition <span class="token keyword">and</span> counter <span class="token operator">=</span> <span class="token number">5</span> <span class="token keyword">then</span><span class="token keyword">buy</span> <span class="token keyword">at</span> <span class="token keyword">market</span>counter <span class="token operator">=</span> <span class="token number">0</span><span class="token keyword">elsif</span> buyingcondition <span class="token keyword">and</span> counter <span class="token operator"><</span><span class="token number">5</span> <span class="token keyword">then</span>counter <span class="token operator">=</span> counter<span class="token operator">+</span><span class="token number">1</span><span class="token keyword">endif</span> -
AuthorPosts
Find exclusive trading pro-tools on