AirBag Defense System
Forums › ProRealTime English forum › ProOrder support › AirBag Defense System
- This topic has 13 replies, 4 voices, and was last updated 6 years ago by Nicolas.
-
-
02/07/2018 at 2:29 AM #61821
Hello everyone, Ivan Donatiello Here.
My intention is to create a trading system that works to defend other strty, as breakout and meanrevertin systems in the portfolio.
For example, I should trade the S & P 500 with an breakout system and mean reverting, and probably this week the high downward volatility is very dangerous.
Then I implement a strategy that works as follows:
Conditions to enter the trade short:
1. Open> Close
2. Close of today < Close of yesterday
3. Today’s range higher than the average range of the last n daysIf the conditions are verified:
1. Open a trade short at today’s low
Stop loss conditions.
1. + n point on today’s high
Eixt:
1. K * mean of the range at n days, where K is a decimal incremental factor> 1
Here is the code that I did but that does not work:
Aribag System by Ivan Donatiello123456789101112131415161718//AirBag System Trading Lab Capital - Ivan Donatiellodefparam cumulateorders=false//Short ConditionC1 = Open > CloseC2 = Close < Close[1]C3 = Range > (summation[10](range)/10)if not longonmarket AND C1 AND C2 AND C3 thenSELLSHORT 1 contract at lowest[1](low)[1] stopstoploss = close+highest[1](high)[1]endif//Exit ConditionSET TARGET PROFIT n2*AverageTrueRange[10]//Stop Loss Conditionset stop loss stoplossIf we can thank you 🙂
02/07/2018 at 12:23 PM #61852You can write lines 10-11 as follows
12SELLSHORT 1 contract at low[1] stopstoploss = close+high[1]because both with LOWEST and HIGHEST you only check one bar, the previous one, making them unnecessary.
Conditions look good and logically combined (assuming you are on a daily TF). C2 requires the previous bar to be BEARISH or even BULLISH but with a current opening bearish gap no matter if filled, is that what you want?
Maybe the average range of the last n bars is greater than the current one!
02/11/2018 at 7:21 PM #62302These are daily bars.
I do not care about the gap, but the explosion of downward volatility.
Even with your lines of code, the system opens only 5 positions then no longer closes the stop loss leaving the last position at a loss.
It would be a shame not to realize this system as it could be an excellent balance of equity systems.
PS: The place also in the Italian forum?
02/11/2018 at 8:00 PM #62303I think that your stoploss calculation is incorrect. As it currently is the stoploss would be huge as close + high[1] = 2623 + 2628 = massive number of pips!
Surely it should be high[1] – close so 2628 – 2623 = 5 pips.
Also you might want to change IF NOT LONGONMARKET to IF NOT ONMARKET or put the stoploss calculation in a separate IF decision as otherwise the stoploss will be repeatedly recalculated once you are short on the market if the same conditions are met again.
1 user thanked author for this post.
02/13/2018 at 11:40 AM #62555PS: The place also in the Italian forum?
Please do not duplicate topics in order to have a wider range of help, because this might cause the opposite effect, leaving some suggestions on a forum and others on a different one, making it difficult and annoying for members to search and help. Thank you.
02/13/2018 at 11:47 AM #62559Since you used
1set stop loss stoplossyou correctly used price instead of pips (pLOSS deals with pips), but you are ADDING two prices, which will never be reached (within Eur/Usd, say 1.2110 + 1.2165 = 2.4275 which is…. you know what!), you may want to write
1stoploss = high[1]or
1stoploss = high[1] + (3 * pipsize)whatever you want.
02/13/2018 at 12:03 PM #62568you correctly used price instead of pips (pLOSS deals with pips)
Well spotted @robertogozzi. I didn’t spot that as I never use Loss always pLoss – so I assumed again! At least I was right about the stoploss calculation! 🙂
02/13/2018 at 12:35 PM #62581“set stop loss” use distance in price and not a price level, so the correct syntax should be:
12stoploss = abs(high[1]-close)set stop loss stoplossAssuming it is a short order with the stoploss set at the High of the previous candlestick.
1 user thanked author for this post.
02/13/2018 at 12:38 PM #62582Thank you Nicolas, I also always use pLOSS, sorry for the incorrect suggestion!
02/13/2018 at 12:46 PM #62583To set a Stop Loss at a given price you only have to use pending STOP orders (renewed at each bar), like
12SELL AT .... STOP //exit LONG tradesEXITSHORT AT .... STOP //exit SHORT tradesis that correct Nicolas?
02/13/2018 at 12:59 PM #62585Thank you for the tips 🙂
I rewrote the code, now it works.
AirBag System for prorealcode community12345678910111213141516171819202122232425//AirBag System Trading Lab Capital - Ivan Donatiellodefparam cumulateorders=false//Short ConditionC1 = Close CROSSES UNDER (Low[1] - atrmultipler*AverageTrueRange[20](close))if not onmarket AND C1 thenSELLSHORT 1 contract at low stopendif//Exit Condition//First tipe of exitif onmarket and barindex-tradeindex(1)>=ndayforexit thenEXITSHORT at marketendif//Second tipe of exit (<span id="result_box" class="" lang="en" tabindex="-1">use either the first or the second or study a possible combination)</span>set target profit atrmultipler*AverageTrueRange[20](close)//Stop Loss Conditionset stop loss high + 1Now the system enters the market at the end of the current bar, it would be much better if the system entered the market during the bar when the volatility level was reached.
For example:
1. Enter the market when the price falls and volatility has exceeded 1.5 Atr [20].
We hope we can do the metrics would improve a lot.
See you soon 😉
02/13/2018 at 1:09 PM #62587Be warned that the above code works with S&P500, Dax and similar instruments, but it would not work with EurUsd, since
1high + 1would give 2.1220 (1.1220 + 1), instead of 1.1221 (1.1220 + 0.0001), so you’d better always use
1set stop loss high + 1 * pipsizewhich will work with any instrument. It’s the system doing the conversion.
1 user thanked author for this post.
02/15/2018 at 12:02 PM #6281402/16/2018 at 8:22 AM #62885Yes you are right about your statement for STOP orders. They expire at each bar so it’s necessary to put them continuously until your conditions are not true anymore.
Not possible to do that until we get the long promise multiple timeframes support 😉
-
AuthorPosts
Find exclusive trading pro-tools on