Indicator for setting previous day HLOC
Forums › ProRealTime English forum › ProBuilder support › Indicator for setting previous day HLOC
- This topic has 5 replies, 2 voices, and was last updated 2 years ago by 2point1.
Tagged: Display prior OHLC, ohlc
-
-
11/24/2021 at 8:56 AM #182180
Hi,
Currently each morning I set previous day high (PDH), low (PDL), market open (PDMO) and market close (PDC) manually by adding lines to the chart. Since I am following 20+ markets and have custom alerts setup, it’s quite tedious to do this task every day. When the alert comes in, I check the relation between price/alert and the PD lines. Going through the code, I can see that I can add an indicator with DRAWHLINE and DRAWTEXT to achieve this, but I could not find a way to define a time frame for the code to look into, i.e. e.g. when looking at DAX I want the indicator to only look at the bars between 9:00-17:30. Since DAX is an index the data available is 24/6, but this is not what I want the Indicator to take into the consideration.
I was thinking of using IF statement to check the bar data, such as time and date and compare it with the requirements, but unfortunately I cannot find an instruction or peace of code which could help me to verify the bar datetime value.
If anyone has a better idea how to achieve the required I would be very grateful.
Here is a view of the chart and lines I have currently setup manually.
11/24/2021 at 9:10 AM #182184Also to add, I would like the Indicator to use the calculation from specific time frame, e.g. 5 min time frame, so that if I change the time frame to 1 min, it is not recalculating the values. I just noticed, that if I use the example code provided in one of the articles, it will recalculate the values:
Example123456789defparam drawonlastbaronly = truehh = highest[15](high)Voffset = 2*pipsizeDRAWHLINE(hh)coloured(0,200,0)DRAWTEXT("PDH",barindex-30,hh+Voffset,SansSerif,Standard, 12)coloured(0,153,0)RETURN11/24/2021 at 9:19 AM #182185It will ALWAYS recalculates itself at any change, be it the TF, the number of units or any of its settings.
This is the correct behavior.
You will have to use IF…ENDIF to select the time window you are interested in.
Use the correct forum, for indicators it’s ProBuilder. I moved it from General trading discussion.
Thank you 🙂
11/24/2021 at 9:29 AM #18218711/24/2021 at 11:14 AM #182197There you go:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566// DAX example//// the TF used must show candles that close on both the starting and ending time// (in this case it must be a 30-minute TF or lower, but not, say, 7 minutes, as its candles do not close at HH:30)//DEFPARAM DrawOnLastBarOnly = trueONCE StartTime = 090000 //Time window (start)ONCE EndTime = 173000 //Time windows (end)ONCE PDH = high //Previous Day HighONCE PDL = low //Previous DayLowONCE DH = high //current Day HighONCE DL = low //current Day LowONCE PDMO = 0 //Previous Day Market OpenONCE MO = 0 //current Day Market OpenONCE PDC = 0 //Previous Day CloseONCE PDMObar = 0ONCE PDHbar = 0ONCE PDLbar = 0ONCE PDCbar = 0ONCE MObar = 0ONCE DHbar = 0ONCE DLbar = 0HR = highest[4](range)MyATR = AverageTrueRange[100](close)Offset1 = MyATR * 1.5Offset2 = MyATRIF OpenTime = StartTime THENPDMO = MOPDMObar = MObarMO = openMObar = BarIndexPDH = DHPDHbar = DHbarDH = highDHbar = BarIndexPDL = DLPDLbar = DLbarDL = lowDLbar = BarIndexENDIFIF OpenTime = EndTime THENPDC = closePDCbar = BarIndexENDIFDH = max(DH,high)DL = min(DL,low)IF DH <> DH[1] THENDHbar = BarIndexENDIFIF DL <> DL[1] THENDLbar = BarIndexENDIFIF PDCbar THENDrawText("PDMO #PDMO#",PDMObar,PDMO + Offset1 + HR) coloured(255,0,0,255) //RedDrawText("↓",PDMObar,PDMO + HR) coloured(255,0,0,255)//DrawText("PDC #PDC#",PDCbar,PDC + Offset1 + HR) coloured(0,128,0,155) //GreenDrawText("↓",PDCbar,PDC + HR) coloured(0,128,0,155)//DrawText("PDH #PDH#",PDHbar,PDH + Offset1) coloured(0,0,255,255) //BlueDrawText("↓",PDHbar,PDH + Offset2) coloured(0,0,255,255)//DrawText("PDL #PDL#",PDLbar,PDL - Offset1) coloured(0,0,255,255) //BlueDrawText("↑",PDLbar,PDL - Offset2) coloured(0,0,255,255)ENDIFRETURN1 user thanked author for this post.
11/30/2021 at 7:56 AM #182508Thank you! This is a good start. Will tweak it a bit and post it here for others to use.
1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on