|
|||||||||||||||||||
| Special offer: buy MetaStock (try for free) | Reuters QuoteCenter Real-Time Data (get a free month) | EOD Data |
|
Using a few studies and functions in TradeStation, the rainbow lines and rainbow oscillator can be developed in Easy Language. As always, the functions should be developed first. For the indicators themselves, special formatting is required for each. An outline of the recommended format is given after each set of indicator code. Below is the Power Editor code for the first function, "Rainbow." This function performs the basic calculations for the moving averages that make up the rainbow. Type: Function, Name: rainbow Inputs: Price(Numeric), Length(Numeric), Level(Numeric); Vars: LVLAvg(0); Array: Avg[10](0); Avg[1] = Average(Price, Length); Avg[2] = Average(Avg[1], Length); Avg[3] = Average(Avg[2], Length); Avg[4] = Average(Avg[3], Length); Avg[5] = Average(Avg[4], Length); Avg[6] = Average(Avg[5], Length); Avg[7] = Average(Avg[6], Length); Avg[8] = Average(Avg[7], Length); Avg[9] = Average(Avg[8], Length); Avg[10] = Average(Avg[9], Length); For value1 = 1 To 10 Begin IF value1 = Level Then LVLAvg = Avg[value1]; End; Rainbow = LVLAvg; The next function is "RainbowBW." This function returns the bandwidth of the averages: Type: Function, Name: RainbowBW Inputs: Price(Numeric), Length(Numeric), Level(Numeric); Vars: LVLAvg(0), HiPrice(0), LoPrice(0), HiAvg(0), LoAvg(0); Array: Avg[10](0); Avg[1] = Average(Price, Length); Avg[2] = Average(Avg[1], Length); Avg[3] = Average(Avg[2], Length); Avg[4] = Average(Avg[3], Length); Avg[5] = Average(Avg[4], Length); Avg[6] = Average(Avg[5], Length); Avg[7] = Average(Avg[6], Length); Avg[8] = Average(Avg[7], Length); Avg[9] = Average(Avg[8], Length); Avg[10] = Average(Avg[9], Length); HiPrice = Highest(Price, Level); LoPrice = Lowest(Price, Level); HiAvg = Avg[1]; LoAvg = Avg[1]; For value1 = 2 To Level Begin IF Avg[value1] > HiAvg Then HiAvg = Avg[value1]; IF Avg[value1] < LoAvg Then LoAvg = Avg[value1]; End; IF HiPrice - LoPrice <> 0 Then Begin IF Price > HiAvg Then HiAvg = Price; IF Price < LoAvg Then LoAvg = Price; RainbowBW = 100 * ((HiAvg - LoAvg) / (HiPrice - LoPrice)); End; The third and final function is "RainbowOsc." This function returns the value of the rainbow oscillator calculation: Type: Function, Name: RainbowOsc Inputs: Price(Numeric), Length(Numeric), Level(Numeric); Vars: AvgAvgs(0), HiPrice(0), LoPrice(0), AvgVal(0); Array: Avg[10](0); AvgAvgs = 0; Avg[1] = Average(Price, Length); Avg[2] = Average(Avg[1], Length); Avg[3] = Average(Avg[2], Length); Avg[4] = Average(Avg[3], Length); Avg[5] = Average(Avg[4], Length); Avg[6] = Average(Avg[5], Length); Avg[7] = Average(Avg[6], Length); Avg[8] = Average(Avg[7], Length); Avg[9] = Average(Avg[8], Length); Avg[10] = Average(Avg[9], Length); HiPrice = Highest(Price, Level); LoPrice = Lowest(Price, Level); For value1 = 1 To Level Begin AvgAvgs = AvgAvgs + Avg[value1]; End; AvgVal = AvgAvgs / Level; IF HiPrice - LoPrice <> 0 Then RainbowOsc = 100 * ((Close - AvgVal) / (HiPrice - LoPrice)); As for the indicators themselves, there are a total of four. For the most part, the indicator code is simple. The first three indicators (Rainbow_a, Rainbow_b and Rainbow_c) are used to plot the rainbow lines 1 through 10 on the chart. If you prefer to have only eight rainbow lines on the chart, then only "Rainbow_b" and "Rainbow_c" would be plotted. For all indicators, the "P" input represents the price basis of the moving average lines. The "Len" input represents the number of bars that are referenced by the moving average calculations. For the rainbow oscillator, the "Levels" input represents the number of average levels that are to be used for the calculation (default = 10). As noted earlier, all four indicators require special format settings for them to appear correctly on the chart. The format settings for each indicator follow each set of indicator code. Type: Indicator, Name: Rainbow_a Inputs: P(Close), Len(2); IF CurrentBar > Len * 10 Then Begin Plot1(Rainbow(P, Len, 10), "Avg10"); Plot2(Rainbow(P, Len, 9), "Avg9"); End; Style: Plot Name Type Color Weight Plot1 Avg10 Line Dk Blue medium Plot2 Avg9 Line Dk Magenta medium Scaling: Same as Price Data Type: Indicator, Name: Rainbow_b Inputs: P(Close), Len(2); IF CurrentBar > Len *10 Then Begin Plot1(Rainbow(P, Len, 8), "Avg8"); Plot2(Rainbow(P, Len, 7), "Avg7"); Plot3(Rainbow(P, Len, 6), "Avg6"); Plot4(Rainbow(P, Len, 5), "Avg5"); End; Style: Plot Name Type Color Weight Plot1 Avg8 Line Dk Green medium Plot2 Avg7 Line Dk Cyan medium Plot3 Avg6 Line Blue Plot4 Avg5 Line Cyan Scaling: Same as Price Data Type: Indicator, Name: Rainbow_c Inputs: P(Close), Len(2); IF CurrentBar > Len *10 Then Begin Plot1(Rainbow(P, Len, 4), "Avg4"); Plot2(Rainbow(P, Len, 3), "Avg3"); Plot3(Rainbow(P, Len, 2), "Avg2"); Plot4(Rainbow(P, Len, 1), "Avg1"); End; Style: Plot Name Type Color Weight Plot1 Avg4 Line Green medium Plot2 Avg3 Line Yellow medium Plot3 Avg2 Line Magenta medium Plot4 Avg1 Line Red medium Scaling: Same as Price Data The final indicator is the rainbow oscillator. The following indicator code plots the rainbow oscillator and the upper/lower bandwidth lines. Type: Indicator, Name: Rainbow Oscillator Inputs: P(Close), Len(2), Levels(10); Vars: PosNeg(0); IF CurrentBar > Len * Levels Then Begin Plot1(RainbowBW(P, Len, Levels), "URB"); Plot2(-RainbowBW(P, Len, Levels), "LRB"); PosNeg = RainbowOsc(P, Len, Levels); IF PosNeg > 0 Then Plot3(PosNeg, "RainbowOsc") Else Plot4(PosNeg, "RainbowOsc"); End; Style: Plot Name Type Color Weight Plot1 URB Line Red medium Plot2 LRB Line Blue medium Plot3 RainbowOsc Histogram Red medium Plot4 RainbowOsc Histogram Blue medium Scaling: Screen Properties: Subgraph 2 This code is available at Omega Research's Web site. The file name is "Rainbow.ELA." -- Gaston Sanchez, Omega Research 800 422-8587, 305 270-1095 Internet: http://www/omegaresearch.com Code:
all formulas for TradeStation all formulas
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| However we try to maintain hiqhest possible level of service - most formulas, oscillators, indicators and systems are submitted by anonymous users. Therefore S4T™ does not take any responsibility for it's quality. If you use any of this information, use it at your own risk. You are responsible for your own trading decisions. Be sure to verify that any information you see on these pages is correct, and is applicable to your particular trade. In no case will S4T™ be responsible for your trading gains or losses. |
|
|