PSEUDOSTOCHASTIC TRADE
Forums › ProRealTime English forum › ProOrder support › PSEUDOSTOCHASTIC TRADE
- This topic has 14 replies, 3 voices, and was last updated 6 years ago by Leo.
-
-
02/23/2018 at 10:44 PM #63754
Hi all,
I got an idea thanks to GraHal in another conversation and I could not go to sleep without testing.
After several attempts I got very nice code.
I do not even let it run complete but please test it wherever and at whichever time frame
02/23/2018 at 10:47 PM #63757I call it Pseudo stochastic because I sue the same period for calculate the three variables that define the stochastic.
PSEUDOSTOCHASTIC TRADE123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155//STOCHASTIC TRADE v1.0//Autor: LEODEFPARAM CumulateOrders = false // Cumulating positions deactivatedDEFPARAM PreLoadBars = 10000 //cargar informacion//VARIABLES TO BE OPTIMIZED//Ps=21 //preiod for stochastic values//Slevel= 20 //stochastic signal//Pactive=3 //bars after stochastic signals//Kp=2 // Profit target to Kp times the stop loss//Psma=200 //Period for a SimpleMoving Averagemaxrisk0=20 //pips per trade to riskn=1maxrisk=maxrisk0+(n-1)*2totalrisk=10*maxrisk*PIPVALUE //for stop the robot if things are going badspread=0.7IF TIME < 060000 THEN //(germany time)spread=1.7*spreadELSIF TIME>214500 THEN //(germany time)spread=1.7*spreadENDIF//Robot Working Time (Germany)IF TIME>050000 and TIME < 220000 THENontime=1ELSEontime=0ENDIF////// RISK CONTROL IF THINGS ARE GOING WONDERFULL ////////n = 1 + (strategyprofit / (77*pipvalue))//n = round(n * 100)//n = n / 100//n = max(1,n)//--------------------------------------------------------//>>>>>>>>>>>>>>>>>> INDICATORS <<<<<<<<<<<<<<<<<<<<<//--------------------------------------------------------SMA=average[Psma](close)TYPICALDAY=(DHIGH(1)+DLOW(1)+Dclose(1))/3mystoch=Stochastic[Ps,Ps](close)StochD=Average[Ps](myStoch)//--------------------------------------------------------//>>>>>>>>>>>>>>>>>> TRADING <<<<<<<<<<<<<<<<<<<<<//--------------------------------------------------------a0=myStoch crosses over StochDa1=highest[Pactive](a0)=1a2=lowest[Pactive+1](mystoch) < Sleva3=close > TYPICALDAYa4=close > SMAIf a1 and a2 and a3 and a4 thenIF NOT LongOnMarket AND ontime=1 and DayOfWeek <= 5 THEN//entrylong=high+0.5*spread*pipsizestoplosslong=(close-lowest[Ps](low))/pipsize+spreadstoplosslong=min(stoplosslong,maxrisk)BUY n CONTRACTS AT market//entrylong STOPSET STOP pLOSS stoplosslongSET TARGET pPROFIT Kp*stoplosslongENDIFENDIFb0=myStoch crosses under StochDb1=highest[Pactive](b0)=1b2=highest[Pactive+1](mystoch) > 100-Slevb3=close < TYPICALDAYb4=close<SMAIF b1 and b2 and b3 and b4 then//entryshort=low-0.5*spread*pipsizestoplossshort= (highest[Ps](high)-close)/pipsize+spreadstoplossshort= min(stoplossshort, maxrisk)IF NOT ShortOnMarket AND ontime=1 and DayOfWeek <= 5 THENSELLSHORT n CONTRACTS AT market //entryshort STOPSET STOP pLOSS StopLossShortSET TARGET pPROFIT Kp*StopLossShortENDIFENDIF//---------------------------------------------------------//>>>>>>>>>>>>>>>>>> EXIT POSITIONS <<<<<<<<<<<<<<<<<<//---------------------------------------------------------mySAR=SAR[0.007,0.007,0.7]// ---> exit longIF longonmarket thenIF close < lowest[Ps](low[1]) THENSELL AT MARKETENDIFIF close crosses under MySAR THENSELL AT MARKETENDIFIF b0 and close>POSITIONPRICE THENSELL AT MARKETENDIFIF close > (POSITIONPRICE+0.5*stoplosslong*pipsize) and close>mySAR thenSET STOP pLOSS min((close-MySAR)/pipsize+2*spread, maxrisk)ENDIFIF TIME > 224500 and DayOfWeek=5 thenSELL AT MARKETENDIFendif// ---> exit longIF shortonmarket thenIF close > highest[Ps](high[1]) THENEXITSHORT AT MARKETENDIFIF close crosses over MySAR THENEXITSHORT AT MARKETENDIFIF a0 and close < POSITIONPRICE thenEXITSHORT AT MARKETENDIFIF close < (POSITIONPRICE-0.5*StopLossShort*pipsize) and close<mySAR thenSET STOP pLOSS min( (MySAR-close)/pipsize+2*spread , maxrisk)ENDIFIF TIME > 224500 and DayOfWeek=5 thenEXITSHORT AT MARKETENDIFendif//Quit the robot if things are going badQ=MAX(Q,(STRATEGYPROFIT/pipvalue/n))R=Q-STRATEGYPROFIT/pipvalue/nIF R > totalrisk THENQUITENDIFIF STRATEGYPROFIT < (-1*totalrisk) THENQUITENDIF2 users thanked author for this post.
02/24/2018 at 8:37 PM #63834last version
1 user thanked author for this post.
02/24/2018 at 10:02 PM #63840@Leo
Sorry for delay, I’ve been busy doing family jobs today, but I wish I’d set it going / optimising while I was doing other stuff! 🙂
Even early results (over 90% yet to do) look good!!!
Does v1.1 supercede V1.0 as I was going to run both to see the improvement, but I may as well kill v1.0 and optimise v1.1?
Many Thanks
GraHal02/24/2018 at 11:16 PM #63846Attached V1.1 on eurusd @ 5 min over 100k bars @ £1 per point SB
Just a couple of thoughts … most of the gain is made by 4 or 5 trades (out of 25 winning) and most of the losing trades don’t lose much … hence the long flattish periods.
Maybe a time condition might help?
More tomoz maybe
Cheers
GraHal02/25/2018 at 3:30 PM #6388802/27/2018 at 1:46 PM #64047V1.1 on DJI @ 1Min TF over 100,000 bars.
Clearly a lot of the gain was made during that big drop and retrace early Feb, but it was both Long and Short during that time and volatile times could be here to stay for a while?
I’ve set it Live but will monitor each trade as soon as it is triggered.
Cheers
GraHalPS variable settings can seen in the image
02/27/2018 at 9:12 PM #64077I do not know what else to do for filter those losing trading
I made some improvements that increase the ratio Gain / Loss and therefore the yield on DJI Indice.
I used the TF28s, if that does not suit you an optimization of variables is possible with a TF1mn or other.
cordially
Gertrade
1 user thanked author for this post.
02/28/2018 at 5:48 AM #6408802/28/2018 at 9:10 AM #64090You have two set of variables, can you tell me please how is your method for optimising those variables
Thanks for the legend TF28s!
For the variables I realized that the variables could be different when one is above or below the equity curve.
To save time, I do not like you optimize all the variables together, I optimize each variable individually on 20,000 units (maximum history on TF28s).
I am at your disposal if you have any other questions.cordially
Gertrade
03/01/2018 at 8:54 AM #64173Hi Leo,
I just finished v1.14 for the EURUSD, I did some optimization of variables and I improved the code to increase the yield. I remain faithful to the TF28s to preserve the legend Gertrade.
below the v1.14 on TF28s for the EURUSD.
03/01/2018 at 10:40 AM #64177@Leo you’ve started something now! 🙂
I thought at one point a few days ago I was just about steering Gertrade off the ‘maverick’ timeframe 28 Sec … but no chance now he’s the Legend! 🙂
I see you’ve gone back to the (unrealistic) eurusd 0.7 spread though Gertrade? I thought you’d convinced yourself that spread of 2 is more realistic on eurusd?
03/01/2018 at 11:30 AM #64179I thought you’d convinced yourself that spread of 2 is more realistic on eurusd?
This is an oversight, I am convinced that the Spread of 0.7 is not realistic, but as Leo had treated it with a piece of code, I left like that.
I launched this v1.14 EURUSD strategy on ProOrder Demo Account, I wait to see the first results to make a comparison with the backtests.
The DJI v1.13 strategy on ProOrder Demo Account is profitable and I am fully satisfied (I’m still waiting a few days to publish results).
03/09/2018 at 3:32 AM #64871Hi everybody,
Already 1 week have passed and I publish you my first results of the DJI v1.13 (on CFD Wall Street Cash 2 $) on ProOrder Demo Account. It is very encouraging to see this equity curve grow. Long live this strategy !!! She seems to me robust. I will post other results of the equity curve week after week.
cordially
Gertrade03/09/2018 at 8:26 AM #64878 -
AuthorPosts
Find exclusive trading pro-tools on