Check of previous candles
- This topic has 31 replies, 3 voices, and was last updated 5 years ago by .
Similar topics:
Forums › ProRealTime English forum › ProOrder support › Check of previous candles
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):
1 2 |
xCloseW = (open+high+low+close)/4 xOpenW = (xOpenW[1]+xCloseW[1])/2 |
1 2 3 4 |
xCloseD = (open+high+low+close)/4 xOpenD = (xOpenD[1]+xCloseD[1])/2 xHighD = 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.
Hi together,
this is now my amended code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
DEFPARAM CUMULATEORDERS = false TIMEFRAME (Monthly, updateonclose) MClose = (open+high+low+close)/4 MOpen = (MOpen[1]+MClose[1])/2 MHigh = Max(max(high, MOpen), MClose) MLow = Min(min(Low, MOpen), MClose) IF (MOpen+MHigh+MLow+MClose)/4 > (MOpen[1]+MClose[1])/2 THEN MyMonth = 1 //BULLish ELSE MyMonth = -1 //BEARish ENDIF TIMEFRAME (Weekly, updateonclose) WClose = (open+high+low+close)/4 WOpen = (WOpen[1]+WClose[1])/2 WHigh = Max(max(high, WOpen), WClose) WLow = Min(min(Low, WOpen), WClose) IF (WOpen+WHigh+WLow+WClose)/4 > (WOpen[1]+WClose[1])/2 THEN MyWeek = 1 //BULLish ELSE MyWeek = -1 //BEARish ENDIF TIMEFRAME (Daily, updateonclose) XClose = (open+high+low+close)/4 XOpen = (XOpen[1]+XClose[1])/2 XHigh = Max(max(high, XOpen), XClose) XLow = Min(min(Low, XOpen), XClose) ONCE AlreadyTraded = 0 IF (XOpen+XHigh+XLow+XClose)/4 > (XOpen[1]+XClose[1])/2 THEN MyDay = 1 //BULLish ELSE MyDay = -1 //BEARish ENDIF ThisDay = OpenDayofWeek IF ThisDay = 1 AND Not OnMarket AND AlReadyTraded = 0 THEN //Monday GoLong = MyMonth = 1 AND MyWeek = 1 AND MyDay = -1 GoShort = MyMonth = -1 AND MyWeek = -1 AND MyDay = 1 IF GoLong THEN EntryPrice = XHigh BUY 1 CONTRACT AT EntryPrice LIMIT ELSIF GoShort THEN EntryPrice = XLow SELLSHORT 1 CONTRACT AT EntryPrice LIMIT ENDIF Sl = AverageTrueRange[2](close) Tp = Sl SET Stop Loss Sl SET Target Profit Tp ENDIF IF ThisDay = 2 AND Not OnMarket AND AlReadyTraded = 0 THEN //Tuesday GoLong = MyMonth = 1 AND MyWeek = 1 AND MyDay[1] = -1 AND MyDay[2] = -1 GoShort = MyMonth = -1 AND MyWeek = -1 AND MyDay[1] = 1 AND MyDay[2] = 1 IF GoLong THEN EntryPrice = XHigh BUY 1 CONTRACT AT EntryPrice LIMIT ELSIF GoShort THEN EntryPrice = XLow SELLSHORT 1 CONTRACT AT EntryPrice LIMIT ENDIF Sl = AverageTrueRange[2](close) Tp = Sl SET Stop Loss Sl SET Target Profit Tp ENDIF IF ThisDay = 3 AND Not OnMarket AND AlReadyTraded = 0 THEN //Wednesday GoLong = MyMonth = 1 AND MyWeek = 1 AND MyDay[1] = -1 AND MyDay[2] = -1 AND MyDay[3] = -1 GoShort = MyMonth = -1 AND MyWeek = -1 AND MyDay[1] = 1 AND MyDay[2] = 1 AND MyDay[3] = 1 IF GoLong THEN EntryPrice = XHigh BUY 1 CONTRACT AT EntryPrice LIMIT ELSIF GoShort THEN EntryPrice = XLow SELLSHORT 1 CONTRACT AT EntryPrice LIMIT ENDIF Sl = AverageTrueRange[2](close) Tp = Sl SET Stop Loss Sl SET Target Profit Tp ENDIF IF ThisDay = 4 AND Not OnMarket AND AlReadyTraded = 0 THEN //Thursday GoLong = MyMonth = 1 AND MyWeek = 1 AND MyDay[1] = -1 AND MyDay[2] = -1 AND MyDay[3] = -1 AND MyDay[4] = -1 GoShort = MyMonth = -1 AND MyWeek = -1 AND MyDay[1] = 1 AND MyDay[2] = 1 AND MyDay[3] = 1 AND MyDay[4] = 1 IF GoLong THEN EntryPrice = XHigh BUY 1 CONTRACT AT EntryPrice LIMIT ELSIF GoShort THEN EntryPrice = XLow SELLSHORT 1 CONTRACT AT EntryPrice LIMIT ENDIF Sl = AverageTrueRange[2](close) Tp = Sl SET Stop Loss Sl SET Target Profit Tp ENDIF IF ThisDay = 5 AND Not OnMarket AND AlReadyTraded = 0 THEN //Friday GoLong = MyMonth = 1 AND MyWeek = 1 AND MyDay[1] = -1 AND MyDay[2] = -1 AND MyDay[3] = -1 AND MyDay[4] = -1 AND MyDay[5] = -1 GoShort = MyMonth = -1 AND MyWeek = -1 AND MyDay[1] = 1 AND MyDay[2] = 1 AND MyDay[3] = 1 AND MyDay[4] = 1 AND MyDay[5] = 1 IF GoLong THEN EntryPrice = XHigh BUY 1 CONTRACT AT EntryPrice LIMIT ELSIF GoShort THEN EntryPrice = XLow SELLSHORT 1 CONTRACT AT EntryPrice LIMIT ENDIF Sl = AverageTrueRange[2](close) Tp = Sl SET Stop Loss Sl SET Target Profit Tp ENDIF IF ThisDay = 1 AND Not OnMarket THEN AlreadyTraded = 0 ENDIF IF OnMarket THEN AlreadyTraded = 1 ENDIF |
When Backtesting it the result looks very bad…
Find exclusive trading pro-tools on