Follow The Price, Dax 1h
Forums › ProRealTime English forum › ProOrder support › Follow The Price, Dax 1h
- This topic has 3 replies, 2 voices, and was last updated 5 years ago by Gianluca.
-
-
10/22/2018 at 4:11 PM #83343
Hi, i tried to code this simple sistem, the idea was took from others forum post, the buy order is placed when 2 average are in the same direction and last period was in trend.
I am searching for some idea to improve the sistem and found more winning trades.
TF 1h, Dax Cash CFD123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186//Gianluca Albino @ PRC//22/10/2018 Dax Cash 1h//Thank to PRC forum for many code and idea that i would never found anywhereDEFPARAM CUMULATEORDERS = FALSE//1////////////////////////////////////////////////////////once trailinstop= 1 //1 on - 0 offtrailingstart = 125 //trailing will start @trailinstart points profittrailingstep = 65 //trailing step to move the "stoploss"//////////////once breakeaven = 0 //1 on - 0 offstartBreakeven = 125 //how much pips/points in gain to activate the breakeven function?PointsToKeep = 100 //how much pips/points to keep in profit above of below our entry price when the breakeven is activated (beware of spread)////////////////////////////////////////////////////////////4/////////ONCE EXCURSION=0trailingstop = 90TIMEOK= TIME> 150000 AND TIME < 170000AVG=AVERAGE[40]avg2=exponentialaverage[5]gann=CALL "PRC_Gann HighLow Activator"CONDAVGSHORT=0CONDAVGLONG=0condavglong2=0CONDAVGshort2=0f=10FOR C = 1 TO fIF avg2[C-1] > AVG[C] THENCONDAVGLONG2 = 1elsecondavglong2=0endifNEXTFOR C = 1 TO fIF avg2[C-1] < AVG[C] THENCONDAVGshort2 = 1elseCONDAVGshort2=0endifNEXTFOR C = 1 TO fIF AVG[C-1] > AVG[C] THENCONDAVGLONG = 1elsecondavglong=0endifNEXTFOR C = 1 TO fIF AVG[C-1] < AVG[C] THENCONDAVGshort = 1elseCONDAVGshort=0endifNEXTC1=(CLOSE<gann) AND CONDAVGSHORT>0 AND CONDAVGSHORT2>0 //(CLOSE<AVG and avg<avg[1] and avg[1]<avg[2]) andC2=(CLOSE>gann)and CONDAVGLONG>0 and CONDAVGLONG2>0//CLOSE >AVG and avg>avg[1] and avg[1]>avg[2] and CLOSE>gannLO1=ABS((HIGH[1] - LOW[2]))LO2=ABS((HIGH[2]- LOW[3]))LO3=ABS((HIGH[3]- LOW[4]))AVGL=(LO1+LO2+LO3)/3NEXTMIN=HIGH-AVGLAV2=ABS(HIGH-LOW)AVGVOLS=(AV2[2]+AV2[1]+AV2)/3NEWMAX=NEXTMIN+AVGVOLSIF NOT ONMARKET THENIF C1 AND TIMEOK THENSELLSHORT 1 CONTRACT AT NEXTMIN-(10*PIPSIZE) STOPENDIFENDIFIF NOT ONMARKET THENIF C2 AND TIMEOK THENBUY 1 CONTRACT AT NEWMAX+(5*PIPSIZE) STOPENDIFENDIFSET TARGET PPROFIT 170SET STOP PLOSS 90if dayofweek=5 and time>210000 thenexitshort at marketsell at marketendif///2/////////////////////////////////////////////////reset the breakevenLevel when no trade are on marketIF NOT ONMARKET THENbreakevenLevel=0ENDIF//3//////////////////////////////test if the price have moved favourably of "startBreakeven" points alreadyif breakeaven>0 thenIF onmarket AND close-tradeprice(1)>=startBreakeven*pipsize THEN//calculate the breakevenLevelbreakevenLevel = tradeprice(1)+PointsToKeep*pipsizeENDIF//place the new stop orders on market at breakevenLevelIF breakevenLevel>0 THENSELL AT breakevenLevel STOPENDIFendif//************************************************************************//trailing stop functionif trailinstop>0 then//reset the stoploss valueIF NOT ONMARKET THENnewSL=0ENDIF//manage long positionsIF LONGONMARKET THEN//first move (breakeven)IF newSL=0 AND close-tradeprice(1)>=trailingstart*pipsize THENnewSL = tradeprice(1)+trailingstep*pipsizeENDIF//next movesIF newSL>0 AND close-newSL>=trailingstep*pipsize THENnewSL = newSL+trailingstep*pipsizeENDIFENDIF//manage short positionsIF SHORTONMARKET THEN//first move (breakeven)IF newSL=0 AND tradeprice(1)-close>=trailingstart*pipsize THENnewSL = tradeprice(1)-trailingstep*pipsizeENDIF//next movesIF newSL>0 AND newSL-close>=trailingstep*pipsize THENnewSL = newSL-trailingstep*pipsizeENDIFENDIF//stop order to exit the positionsIF newSL>0 THENSELL AT newSL STOPEXITSHORT AT newSL STOPENDIFendif/////////////////////////////4// MFE EXCURSION//////trailing stop//resetting variables when no trades are on marketif not onmarket thenMAXPRICE = 0MINPRICE = closepriceexit = 0endifIF EXCURSION>0 THEN//case SHORT orderif shortonmarket thenMINPRICE = MIN(MINPRICE,close) //saving the MFE of the current tradeif tradeprice(1)-MINPRICE>=trailingstop*pointsize then //if the MFE is higher than the trailingstop thenpriceexit = MINPRICE+trailingstop*pointsize //set the exit price at the MFE + trailing stop price levelendifendif//case LONG orderif longonmarket thenMAXPRICE = MAX(MAXPRICE,close) //saving the MFE of the current tradeif MAXPRICE-tradeprice(1)>=trailingstop*pointsize then //if the MFE is higher than the trailingstop thenpriceexit = MAXPRICE-trailingstop*pointsize //set the exit price at the MFE - trailing stop price levelendifendif//exit on trailing stop price levelsif onmarket and priceexit>0 thenEXITSHORT AT priceexit STOPSELL AT priceexit STOPendifENDIF1 user thanked author for this post.
10/23/2018 at 11:41 AM #83384Hi,
If you have a calculated Stop order on a limited hour graph on Friday 20:00 hr, garantueed by PRT, will this last during the whole weekend ? There are more real trading hours after 20:00 before the weekend begins, and a calculated Stop last just one bar.
KR Jan
=========== APPENDIX If needed, further explanation of my question ==============================================
Pro Real Time offers the opportunity to set a auto trading stop live with a garantueed stops, see attachet JPEG file, see the tickbox “Use garantueed Stops”
If you are using this, the garantueed stop is also applicable for the programmed trailing stops (see below), as far as I could see at my strategy, the garantueed stops moves up in a long position when the price moves higher.
To my understanding the programmed STOP last only one bar, after each bar it needs to be set again by calculating a new STOP on the next bar, which is done in the code below.
If you limit the trading time in PRT, the bars in the graph will be less than the actual trading bars : for example set trading time in the graph 8:00 hr till 22:00 hr for the DAX means that the hourly bars in the graph are less then in actual trading.
If you are using graph trading times, will the last programmed STOP of the day / before the weekend remains till the next graph based calculated STOP or erased by the next trading bar ?
Example Calculated stop Friday 22:00 hr = 11.100 garantueed by PRT , will this last during the whole weekend ?
Next calculated stop Monday 8:00 hr = 11.000
Programmed trailng stop123456789101112131415161718192021222324252627282930//resetting variables when no trades are on marketif not onmarket thenMAXPRICE = 0MINPRICE = closepriceexit = 0endifIF EXCURSION>0 THEN//case SHORT orderif shortonmarket thenMINPRICE = MIN(MINPRICE,close) //saving the MFE of the current tradeif tradeprice(1)-MINPRICE>=trailingstop*pointsize then //if the MFE is higher than the trailingstop thenpriceexit = MINPRICE+trailingstop*pointsize //set the exit price at the MFE + trailing stop price levelendifendif//case LONG orderif longonmarket thenMAXPRICE = MAX(MAXPRICE,close) //saving the MFE of the current tradeif MAXPRICE-tradeprice(1)>=trailingstop*pointsize then //if the MFE is higher than the trailingstop thenpriceexit = MAXPRICE-trailingstop*pointsize //set the exit price at the MFE - trailing stop price levelendifendif//exit on trailing stop price levelsif onmarket and priceexit>0 thenEXITSHORT AT priceexit STOPSELL AT priceexit STOPendifENDIF10/23/2018 at 12:10 PM #8338610/25/2018 at 12:34 PM #83505 -
AuthorPosts
Find exclusive trading pro-tools on