Pause trading till next open when stop loss hit
Forums › ProRealTime English forum › ProOrder support › Pause trading till next open when stop loss hit
- This topic has 10 replies, 3 voices, and was last updated 3 years ago by Fran55.
-
-
06/24/2020 at 10:56 AM #13700106/24/2020 at 11:46 AM #137006
There you go:
12345678910111213141516171819Once TradeON = 1If TradeON = 0 thenTradeON = 1EndifIf StrategyProfit < StrategyProfit[1] thenTradeON = 0Endif..If MyLongConditions and TradeON ThenBuy 1 Contract at MarketEndif..If MyShortConditions and TradeON ThenBuy 1 Contract at MarketEndif..1 user thanked author for this post.
06/25/2020 at 8:20 PM #137175Hi Robert,
I made an attempt at inserting the code but it is not performing as expected still multiple losses on same day. D2 is the original equity curve before code was inserted please take a look at the code thanks.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125// M5// SPREAD 1.5// by BALMORA 74 – FEBRUARY 2019DEFPARAM CumulateOrders = falseDEFPARAM Preloadbars = 50000//VARIABLESCtimeA = time >= 080000 and time <= 180000CtimeB = time >= 080000 and time <= 180000// TAILLE DES POSITIONSONCE PositionSizeLong = 1ONCE PositionSizeShort = 1//STRATEGIE//VECTEUR = CALCUL DE L’ANGLEONCE PeriodeA = 10ONCE nbChandelierA= 15MMA = Exponentialaverage[PeriodeA](close)ADJASUROPPO = (MMA-MMA[nbchandelierA]*pipsize) / nbChandelierAANGLE = (ATAN(ADJASUROPPO)) //FONCTION ARC TANGENTECondBuy1 = ANGLE >= 45CondSell1 = ANGLE <= – 37//VECTEUR = CALCUL DE LA PENTE ET SA MOYENNE MOBILEONCE PeriodeB = 20ONCE nbChandelierB = 35lag = 5MMB = Exponentialaverage[PeriodeB](close)pente = (MMB-MMB[nbchandelierB]*pipsize) / nbchandelierBtrigger = Exponentialaverage[PeriodeB+lag](pente)CondBuy2 = (pente > trigger) AND (pente < 0)CondSell2 = (pente CROSSES UNDER trigger) AND (pente > -1)Once TradeON = 1If TradeON = 0 thenTradeON = 1EndifIf StrategyProfit < StrategyProfit[1] thenTradeON = 0EndifIf condbuy and TradeON ThenBuy 1 Contract at MarketEndifIf condsell and TradeON ThenBuy 1 Contract at MarketEndif//ENTREES EN POSITIONCONDBUY = CondBuy1 and CondBuy2 and CTimeACONDSELL = CondSell1 and CondSell2 and CtimeB//POSITION LONGUEIF CONDBUY THENbuy PositionSizeLong contract at marketSET STOP %LOSS 1.3SET STOP pLOSS 80ENDIF//POSITION COURTEIF CONDSELL THENSellshort PositionSizeShort contract at marketSET STOP %LOSS 1.3SET STOP pLOSS 80ENDIF//VARIABLES STOP SUIVEURONCE trailingStopType = 1 // Trailing Stop – 0 OFF, 1 ONONCE trailingstoplong = 4 // Trailing Stop Atr Relative DistanceONCE trailingstopshort = 4 // Trailing Stop Atr Relative DistanceONCE atrtrailingperiod = 14 // Atr parameter ValueONCE minstop = 0 // Minimum Trailing Stop Distance// TRAILINGSTOP//———————————————-atrtrail = AverageTrueRange[atrtrailingperiod]((close/10)*pipsize)/1000trailingstartl = round(atrtrail*trailingstoplong)trailingstartS = round(atrtrail*trailingstopshort)if trailingStopType = 1 THENTGL =trailingstartlTGS=trailingstartsif not onmarket thenMAXPRICE = 0MINPRICE = closePREZZOUSCITA = 0ENDIFif longonmarket thenMAXPRICE = MAX(MAXPRICE,close)if MAXPRICE-tradeprice(1)>=TGL*pointsize thenif MAXPRICE-tradeprice(1)>=MINSTOP thenPREZZOUSCITA = MAXPRICE-TGL*pointsizeELSEPREZZOUSCITA = MAXPRICE – MINSTOP*pointsizeENDIFENDIFENDIFif shortonmarket thenMINPRICE = MIN(MINPRICE,close)if tradeprice(1)-MINPRICE>=TGS*pointsize thenif tradeprice(1)-MINPRICE>=MINSTOP thenPREZZOUSCITA = MINPRICE+TGS*pointsizeELSEPREZZOUSCITA = MINPRICE + MINSTOP*pointsizeENDIFIF ONMARKET AND DAYOFWEEK=5 AND TIME>=210000 THENSELL AT MARKETEXITSHORT AT MARKETENDIFENDIFENDIFif onmarket and PREZZOUSCITA>0 thenEXITSHORT AT PREZZOUSCITA STOPSELL AT PREZZOUSCITA STOPENDIFENDIF06/25/2020 at 8:25 PM #137179You asked to wait 1 bar, that’s what it’s doing.
If you want to pause the whole day then replace line 2 of my code with
1If IntraDayBarIndex = 0 thenPlease, always use the ‘Insert PRT Code’ button when putting code in your posts to make it easier for others to read.
Thank you 🙂
1 user thanked author for this post.
06/26/2020 at 3:41 PM #137261123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135// ROBOT VECTORIAL DAX// M5// SPREAD 1.5// by BALMORA 74 - FEBRUARY 2019DEFPARAM CumulateOrders = falseDEFPARAM Preloadbars = 50000//VARIABLESCtimeA = time >= 080000 and time <= 180000CtimeB = time >= 080000 and time <= 180000// TAILLE DES POSITIONSONCE PositionSizeLong = 1ONCE PositionSizeShort = 1//STRATEGIE//VECTEUR = CALCUL DE L'ANGLEONCE PeriodeA = 10ONCE nbChandelierA= 15MMA = Exponentialaverage[PeriodeA](close)ADJASUROPPO = (MMA-MMA[nbchandelierA]*pipsize) / nbChandelierAANGLE = (ATAN(ADJASUROPPO)) //FONCTION ARC TANGENTECondBuy1 = ANGLE >= 45CondSell1 = ANGLE <= - 37//VECTEUR = CALCUL DE LA PENTE ET SA MOYENNE MOBILEONCE PeriodeB = 20ONCE nbChandelierB = 35lag = 5MMB = Exponentialaverage[PeriodeB](close)pente = (MMB-MMB[nbchandelierB]*pipsize) / nbchandelierBtrigger = Exponentialaverage[PeriodeB+lag](pente)CondBuy2 = (pente > trigger) AND (pente < 0)CondSell2 = (pente CROSSES UNDER trigger) AND (pente > -1)Once TradeON = 1IF IntraDayBarIndex = 0 THENTradeON = 1EndifIf StrategyProfit < StrategyProfit[1] thenTradeON = 0EndifIf CONDBUY and TradeON ThenBuy 1 Contract at MarketEndifIf CONDSELL and TradeON ThenBuy 1 Contract at MarketEndif//ENTREES EN POSITIONCONDBUY = CondBuy1 and CondBuy2 and CTimeA and TradeONCONDSELL = CondSell1 and CondSell2 and CtimeB and TradeON//POSITION LONGUEIF CONDBUY THENbuy PositionSizeLong contract at marketSET STOP %LOSS 1.3SET STOP pLOSS 80ENDIF//POSITION COURTEIF CONDSELL THENSellshort PositionSizeShort contract at marketSET STOP %LOSS 1.3SET STOP pLOSS 80ENDIF//VARIABLES STOP SUIVEURONCE trailingStopType = 1 // Trailing Stop - 0 OFF, 1 ONONCE trailingstoplong = 4 // Trailing Stop Atr Relative DistanceONCE trailingstopshort = 4 // Trailing Stop Atr Relative DistanceONCE atrtrailingperiod = 14 // Atr parameter ValueONCE minstop = 0 // Minimum Trailing Stop Distance// TRAILINGSTOP//----------------------------------------------atrtrail = AverageTrueRange[atrtrailingperiod]((close/10)*pipsize)/1000trailingstartl = round(atrtrail*trailingstoplong)trailingstartS = round(atrtrail*trailingstopshort)if trailingStopType = 1 THENTGL =trailingstartlTGS=trailingstartsif not onmarket thenMAXPRICE = 0MINPRICE = closePREZZOUSCITA = 0ENDIFif longonmarket thenMAXPRICE = MAX(MAXPRICE,close)if MAXPRICE-tradeprice(1)>=TGL*pointsize thenif MAXPRICE-tradeprice(1)>=MINSTOP thenPREZZOUSCITA = MAXPRICE-TGL*pointsizeELSEPREZZOUSCITA = MAXPRICE - MINSTOP*pointsizeENDIFENDIFENDIFif shortonmarket thenMINPRICE = MIN(MINPRICE,close)if tradeprice(1)-MINPRICE>=TGS*pointsize thenif tradeprice(1)-MINPRICE>=MINSTOP thenPREZZOUSCITA = MINPRICE+TGS*pointsizeELSEPREZZOUSCITA = MINPRICE + MINSTOP*pointsizeENDIFIF ONMARKET AND DAYOFWEEK=5 AND TIME>=210000 THENSELL AT MARKETEXITSHORT AT MARKETENDIFENDIFENDIFif onmarket and PREZZOUSCITA>0 thenEXITSHORT AT PREZZOUSCITA STOPSELL AT PREZZOUSCITA STOPENDIFENDIFHi Robert, Thanks I made the suggested replacement and I am still getting subsequent trades opening that day, thanks for your help.
06/26/2020 at 3:57 PM #137262You did not add TradeON to your conditions (line 10 and 15 in my code).
Add it to your lines 67 and 75.
My first code was made to wait ONE bar, while my next suggestions was to wait ONE day (till new day opens).
1 user thanked author for this post.
06/29/2020 at 9:52 AM #13746406/29/2020 at 10:21 AM #137469It’s beacause STRATEGYPROFIT (like ONMARKET, etc…) take a bar to be able to update its status, so when you do Stop & Reverse ProOrder can’t know whether there was a gain or a loss.
To achieve the correct result you should add
1and Not OnMarketto your conditions to enter a trade.
In case you want to do Stop & Reverse you need to take note of that and accept that you will probably suffer TWO losses before there’s a temporary stop.At line 52 and 57 you always use BUY both for long and short conditions, is that intentional?
06/29/2020 at 11:03 PM #13758606/30/2020 at 12:05 AM #137589If you use and Not OnMarket it will not work!
06/30/2020 at 10:43 AM #137658 -
AuthorPosts
Find exclusive trading pro-tools on