Scalping strategy to be improved – Any help is welcome
Forums › ProRealTime English forum › ProOrder support › Scalping strategy to be improved – Any help is welcome
- This topic has 3 replies, 3 voices, and was last updated 1 year ago by KumoNoJuzza.
-
-
08/20/2023 at 11:11 AM #219363
Hi,
I am trying to automate a scalping strategy I have come across. I did not publish it in the strategy section since it is clearly not profitable (yet :p )
Any help is welcome as I would be happy to work together to make this strategy profitable.
The initial strategy being:
Setup: is for price to move above the lower or lower Bollinger Bands, RSI raise above the 70 line or below the 30 line and Stochastic raise above the 80 line or below the 20 line at the same time.
Long Entry: price to move below the upper Bollinger Bands( deviation 2 and 20 period), RSI (7 period ) raise above the 30 line and Stochastic > 80 at the same time.
Short Entry: price to move above the upper Bollinger Bands( deviation 2 and 20 period), RSI (7 period ) raise below the 70 line and Stochastic < 20 at the same time.
Exit: Use Trailing Stop.
As you can see, when backtesting most trades are winning but the few losses are too big. I am running out of ideas to optimize it and to mitigate losses. The code is
PRT code12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788DEFPARAM PreLoadBars = 100000DEFPARAM CumulateOrders = False//DEFPARAM FlatBefore = 070000//DEFPARAM FlatAfter = 230000// *** tendance courte *****************M8=average[4,7](close) // 11Tm8h=M8>M8[1]Tm8b=M8<M8[1]//************** Indicators Setup ****************BD = BollingerDown[20](close)BU = BollingerUp[20](close)RS = RSI[7](close)ST = Stochastic[5,3](close)//*********** Strategy ***************If High[close] > BU AND High[1] > BU AND RS > 65 AND ST > 40 AND Tm8h THENSELL 1 contract at marketENDIFIf Low[close] < BD AND Low[1] < BD AND RS < 35 AND ST < 20 AND Tm8b THENBUY 1 contract at marketENDIFSET STOP pLOSS 50//********* trailing stop function *************trailingstartL = 10 //LONG trailing will start @trailingstart points profittrailingstartS = 10 //SHORT trailing will start @trailingstart points profittrailingstep = 5 //trailing step to move the "stoploss"Distance = 0 * PipSize// SL = 15 // STOP LOSS//******************** reset the Trailing Stop value *************IF NOT ONMARKET THENTS=0ENDIF//manage long positionsIF LONGONMARKET THEN//first moveIF TS=0 AND close-tradeprice(1)>=trailingstartL*pipsize THENTS = tradeprice(1)+trailingstep*pipsizeENDIF//next movesIF TS>0 AND close-TS>=trailingstep*pipsize THENTS = TS+trailingstep*pipsizeENDIFENDIF//******************** manage short positions *********************IF SHORTONMARKET THEN//first stepIF TS=0 AND tradeprice(1)-close>=trailingstartS*pipsize THENTS = tradeprice(1)-trailingstep*pipsizeENDIF//next stepsIF TS>0 AND TS-close>=trailingstep*pipsize THENTS = TS-trailingstep*pipsizeENDIFENDIF//stop order to exit the positionsIF TS>0 THENIF LongOnMarket THENIF (close - Distance) > TS THENSELL AT TS STOPELSIF (close + Distance) < TS THENSELL AT TS LIMITELSESELL AT MarketENDIFELSIF ShortOnMarket THENIF (close - Distance) > TS THENEXITSHORT AT TS LIMITELSIF (close + Distance) < TS THENEXITSHORT AT TS STOPELSEEXITSHORT AT MarketENDIFENDIFENDIF08/20/2023 at 2:55 PM #219372Hi K.,
Some remarks to get the going better. First your current strategy is not taking any shorts! The command for going short in PRT is SELLSHORT. In line 23 you hope that SELL will do the trick, but no. SELL is for closing a BUY, SELLSHORT is for selling, to be closed later by EXITSHORT.
Next little problem: High[Close] in line 22 and Low[Close] in line 26 do something, but most likely not what you want. High[AnyNumber] gives the high of the candle AnyNumber back in time. With the CAC around 7200 this will give you the High and Low of about 7200 minutes ago. If you replace High[Close] and Low[Close] both by Close, you will get some results. If you drop the long trades and only keep the short trades you might even win some money with this strategy. In my experience lots of scalping strategies perform better as either long only or short only robot.
And then there are the long and short conditions in the IF . . . THEN in lines 22 and 26. The logic programmed with these conditions doesn’t correspond to the text above the code in which you explain the strategy. I leave that up to you to resolve or improve this part. Hope this will help a little, good luck.08/20/2023 at 3:03 PM #219373Oops, crossing comments…
Here are some notes about your system…
The system only opens long positions because you use Sell instead of SellShort…
High[Close] and Low[Close] is not possible…
The input in your system does not match the description…
08/21/2023 at 2:57 PM #219432Thanks guys for your feedbacks. I’ll work on it.
-
AuthorPosts