Mid Daily Range BO Dax mtf
Forums › ProRealTime English forum › ProOrder support › Mid Daily Range BO Dax mtf
- This topic has 2 replies, 2 voices, and was last updated 6 years ago by robertogozzi.
-
-
09/06/2018 at 11:05 AM #79871
A couple of days ago I replied to a topic by @Mert (https://www.prorealcode.com/topic/median-previous-hour-priceline-in-a-1-minute-chart/#post-79723) about mid range and decided to experiment some code on daily mid range Break Out on a 1-minute charts using the newly supported MTF.
It simply detects yesterday’s mid range, then waits the 1-minute chart to cross over/under it, provided there’s been a previous crossover/under on 1-hour charts within a few bars (I want to eneter the second break out). This code may lack other indicators and/or trailing stops, but I think it’s a good exercise. I tested it on Dax, Bund and Cac40 and it shows some performance, while it seems not to be working good on fx pairs:
Mid Daily Range BO Dax mtf12345678910111213141516171819202122232425262728293031// Mid Daily Range BO Dax mtfTIMEFRAME (default)DaysForbidden = OpenDayOfWeek < 1 OR OpenDayOfWeek > 5TimeForbidden = OpenTime < 100000 OR OpenTime > 170000 //10 - 17////////////////////////////////////////////////////////////////////////TIMEFRAME (Daily, updateonclose)MidRange = low + (range / 2)////////////////////////////////////////////////////////////////////////TIMEFRAME (1 hour, updateonclose) //a previous BreakOut on H1 within a few bars is requiredONCE LookBack = 5 //5PreviousHI = summation[LookBack](high[1] >= MidRange)PreviousLO = summation[LookBack](low[1] <= MidRange)////////////////////////////////////////////////////////////////////////TIMEFRAME (default)// LONG tradesa0 = PreviousHI //previous BO oka1 = close CROSSES OVER MidRange //crossover againax = a0 AND a1IF ax AND Not OnMarket AND Not DaysForbidden AND Not TimeForbidden THENBUY 1 CONTRACT AT MARKETENDIF// SHORT tradesb0 = PreviousLO //previous BO okb1 = close CROSSES UNDER MidRange //crossunder againbx = b0 AND b1IF bx AND Not Onmarket AND Not DaysForbidden AND Not TimeForbidden THENSELLSHORT 1 CONTRACT AT MARKETENDIF// Sl & TpSET TARGET pPROFIT 50 //50SET STOP pLOSS 50 //5009/09/2018 at 8:10 PM #80042with MFE trailing123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263// Mid Daily Range BO Dax mtfTIMEFRAME (default)DaysForbidden = OpenDayOfWeek < 1 OR OpenDayOfWeek > 5TimeForbidden = OpenTime < 100000 OR OpenTime > 170000 //10 - 17////////////////////////////////////////////////////////////////////////TIMEFRAME (Daily, updateonclose)MidRange = low + (range / 2)////////////////////////////////////////////////////////////////////////TIMEFRAME (1 hour, updateonclose) //a previous BreakOut on H1 within a few bars is requiredONCE LookBack = 5 //5PreviousHI = summation[LookBack](high[1] >= MidRange)PreviousLO = summation[LookBack](low[1] <= MidRange)////////////////////////////////////////////////////////////////////////TIMEFRAME (default)// LONG tradesa0 = PreviousHI //previous BO oka1 = close CROSSES OVER MidRange //crossover againax = a0 AND a1IF ax AND Not OnMarket AND Not DaysForbidden AND Not TimeForbidden THENBUY 1 CONTRACT AT MARKETENDIF// SHORT tradesb0 = PreviousLO //previous BO okb1 = close CROSSES UNDER MidRange //crossunder againbx = b0 AND b1IF bx AND Not Onmarket AND Not DaysForbidden AND Not TimeForbidden THENSELLSHORT 1 CONTRACT AT MARKETENDIF// Sl & TpSET TARGET pPROFIT 50 //50SET STOP pLOSS 50 //50//trailing stoptrailingstop = 7//resetting variables when no trades are on marketif not onmarket thenMAXPRICE = 0MINPRICE = closepriceexit = 0endif//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 STOPendifHiRoberto ,
congrats for your strategy , I added a MFE trailing with DAX 5 Eur
What do you think ?
09/10/2018 at 11:24 PM #80133Trailing stop is excellent. Experimenting may result in great improvements.
You may try different values for SL & TP or even change time frames.
-
AuthorPosts
Find exclusive trading pro-tools on