Never two or more time trading in same direction
Forums › ProRealTime English forum › ProOrder support › Never two or more time trading in same direction
- This topic has 8 replies, 2 voices, and was last updated 8 years ago by Bolu14.
-
-
05/14/2016 at 5:09 PM #7069
Hello,
i try to create a code for the following Trading Idea:
Enter Long:
RSI undercross 30 and the last trade have to be a short Trade
Enter Short
RSI overcross 70 and the last trade have to be a long Trade
Exit only with StopLoss or Positionchange (maybe from long to short or short to long)
My Intention is, that in Case of a Strong Trend the RSI will generate may times short signals (maybe on a UpTrend). RSI will swing at the 70 Line and create many failure Signals. If the Short signal is given, then the next trading should be a Long Trade, means that i trade only one time the Short Signal. And if the RSI Swing at 70 and create manytimes short Signals, these does not matter to me. I will wait, until a long Signal is coming.
I hope you understand.
I use this on Dax 1 Minute Timeframe. In Strong Trends it generates 6-10 times failuresignal behind each other. I want to decrese that.
So, that is my code, which i create, but i can`t build the condition with the direction of the last trade.
123456789101112131415161718192021222324252627282930313233343536373839404142434445// Code-ParameterDEFPARAM CumulateOrders = FalseDEFPARAM Flatbefore = 090500DEFPARAM Flatafter = 215500// Enter Long Positionindicator1 = RSI[14]c1 = (indicator1 CROSSES UNDER 30)c7 = ShortOnMarket[1] = 1IF c1 AND c7 THENBUY 1 CONTRACT AT MARKETENDIF// Exit Long Positionindicator2 = RSI[14]c2 = (indicator2 >= 65)c3 = (close <= open[1])IF c3 AND c2 THENSELL AT MARKETENDIF// Enter Short Positionindicator3 = RSI[14]c4 = (indicator3 CROSSES OVER 70)c8 = LongOnMarket[1] = 1IF c4 AND c8 THENSELLSHORT 1 CONTRACT AT MARKETENDIF// Exit Short Positionc5 = (close >= open[1])indicator4 = RSI[14]c6 = (indicator4 <= 35)IF c5 AND c6 THENEXITSHORT AT MARKETENDIF// MoneyManagementSET STOP pLOSS 14I dont know, how i can check, in which the last trade was going on. Was it a Longtrade or Shorttrade ?
I hope you can help me.
Thanks
05/14/2016 at 5:10 PM #707205/14/2016 at 8:49 PM #708805/14/2016 at 8:56 PM #7090Yes. Because in Case of a LongTrend maybe, this system generates many FailureSignals, all short Signals (at LongTrend), and i dont want to trade this until the Dax is normal (no Trend) and the RSI goes down to create a Long Signal.
Now i Modify this, but in this case i dont get a trade. If i set manual the Variable on Line 7 to 1 then it runs, but this means, that i will start everyday with a short signal. It should be so, that the first Trade each day without this condition (Previous Long or Previous Short)
Please Check this:
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758// Code-ParameterDEFPARAM CumulateOrders = FalseDEFPARAM Flatbefore = 090500DEFPARAM Flatafter = 215500If Time = 090000 thenPositionRichtung = 0EndIF// Enter Long Positionindicator1 = RSI[14]c1 = (indicator1 CROSSES UNDER 30)c7 = (PositionRichtung < 0)If ShortOnMarket = 1 THENPositionRichtung = -1EndIFIF c1 AND c7 THENBUY 1 CONTRACT AT MARKETENDIF// Exit Long Positionindicator2 = RSI[14]c2 = (indicator2 >= 65)c3 = (close <= open[1])IF c3 AND c2 THENSELL AT MARKETENDIF// Enter Short Positionindicator3 = RSI[14]c4 = (indicator3 CROSSES OVER 70)c8 = (PositionRichtung > 0)If LongOnMarket = 1 THENPositionRichtung = 1EndIFIF c4 AND c8 THENSELLSHORT 1 CONTRACT AT MARKETENDIF// Exit Short Positionc5 = (close >= open[1])indicator4 = RSI[14]c6 = (indicator4 <= 35)IF c5 AND c6 THENEXITSHORT AT MARKETENDIF// MoneyManagementSET STOP pLOSS 14I try for long time, but i thinks this is near to my Final 🙂
05/14/2016 at 9:00 PM #709305/15/2016 at 5:21 PM #7120Ok, so it needs to flag a variable when a buy trading occur and another one when a sell trading occur. Then just test this variable to open a new position.
This variable needs to be reset each new day at very first intraday bar.
Here is your modified code: (haven’t test it)
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152// Code-ParameterDEFPARAM CumulateOrders = FalseDEFPARAM Flatbefore = 090500DEFPARAM Flatafter = 215500If intradaybarindex=0 thenPositionRichtung = 0EndIF// Enter Long Positionindicator1 = RSI[14]c1 = (indicator1 CROSSES UNDER 30)c7 = (PositionRichtung < 0)IF c1 AND c7 and PositionRichtung <>1 THENBUY 1 CONTRACT AT MARKETPositionRichtung = 1ENDIF// Exit Long Positionindicator2 = RSI[14]c2 = (indicator2 >= 65)c3 = (close <= open[1])IF c3 AND c2 THENSELL AT MARKETENDIF// Enter Short Positionindicator3 = RSI[14]c4 = (indicator3 CROSSES OVER 70)c8 = (PositionRichtung > 0)IF c4 AND c8 and PositionRichtung <>-1 THENSELLSHORT 1 CONTRACT AT MARKETPositionRichtung = -1ENDIF// Exit Short Positionc5 = (close >= open[1])indicator4 = RSI[14]c6 = (indicator4 <= 35)IF c5 AND c6 THENEXITSHORT AT MARKETENDIF// MoneyManagementSET STOP pLOSS 1405/15/2016 at 9:58 PM #7140Thanks, it looks good.
But the lines 14 and 34 have to be remove, because they are not needed anymore. Also the conditions “and c7” and “and c8” in Line 16 and 36. Then it runs.
I try to reduce the failure Trades but the Problem is, that i lost the important trades too. These, where i can win 40-60 Points at the end of the Trend. With this System, i would ignore the last signals in the trend, these, where the Index will turn around.
I hope you understand.
Thanks for your support.
05/16/2016 at 8:58 AM #7154Oh yes you are right about the c7 and c8 conditions, I forgot to remove them.
About the false signals, you are trying to catch trend with a bounded oscillator on the last 14 period. Maybe you should look at price behaviour as a complement to the RSI.
05/27/2016 at 3:31 AM #8197Hello Nicolas,
thanks for your support.
I still run this “system” live on my account, but i see, that every morning the first trade are missing.
I mean, that there should be a trade at maybe 09:13 but this first signal will not trade. It starts with the secound one.
Where can be the problem?
It is possible, that Intradaybarindex does not run because we have a condition like
1<span class="token keyword">DEFPARAM</span> Flatbefore <span class="token operator">=</span> <span class="token number">090500</span>At which time the intradaybarindex is = 0 ?
The last version of this Code, i attach to this post.
Thanks.
-
AuthorPosts
Find exclusive trading pro-tools on