Parabolic Short/Long Strategy
Forums › ProRealTime English forum › ProOrder support › Parabolic Short/Long Strategy
- This topic has 9 replies, 3 voices, and was last updated 1 year ago by Francesco.
-
-
03/14/2023 at 4:45 PM #211550
Hi everyone, after taking a break for a while, I’m back to jot down a few more ideas during my free time. Since I’m a bit rusty, I would like some help in converting some elements into a code that I will then assemble and share with you if it’s decent.
First code: Identify an increase/decrease of x percent in a stock during the past y days;
Second code: Enter short during the breakdown of the opening range low if the candle is red/Enter long during the breakout of the opening range high if the candle is green;
Third code: Open a position when the price, after crossing over or under the VWAP, fails and bounces back.
Thanks!
03/15/2023 at 7:53 AM #211567Hi @Francesco,
Here is the first code…
Increase / Decrease1234567891011Period = y //y daysGain = x // x%Increase = 0Decrease = 0If (Close - Close[y]) / Close[y] * 100 >= x thenIncrease = 1ElsIf (Close - Close[y]) / Close[y] * 100 <= x thenDecrease = 1EndIf1 user thanked author for this post.
03/15/2023 at 8:16 AM #21156803/15/2023 at 10:59 AM #211577I suggest to modify the code as follows, to make sure both variables are always different:
1234567If (Close – Close[y]) / Close[y] * 100 >= x thenIncrease = 1Decrease = 0ElsIf (Close – Close[y]) / Close[y] * 100 <= –x thenIncrease = 0Decrease = 1EndIf1 user thanked author for this post.
03/15/2023 at 2:05 PM #211592Thank you guys!
For the second request, could something like this work? (the time refers to NASDAQ opening hours)
12345678910111213141516// Entry Conditionsif time>= 153000 and time <= 153500 thenif time= 153000 thendailyhigh= highdailylow= lowendifif high> dailyhigh thendailyhigh= highendifif low< dailylow thendailylow = lowendifendifcl= close crosses over dailyhighcs= close crosses under dailylow03/15/2023 at 3:24 PM #21159303/15/2023 at 5:36 PM #211603When I use Time >=153000 the high and Low of the previous candle is used, hence Time >= 153500…
Second Code12345678910111213141516DefParam CumulateOrders=FalseTimeFrame(5 minutes, UpDateOnClose)Once HighEntry=0Once LowEntry=0If Time >= 153500 and Time <= 154000 and NOT OnMarket thenIf Time = 153500 thenHighEntry = HighLowEntry = LowEndIfIf (HighEntry + LowEntry) <> 0 thenBuy 1 contract at HighEntry STOPSellShort 1 contract at LowEntry STOPEndIfEndIf1 user thanked author for this post.
03/15/2023 at 7:47 PM #211613It seems to open the positions correctly now! But i’m still missing on how to put the stop loss on the high/low of the entry candle.
Also in your example @js the postion should be closed at 15:55 after crossing under the low of the entry candle.
Any suggestion? Current code version below:
123456789101112131415161718192021222324// Entry Conditionsonce highentry=0once lowentry=0if time= 153000 thenhighentry=highlowentry=lowendifcl=close crosses over highentrycs=close crosses under lowentry// Time Conditionst=time>=153500 and time< 154000// Enter Longif not onmarket and cl and t thenbuy n contract at marketendif// Enter Shortif not onmarket and cs and t thensellshort n contract at marketendif03/16/2023 at 1:44 PM #211647I implemented the following code and it seems that i’m getting closer
123456789101112131415161718192021222324252627// Entry Conditionsif time=153000 thenhighentry=highlowentry=lowendifcl=close crosses over highentrycs=close crosses under lowentry// Time Conditionst=time>=153500 and time<154000// Stop Loss Conditionssll=abs(close-low)sls=abs(close-high)// Enter Longif not onmarket and cl and t thenbuy n contract at marketset stop loss sllendif// Enter Shortif not onmarket aand cs and t thensellshort n contract at marketset stop loss slsendifBut as you can see in the image attached, the position is closed when crossing the high of the opening range candle and not when crossing the high of the candle where the position was opened
03/16/2023 at 6:46 PM #211666Ok i think i managed to solve the issue changing with:
123// Stop Loss Conditionssll=abs(close[2]-low)sls=abs(close[2]-high)But looking at the backtests, putting the stop loss on the high/low of the opening range candle (so at the daily high/low) instead of the candle where the position was opened (as i wanted to during last posts) seems more effective for gains.
Below the first version of the system (i’m still figuring out if it’s necessary to implement the VWAP condition) on NASDAQ 5M – 1.5 Contracts (939€ atm)
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687// Parabolic Long/Short v1 by Francesco// ProRealCode.com - 20230316// NASDAQ - 5M// Setupdefparam cumulateorders=falsen=1.5once long=1once short=1timeframe (1 day)// Filterx=3if (close-close[1])/close*100>=x thenincrease=1decrease=0elsif (close-close[1])/close*100<=-x thenincrease=0decrease=1endiftimeframe (default)// Entry Conditionsif time=153000 thenhighentry=highlowentry=lowendifcl=close crosses over highentrycs=close crosses under lowentry// Time Conditionst=time>=153500 and time<154000// Stop Loss Conditionssll=abs(close-low)sls=abs(close-high)// Enter Longif long thenif not onmarket and decrease=1 and cl and t thenbuy n contract at marketset stop loss sllendifendif// Enter Shortif short thenif not onmarket and increase=1 and cs and t thensellshort n contract at marketset stop loss slsendifendif// Trailing Stoptrailingstart=200trailingstep=5If not onmarket thennewsl=0endifif longonmarket thenif newsl=0 and close-tradeprice(1)>=trailingstart*pipsize thennewsl=tradeprice(1)+trailingstep*pipsizeendifif newsl>0 and close-newsl>=trailingstep*pipsize thennewsl=newSL+trailingstep*pipsizeendifendifif shortonmarket thenif newsl=0 and tradeprice(1)-close>=trailingstart*pipsize thennewsl=tradeprice(1)-trailingstep*pipsizeendifif newsl>0 and newSL-close>=trailingstep*pipsize thennewsl=newsl-trailingstep*pipsizeendifendifif newsl>0 thensell at newsl stopexitshort at newsl stopendifFew details about the system:
- Entirely based on price action
- Pretty easy to optimize (just 1 value to edit)
- No optimization needed for stop loss, just play with the trailing stop
- Running just the Long version drastically decreases drawdown but generates less gains
Please find attached a 10y backtest; feel free to give your contribution
-
AuthorPosts
Find exclusive trading pro-tools on