Current location | Thread information | |
![]() ![]() ![]() ![]() ![]() ![]() |
Last Activity 7/6/2025 3:47 AM 2 replies, 2434 viewings |
|
|
Printer friendly version |
^ Top | |||
RLB![]() Regular ![]() ![]() Posts: 58 Joined: 8/23/2007 Location: Ladera Ranch, CA ![]() |
I need help with 2 issues. 1) Matt can you post the Floor Pivot (All Levels, 0) and Floor Pivot Daily (All Levels, 0) indicators that are part of the Trading Secrets I download in NC please? I see an indicator in OmniLanguage IDE called FLOOR_PIV(X) referenced in the different systems. Looks like each system is used to initiate a trade to fade each of the major floor pivot levels. Based on how FLOOR_PIV(X) are used in each of the systems (FLR1, FLR2,...FLRTCI) I think I can figure out how to use it and set Parameters but it would be great (as much for education on writing indicators) to see how someone knowledgeable with code does it as I am early on the learning curve. It will also go a long way to answering the numerous questions in the next issue. 2) I am struggling to understand how to write the nest necessary for an indicator/system referencing 2 time periods. Looking at Mark Fisher's ACD method (The Logical Trader) together with Floor Pivots to trade intraday, say 15 minute bars, I need to include indicators that will reference price action in both a single bar as well as the entire previous day. The Floor Pivots reference the prev day's HLC, and Fisher's ACD Open Range references the high and low of the first 15 minutes (ideally 20 minutes but 15 is what I trade and so is acceptable). On a chart I then would like the indicator to plot horizontal lines across the entire day for the Floor Pivots and Open Bar High and Low (Open Range) as well other levels that will be a function of these. Below is how another OT NC member coded this indicator but the results of the the Floor Pivot calc seem to miss the first bar of the previous day. (Perhaps this comes from the nBar counting function I struggle to understand below?). The OmniTrader Indicator is accurate. I am very curious to see how it is written compared to this. Further, I don't quite understand the counting function. The loop starts with a requirement that the time be after the open (which I define as Paramater "6:30" since I am in California) but before 1 minute after the open. Presumably this is to make a single calc for the day? The count uses nBar (defined earlier as nBar[1] - does this reset it to 0? The count function then starts as nBar = Bar - nBar - 1, then the Floor Pivot calcs are made, then nBar = nBar[1], then if nBar[1] >0 the Floor Pivot figures are plotted as horizontal lines starting X1 = nBar to X2 = Bar -1. After the loop closes then: nBar = Bar. Does "Bar" reference the number of bars since the open so that the 1st 15 minutes - 6:30 - 6:45 (in my 15 min chart) is 1, then 6:45-7:00 is 2,...etc. I assume the very first nBar = nBar[1] resets it to zero (or does this reference all the number of bars in the previous day such that the Floor Pivot calcs the HLC of the entire previous day as it should? If the first nBar = nBar[1] resets nBar to 0 then the first nBar = Bar - nBar -1 becomes nBar = 1 (bar 1) - 0 (my assumption) - 1 = 0 and the second nBar = 2 (bar 2) - 0 (from last calc) - 1 = 1 and the 3rd nBar = 3 (bar 3) - 1 (from last calc) - 1 = 1. This is what I don't understand. Is this the most efficient way to write this loop? Note that I in no way imply anything less than complete respect and gratitude to the author and hope I haven't offended him by referencing this however I really need help at this point. As an aside, in general do you recommend imbedding plotting functions within a system or keeping them separate as indicators? Last, is it necessary to "Return" something at the end of each indicator? Below is shown "Return 0". I assume "0" is used because there are so many calcs in this indicator? Here is the indicator. I modified it slightly to simplify the discussion. Any help clarifying my confusion above would be greatly appreciated! #Indicator '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ' Daily ACD method Floor Pivots on intra-day charts '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ' Notes: Adjustable Domicile Beginning of Day '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #PARAM "Open_Hour", 6,0,23 'Note that I am in California #PARAM "Open_Minute", 30,0,59 #Param "Opening_Range_Bars", 4,1,60 'Adjusted for my 15 minute chart #Param "Draw_Pivot_Range", 1,0,1 'Choose 1 to include Floor Pivot Dim HV, LV, CL as Single Dim Pivot, PDiff, PRU, PRL as Single Dim X1, X2, nBar as Integer nBar = nBar[1] PRU = PRU[1] Pivot = Pivot[1] PRL = PRL[1] If (AfterTime(Open_Hour, Open_Minute) and BeforeTime(Open_Hour, Open_Minute + 1)) _ or (Bar = C.Length - 1) Then nBar = Bar - nBar - 1 HV = HHV(nBar)[1] LV = LLV(nBar)[1] CL = C[1] Pivot = (HV + LV + CL) / 3 PDiff = ABS(Pivot - ((HV+LV)/2)) PRU = Pivot + PDiff PRL = Pivot - PDiff nBar = nBar[1] If nBar[1]>0 Then X1 = nBar X2 = Bar - 1 If Draw_Pivot_Range=1 Then PlotPriceTrendLine("PivRangeHi", X1, PRU[1], X2, PRU[1]) PlotPriceTrendLine("PivotPoint", X1, Pivot[1], X2, Pivot[1]) PlotPriceTrendLine("PivRangeLo", X1, PRL[1], X2, PRL[1]) End If End If nBar = Bar End If Return 0 [Edited by RLB on 1/17/2008 12:53 PM] | ||
^ Top | |||
Matthew Greenslet![]() Idol ![]() ![]() ![]() ![]() Posts: 2077 Joined: 2/27/2006 ![]() |
Floor pivots consist of 11 levels. The center pivot (P), Bottom Pivot (B), Top Pivot (T), and 4 Support/Resistance levels (R1-R4 and S1-S4). The calculation for the floor pivots are as follows P = (High + Low + Close) / 3 B = (High + Low) / 2 T = ((P - B) + P) R1 = (2 * P - Low) S1 = (2 * P - High) R2 = (P - S1 + R1) S2 = ((P - (R1 - S1))) R3 = ((2 * (P - Low) + High)) S3 = ((Low - (2 * (High - P)))) R4 = ((R2 - R1) + R3) S4 = (S3 - (S1 - S2)) Built in the standard base OT indicators library are 2 versions of this indicator. One which uses the current timeframe used (Floor_Piv) and one which always uses the daily chart (Floor_PIVD). The parameters will be a value between -5 and 5. -5 = Support 4 -4 = Support 3 -3 = Support 2 -2 = Support 1 -1 = Bottom Pivot 0 = Center Pivot 1 = Top Pivot 2 = Resistance 1 3 = Resistance 2 4 = Resistance 3 5 = Resistance 4 So for example say you want to add a filter to your strategy that will only allow long signal when l price of a bar has violated (or dropped below) the Resistance 4 level. In the filter block under the Long Signal section you would type ... L < Floor_Piv(-5) You can not write a system or indicator to reference a specific time. Instead what you want to do is change the system, confirm, or filter block that you are using the system/indicator in to a higher timeframe. nBar = nBar[1] is referencing a historical value of 1 bar back. (See FAQ - http://www.omnitrader.com/omnitrader/proforum/thread-view.asp?threadid=1288&posts=1 ) Remember that all of your code is already in a loop to follow a bar by bar paradigm. So if we are only setting a variable based on some condition and we need to carry that value over to the next bar at the top of the script you can just use MyVar = MyVar[1]. That is saying to set the current value of your variable to equal the same as the prior value 1 bar back. The actual built in OL function Bar() returns the record number you are on. Again, remember we are walking through the data chart 1 bar at a time. So if you have 500 data periods loaded (or 500 bars of data) you can tell what iteration you are on by calling Bar(). This is a zero based index so the first bar of data is actually bar 0. So if Bar() returns a value of 123 you are currently on the 124th bar of data. There are many wasy of using this. One example is if you need to do some action for a specific number of bars you can keep track of you bar count by setting a variable to the value of Bar when you start and then subtract the value of Bar() from your variable. I.E. Dim nBar as Integer 'declare a variable to hold my bar count nBar = nBar[1] ' carry over my value to each consecutive bar If MyConditionIsMet Then ' My condition is met nBar = Bar() ' Keep track of the specific bar where my condition was met End If If Bar() - nBar < 5 Then ' Do some action for 5 bars only ...MyAction... End If | ||
^ Top | |||
RLB![]() Regular ![]() ![]() Posts: 58 Joined: 8/23/2007 Location: Ladera Ranch, CA ![]() |
Matthew, Thanks v much for the response. Very helpful. In the last code there are really 2 independent indicators combined: floor pivots and fisher ACD. In order to handle them easier I decided to break them up. Would you agree that in general it is better to break up indicators into as basic a group as possible, or do you find it better to combine those indicators that are likely to be grouped together? When looking at others' codes I am sometimes surprised at the order in which loops have been written (If Then). In some cases formulas that define certain names or indicators occur near the end even though they are referenced earlier. Assuming they are not nested, does it make little difference where in the code loops are located? In order to utilize OL built in functions (FLOOR_PIV() and FLOOR_PIVD()) I replaced my manual calculations with these (which I realize behind the scenes is doing the same manual calcs). I think that System building will be easier where the reference price will be FLOOR_PIV(x) with x from -5 to +5. Can I trouble you to take a look at the modified indicators (2) below and comment if there is anything either flawed or inefficient in the layout? I am next going to look at a number of increments or ratios in relation to the Open Range (in this case defined as first 15 min of trading) in addition to Fibonacci Ratios. In terms of design and ease of use in systems, would you suggest building indicators in similar fashion to FLOOR_PIV(x) above such as FIBRATIO(x) where x is from, say, -5 to +5 with each corresponding to a specific ration above/below the open range? Another would be ATR multiples (Eights),..etc. I will be combining these indicators in the hopes of reconfirming particular levels (e.g. if FLOOR_PIV(1) is close to (FIBRATIO(1) or FIBRATIO(2) or FIBRATIO(3)). Would you recommend doing this as a separate filter block or rather within the same system? Many thanks! #Indicator '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ' Daily ACD method With Fibonacci Extensions on intra-day chart '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #PARAM "Open_Hour", 6,0,23 #PARAM "Open_Minute", 30,0,59 #Param "Opening_Range_Bars", 1,1,60 '# of bars for Opening Range #Param "Draw_Fib_Extensions", 1,0,1 'Fibonacci extensions off Open Range #PARAM "PivotPoint", 0,-5,5 Dim X1, X2, nBar as Integer nBar = nBar[1] If (AfterTime(Open_Hour, Open_Minute) and BeforeTime(Open_Hour, Open_Minute + 1)) _ or (Bar = C.Length - 1) Then nBar = Bar - nBar - 1 nBar = nBar[1] If nBar[1]>0 Then X1 = nBar X2 = Bar - 1 End If nBar = Bar End If Dim FibP2618 as Single = 0 Dim FibP1618 as Single = 0 Dim FibP1272 as Single = 0 Dim ORHV as Single = 0 Dim ORLV as Single = 0 Dim FibN1272 as Single = 0 Dim FibN1618 as Single = 0 Dim FibN2618 as Single = 0 FibP2618 = FibP2618[1] FibP1618 = FibP1618[1] FibP1272 = FibP1272[1] ORHV = ORHV[1] ORLV = ORLV[1] FibN1272 = FibN1272[1] FibN1618 = FibN1618[1] FibN2618 = FibN2618[1] If FLOOR_PIV(PivotPoint) <> FLOOR_PIV(PivotPoint)[1] or Bar = C.Length - 1 Then PlotPriceTrendline("ORH +1.272", X1, FibP1272, X2, FibP1272, Blue, 2) PlotPriceTrendline("OR High", X1, ORHV, X2, ORHV, Red,2) PlotPriceTrendline("OR Low", X1, ORLV, X2, ORLV, Green, 2) PlotPriceTrendline("ORL -1.272", X1, FibN1272, X2, FibN1272, Blue, 2) If Draw_Fib_Extensions=1 Then PlotPriceTrendline("ORH +2.618", X1, FibP2618, X2, FibP2618, Orange, 2) PlotPriceTrendline("ORH +1.618", X1, FibP1618, X2, FibP1618, Purple, 2) PlotPriceTrendline("ORL -1.618", X1, FibN1618, X2, FibN1618, Purple, 2) PlotPriceTrendline("ORL -2.618", X1, FibN2618, X2, FibN2618, Orange, 2) End If nBar = Bar End If If Bar = nBar + (Opening_Range_Bars - 1) Then ORHV = HHV(H, Opening_Range_Bars) ORLV = LLV(L, Opening_Range_Bars) FibP2618 = ORHV + (ORHV - ORLV) * 1.618 FibP1618 = ORHV + (ORHV - ORLV) * 0.618 FibP1272 = ORHV + (ORHV - ORLV) * 0.272 FibN1272 = ORLV - (ORHV - ORLV) * 0.272 FibN1618 = ORLV - (ORHV - ORLV) * 0.618 FibN2618 = ORLV - (ORHV - ORLV) * 1.618 End If Return 0 #Indicator '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ' Daily Floor Pivot on intra-day time-frame '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #PARAM "Open_Hour", 6,0,23 #PARAM "Open_Minute", 30,0,59 #PARAM "PivRangeHi", 1,-5,5 #PARAM "PivRangeLo", -1,-5,5 #PARAM "PivotPoint", 0,-5,5 Dim X1, X2, nBar as Integer nBar = nBar[1] If (AfterTime(Open_Hour, Open_Minute) and BeforeTime(Open_Hour, Open_Minute + 1)) _ or (Bar = C.Length - 1) Then nBar = Bar - nBar nBar = nBar[1] If nBar[1]>0 Then X1 = nBar X2 = Bar - 1 PlotPriceTrendLine("PivRangeHi", X1, FLOOR_PIV(PivRangeHi)[1], X2, FLOOR_PIV(PivRangeHi)[1], Magenta, 2) PlotPriceTrendLine("PivPoint", X1, FLOOR_PIV(PivotPoint)[1], X2, FLOOR_PIV(PivotPoint)[1], Magenta, 2) PlotPriceTrendLine("PivRangeLo", X1, FLOOR_PIV(PivRangeLo)[1], X2, FLOOR_PIV(PivRangeLo)[1], Magenta, 2) End If nBar = Bar End If Return 0 [Edited by RLB on 1/18/2008 2:25 PM] |
|
|
Legend | Action | Notification | |||
Administrator
Forum Moderator |
Registered User
Unregistered User |
![]() |
Toggle e-mail notification |