Check of previous candles
Forums › ProRealTime English forum › ProOrder support › Check of previous candles
- This topic has 31 replies, 3 voices, and was last updated 6 years ago by
Marc.
-
-
07/30/2018 at 2:34 PM #77080
Lines 15 and 23 reference MONTHLY HA candlesticks as defined in lines 3-6. Since you are in the Weekly and Daily TF, you should define HA candlesticks also for those TF’s.
First you’ll have to remove lines 5-6, since when you later want to refernce the high and low of a HA candlestick you should, I guess, reference the xHighD and xLowD from the DAILY definitions.
For the WEEKLY TF you should add, after line 14 (before line 15):
12xCloseW = (open+high+low+close)/4xOpenW = (xOpenW[1]+xCloseW[1])/2For the DAILY TF you’ll have to add 4 lines, after line 22 (before line 23):1234xCloseD = (open+high+low+close)/4xOpenD = (xOpenD[1]+xCloseD[1])/2xHighD = Max(max(high, xOpenD), xCloseD)xLowD = Min(min(Low, xOpenD), xClosed)then you’ll have to change references in lines 15 and 23 and in lines 33,36,49,52,65,68,81,84,97 and 100.
But I think also lines with reference to MyDay, MyDay[1] and so on… must be incorrect, but I cannot tell what because the code is too long, and difficult to read and debug.
As I suggested at the beginning, before making a single change you should be confident with the current code. When you’ll be confident with your first change you may add one more (not trwo or three, just one at a time).
Use GRAPH to debug.
08/06/2018 at 2:04 PM #77639Hi together,
this is now my amended code:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125DEFPARAM CUMULATEORDERS = falseTIMEFRAME (Monthly, updateonclose)MClose = (open+high+low+close)/4MOpen = (MOpen[1]+MClose[1])/2MHigh = Max(max(high, MOpen), MClose)MLow = Min(min(Low, MOpen), MClose)IF (MOpen+MHigh+MLow+MClose)/4 > (MOpen[1]+MClose[1])/2 THENMyMonth = 1 //BULLishELSEMyMonth = -1 //BEARishENDIFTIMEFRAME (Weekly, updateonclose)WClose = (open+high+low+close)/4WOpen = (WOpen[1]+WClose[1])/2WHigh = Max(max(high, WOpen), WClose)WLow = Min(min(Low, WOpen), WClose)IF (WOpen+WHigh+WLow+WClose)/4 > (WOpen[1]+WClose[1])/2 THENMyWeek = 1 //BULLishELSEMyWeek = -1 //BEARishENDIFTIMEFRAME (Daily, updateonclose)XClose = (open+high+low+close)/4XOpen = (XOpen[1]+XClose[1])/2XHigh = Max(max(high, XOpen), XClose)XLow = Min(min(Low, XOpen), XClose)ONCE AlreadyTraded = 0IF (XOpen+XHigh+XLow+XClose)/4 > (XOpen[1]+XClose[1])/2 THENMyDay = 1 //BULLishELSEMyDay = -1 //BEARishENDIFThisDay = OpenDayofWeekIF ThisDay = 1 AND Not OnMarket AND AlReadyTraded = 0 THEN //MondayGoLong = MyMonth = 1 AND MyWeek = 1 AND MyDay = -1GoShort = MyMonth = -1 AND MyWeek = -1 AND MyDay = 1IF GoLong THENEntryPrice = XHighBUY 1 CONTRACT AT EntryPrice LIMITELSIF GoShort THENEntryPrice = XLowSELLSHORT 1 CONTRACT AT EntryPrice LIMITENDIFSl = AverageTrueRange[2](close)Tp = SlSET Stop Loss SlSET Target Profit TpENDIFIF ThisDay = 2 AND Not OnMarket AND AlReadyTraded = 0 THEN //TuesdayGoLong = MyMonth = 1 AND MyWeek = 1 AND MyDay[1] = -1 AND MyDay[2] = -1GoShort = MyMonth = -1 AND MyWeek = -1 AND MyDay[1] = 1 AND MyDay[2] = 1IF GoLong THENEntryPrice = XHighBUY 1 CONTRACT AT EntryPrice LIMITELSIF GoShort THENEntryPrice = XLowSELLSHORT 1 CONTRACT AT EntryPrice LIMITENDIFSl = AverageTrueRange[2](close)Tp = SlSET Stop Loss SlSET Target Profit TpENDIFIF ThisDay = 3 AND Not OnMarket AND AlReadyTraded = 0 THEN //WednesdayGoLong = MyMonth = 1 AND MyWeek = 1 AND MyDay[1] = -1 AND MyDay[2] = -1 AND MyDay[3] = -1GoShort = MyMonth = -1 AND MyWeek = -1 AND MyDay[1] = 1 AND MyDay[2] = 1 AND MyDay[3] = 1IF GoLong THENEntryPrice = XHighBUY 1 CONTRACT AT EntryPrice LIMITELSIF GoShort THENEntryPrice = XLowSELLSHORT 1 CONTRACT AT EntryPrice LIMITENDIFSl = AverageTrueRange[2](close)Tp = SlSET Stop Loss SlSET Target Profit TpENDIFIF ThisDay = 4 AND Not OnMarket AND AlReadyTraded = 0 THEN //ThursdayGoLong = MyMonth = 1 AND MyWeek = 1 AND MyDay[1] = -1 AND MyDay[2] = -1 AND MyDay[3] = -1 AND MyDay[4] = -1GoShort = MyMonth = -1 AND MyWeek = -1 AND MyDay[1] = 1 AND MyDay[2] = 1 AND MyDay[3] = 1 AND MyDay[4] = 1IF GoLong THENEntryPrice = XHighBUY 1 CONTRACT AT EntryPrice LIMITELSIF GoShort THENEntryPrice = XLowSELLSHORT 1 CONTRACT AT EntryPrice LIMITENDIFSl = AverageTrueRange[2](close)Tp = SlSET Stop Loss SlSET Target Profit TpENDIFIF ThisDay = 5 AND Not OnMarket AND AlReadyTraded = 0 THEN //FridayGoLong = MyMonth = 1 AND MyWeek = 1 AND MyDay[1] = -1 AND MyDay[2] = -1 AND MyDay[3] = -1 AND MyDay[4] = -1 AND MyDay[5] = -1GoShort = MyMonth = -1 AND MyWeek = -1 AND MyDay[1] = 1 AND MyDay[2] = 1 AND MyDay[3] = 1 AND MyDay[4] = 1 AND MyDay[5] = 1IF GoLong THENEntryPrice = XHighBUY 1 CONTRACT AT EntryPrice LIMITELSIF GoShort THENEntryPrice = XLowSELLSHORT 1 CONTRACT AT EntryPrice LIMITENDIFSl = AverageTrueRange[2](close)Tp = SlSET Stop Loss SlSET Target Profit TpENDIFIF ThisDay = 1 AND Not OnMarket THENAlreadyTraded = 0ENDIFIF OnMarket THENAlreadyTraded = 1ENDIFWhen Backtesting it the result looks very bad…
-
AuthorPosts
Find exclusive trading pro-tools on