|
|
 |
|

05-18-2009, 08:04 AM
|
|
Member
|
|
Join Date: May 2009
Posts: 6
|
|
FIBONACCI PIVOTS FORMULA
I understand the code and the formula for computing the standard pivot.
How can I compute for the Fibonacci Pivots?
|

05-18-2009, 08:21 AM
|
|
Member
|
|
Join Date: Apr 2009
Posts: 30
|
|
|
Try this
R3 = Pivot + 1.000 * (- - L) =
R2 = Pivot + 0.618 * (- - L) =
R1 = Pivot + 0.382 * (- - L) =
Pivot = ( - + L + C ) / 3 =
S1 = Pivot - 0.382 * (- - L) =
S2 = Pivot - 0.618 * (- - L) =
S3 = Pivot - 1.000 * (- - L) =
|

05-18-2009, 08:24 AM
|
|
Member
|
|
Join Date: Apr 2009
Posts: 30
|
|
|
sorry
R3 = Pivot + 1.000 * (HIGH-LOW) =
R2 = Pivot + 0.618 *(HIGH-LOW) =
R1 = Pivot + 0.382 * (HIGH-LOW) =
Pivot = (HIGH + LOW + CLOSE ) / 3 =
S1 = Pivot - 0.382 * (HIGH-LOW) =
S2 = Pivot - 0.618 *(HIGH-LOW) =
S3 = Pivot - 1.000 * (HIGH-LOW) =
|

05-18-2009, 02:08 PM
|
|
Member
|
|
Join Date: Apr 2009
Posts: 30
|
|
|
Hi reginad,
here is the code for a full automatic PIVOT LEVEL indicator. The only thing you can change is the time, when the pivot levels were calculated.
For explample if parameter Stunden to 6 then the pivot calculate from six a clock yesterday to six a clock today.
The code also includes the FIBO PIVOT Level calculation.
You do not have to think about which timeframe your are use, the indicator check this for you, and set the right parameter.
-- Indicator profile initialization routine
-- Defines indicator profile properties and indicator parameters
-- TODO: Add minimal and maximal value of numeric parameters and default color of the streams
function Init()
indicator:name("PIVOT");
indicator:description("PIVOT LINES");
indicator:requiredSource(core.Bar);
indicator:type(core.Indicator);
indicator.parameters:addInteger("HH", "Stunden", "Stunden", 0,0,24);
indicator.parameters:addColor("R3_color", "R3", "R3", core.rgb(0,0,128));
indicator.parameters:addColor("R2_color", "R2", "R2", core.rgb(0,0,255));
indicator.parameters:addColor("R1_color", "R1", "R1", core.rgb(0,128,255));
indicator.parameters:addColor("S3_color", "S3", "S3", core.rgb(128,0,0));
indicator.parameters:addColor("S2_color", "S2", "S2", core.rgb(255,0,0));
indicator.parameters:addColor("S1_color", "S1", "S1", core.rgb(255,128,128));
indicator.parameters:addColor("PP_color", "PP", "PP", core.rgb(255,255,0));
indicator.parameters:addColor("MIN_color", "LOW PREV", "LOW PREV", core.rgb(255,255,0));
indicator.parameters:addColor("MAX_color", "MAX PREV", "MAX PREV", core.rgb(255,255,0));
indicator.parameters:addColor("CLOSE_color", "CLOSE PREV", "CLOSE PREV", core.rgb(255,255,0));
end
-- Indicator instance initialization routine
-- Processes indicator parameters and creates output streams
-- TODO: Refine the first period calculation for each of the output streams.
-- TODO: Calculate all constants, create instances all subsequent indicators and load all required libraries
-- Parameters block
local first;
local source = nil;
local TF = nil;
local N = nil;
local HH = nil;
local MM = nil;
local SS = nil;
local MAX = nil;
local MIN = nil;
-- Streams block
local HIGH = nil;
-- Routine
function Prepare()
HH = instance.parameters.HH;
MM = instance.parameters.MM;
SS = instance.parameters.SS;
TF = instance.parameters.TF;
source = instance.source;
-- CHECK which TIMEFRAME is used
TF = source:barSize();
if TF == "m5" then
N = 304;
end
if TF == "m15" then
N = 104;
end
if TF == "m30" then
N = 52;
end
if TF == "h1" then
N = 26;
end
first = N + source:first();
first_COUNT = source:first();
local name = profile:id() .. "(" .. source:name() .. ")";
instance:name(name);
-- Internal DATE Stream
DATE = instance:addInternalStream (first_COUNT);
-- STREAM OUTPUT
MAX = instance:addStream("MAX", core.Line, name, "MAX", instance.parameters.MAX_color,first+2*N-1);
MIN = instance:addStream("MIN", core.Line, name, "MIN", instance.parameters.MIN_color,first+2*N-1);
CLOSE_P = instance:addStream("CLOSE_P", core.Line, name, "CLOSE_P", instance.parameters.CLOSE_color,first+2*N-1);
R3 = instance:addStream("R3", core.Line, name, "R3", instance.parameters.R3_color,first+2*N-1);
R2 = instance:addStream("R2", core.Line, name, "R2", instance.parameters.R2_color,first+2*N-1);
R1 = instance:addStream("R1", core.Line, name, "R1", instance.parameters.R1_color,first+2*N-1);
S1 = instance:addStream("S1", core.Line, name, "S1", instance.parameters.S1_color,first+2*N-1);
S2 = instance:addStream("S2", core.Line, name, "S2", instance.parameters.S2_color,first+2*N-1);
S3 = instance:addStream("S3", core.Line, name, "S3", instance.parameters.S3_color,first+2*N-1);
PP = instance:addStream("PP", core.Line, name, "PP", instance.parameters.PP_color,first+2*N-1);
end
-- Indicator calculation routine
-- TODO: Add your code for calculation output values
function Update(period)
-- GET DATE of the PERIOD
DATE[period] = source:date(period);
CC = core.dateToTable(DATE[period]);
if period >= first and source:hasData(period)then
if CC.hour == HH and CC.min == 0 and CC.sec == 0 then
MAX[period] = core.max(source.high, core.rangeTo(period,N));
MIN[period] = core.min(source.low, core.rangeTo(period,N));
CLOSE_P[period] = source.close[period];
else
MAX[period] = MAX[period-1];
MIN[period] = MIN[period-1];
CLOSE_P[period] = CLOSE_P[period-1];
end
-- PIVOT LEVEL
PP[period] = (MAX[period]+MIN[period]+CLOSE_P[period]) / 3;
R3[period] = MAX[period] + 2*(PP[period]-MIN[period]);
R2[period] = PP[period] + (MAX[period]-MIN[period]);
R1[period] = 2*PP[period] - MIN[period];
S1[period] = 2*PP[period] - MAX[period];
S2[period] = PP[period] - (MAX[period] - MIN[period]);
S3[period] = MIN[period] - 2*(MAX[period] - PP[period]);
-- PIVOT LEVEL
end
-- FIBONACCI LEVEL
-- PP[period] = ((MAX[period] - MIN[period]) * 0.500) + MIN[period];
-- R3[period] = MAX[period];
-- R2[period] = ((MAX[period] - MIN[period]) * 0.764) + MIN[period];
-- R1[period] = ((MAX[period] - MIN[period]) * 0.618) + MIN[period];
-- S1[period] = ((MAX[period] - MIN[period]) * 0.382) + MIN[period];
-- S2[period] = ((MAX[period] - MIN[period]) * 0.236) + MIN[period];
-- S3[period] = MIN[period];
-- FIBONACCI LEVEL
end
|

06-26-2009, 12:08 AM
|
 |
Member
|
|
Join Date: Jun 2008
Posts: 146
|
|
|
PIVOTS
Quote:
Originally Posted by gidien
Hi reginad,
here is the code for a full automatic PIVOT LEVEL indicator. The only thing you can change is the time, when the pivot levels were calculated.
For explample if parameter Stunden to 6 then the pivot calculate from six a clock yesterday to six a clock today.
The code also includes the FIBO PIVOT Level calculation.
You do not have to think about which timeframe your are use, the indicator check this for you, and set the right parameter.
-- Indicator profile initialization routine
-- Defines indicator profile properties and indicator parameters
-- TODO: Add minimal and maximal value of numeric parameters and default color of the streams
function Init()
indicator:name("PIVOT");
indicator:description("PIVOT LINES");
indicator:requiredSource(core.Bar);
indicator:type(core.Indicator);
indicator.parameters:addInteger("HH", "Stunden", "Stunden", 0,0,24);
indicator.parameters:addColor("R3_color", "R3", "R3", core.rgb(0,0,128));
indicator.parameters:addColor("R2_color", "R2", "R2", core.rgb(0,0,255));
indicator.parameters:addColor("R1_color", "R1", "R1", core.rgb(0,128,255));
indicator.parameters:addColor("S3_color", "S3", "S3", core.rgb(128,0,0));
indicator.parameters:addColor("S2_color", "S2", "S2", core.rgb(255,0,0));
indicator.parameters:addColor("S1_color", "S1", "S1", core.rgb(255,128,128));
indicator.parameters:addColor("PP_color", "PP", "PP", core.rgb(255,255,0));
indicator.parameters:addColor("MIN_color", "LOW PREV", "LOW PREV", core.rgb(255,255,0));
indicator.parameters:addColor("MAX_color", "MAX PREV", "MAX PREV", core.rgb(255,255,0));
indicator.parameters:addColor("CLOSE_color", "CLOSE PREV", "CLOSE PREV", core.rgb(255,255,0));
end
-- Indicator instance initialization routine
-- Processes indicator parameters and creates output streams
-- TODO: Refine the first period calculation for each of the output streams.
-- TODO: Calculate all constants, create instances all subsequent indicators and load all required libraries
-- Parameters block
local first;
local source = nil;
local TF = nil;
local N = nil;
local HH = nil;
local MM = nil;
local SS = nil;
local MAX = nil;
local MIN = nil;
-- Streams block
local HIGH = nil;
-- Routine
function Prepare()
HH = instance.parameters.HH;
MM = instance.parameters.MM;
SS = instance.parameters.SS;
TF = instance.parameters.TF;
source = instance.source;
-- CHECK which TIMEFRAME is used
TF = source:barSize();
if TF == "m5" then
N = 304;
end
if TF == "m15" then
N = 104;
end
if TF == "m30" then
N = 52;
end
if TF == "h1" then
N = 26;
end
first = N + source:first();
first_COUNT = source:first();
local name = profile:id() .. "(" .. source:name() .. ")";
instance:name(name);
-- Internal DATE Stream
DATE = instance:addInternalStream (first_COUNT);
-- STREAM OUTPUT
MAX = instance:addStream("MAX", core.Line, name, "MAX", instance.parameters.MAX_color,first+2*N-1);
MIN = instance:addStream("MIN", core.Line, name, "MIN", instance.parameters.MIN_color,first+2*N-1);
CLOSE_P = instance:addStream("CLOSE_P", core.Line, name, "CLOSE_P", instance.parameters.CLOSE_color,first+2*N-1);
R3 = instance:addStream("R3", core.Line, name, "R3", instance.parameters.R3_color,first+2*N-1);
R2 = instance:addStream("R2", core.Line, name, "R2", instance.parameters.R2_color,first+2*N-1);
R1 = instance:addStream("R1", core.Line, name, "R1", instance.parameters.R1_color,first+2*N-1);
S1 = instance:addStream("S1", core.Line, name, "S1", instance.parameters.S1_color,first+2*N-1);
S2 = instance:addStream("S2", core.Line, name, "S2", instance.parameters.S2_color,first+2*N-1);
S3 = instance:addStream("S3", core.Line, name, "S3", instance.parameters.S3_color,first+2*N-1);
PP = instance:addStream("PP", core.Line, name, "PP", instance.parameters.PP_color,first+2*N-1);
end
-- Indicator calculation routine
-- TODO: Add your code for calculation output values
function Update(period)
-- GET DATE of the PERIOD
DATE[period] = source:date(period);
CC = core.dateToTable(DATE[period]);
if period >= first and source:hasData(period)then
if CC.hour == HH and CC.min == 0 and CC.sec == 0 then
MAX[period] = core.max(source.high, core.rangeTo(period,N));
MIN[period] = core.min(source.low, core.rangeTo(period,N));
CLOSE_P[period] = source.close[period];
else
MAX[period] = MAX[period-1];
MIN[period] = MIN[period-1];
CLOSE_P[period] = CLOSE_P[period-1];
end
-- PIVOT LEVEL
PP[period] = (MAX[period]+MIN[period]+CLOSE_P[period]) / 3;
R3[period] = MAX[period] + 2*(PP[period]-MIN[period]);
R2[period] = PP[period] + (MAX[period]-MIN[period]);
R1[period] = 2*PP[period] - MIN[period];
S1[period] = 2*PP[period] - MAX[period];
S2[period] = PP[period] - (MAX[period] - MIN[period]);
S3[period] = MIN[period] - 2*(MAX[period] - PP[period]);
-- PIVOT LEVEL
end
-- FIBONACCI LEVEL
-- PP[period] = ((MAX[period] - MIN[period]) * 0.500) + MIN[period];
-- R3[period] = MAX[period];
-- R2[period] = ((MAX[period] - MIN[period]) * 0.764) + MIN[period];
-- R1[period] = ((MAX[period] - MIN[period]) * 0.618) + MIN[period];
-- S1[period] = ((MAX[period] - MIN[period]) * 0.382) + MIN[period];
-- S2[period] = ((MAX[period] - MIN[period]) * 0.236) + MIN[period];
-- S3[period] = MIN[period];
-- FIBONACCI LEVEL
end
|
HELLO:
COULD YOU GIVE SOME INSTRUCTIONS ON HOW TO GET THIS UPLOADED?
GLAD IF U COULD EMAIL ME AT chris.smith@mmjamaica.com
thanks
|

06-26-2009, 02:37 AM
|
|
Registered User
|
|
Join Date: Jun 2009
Posts: 1
|
|
|
Thanks for this and very much appreciated. I can't believe that FXCM can't find a way to make a real pivot indicator for their platform. Does anybody know how to modify the code to get rid of that huge line that starts the indicator. Maybe default it to the lowest bar price in the calculation bar count or a simple moving average number that is closer than 0. Not being able to scale the chart correctly is trivial but when you change pairs or time frames it is a pain to readjust several charts every time.
Yes I did try to learn LUA to change it but I am a mediocre trader at best and a really crappy programmer I have discovered.
Cheers,
Bolter
|

08-06-2009, 07:57 AM
|
|
Member
|
|
Join Date: Aug 2009
Posts: 13
|
|
|
Pivot Out of scale
Quote:
Originally Posted by gidien
Hi reginad,
here is the code for a full automatic PIVOT LEVEL indicator. The only thing you can change is the time, when the pivot levels were calculated.
For explample if parameter Stunden to 6 then the pivot calculate from six a clock yesterday to six a clock today.
The code also includes the FIBO PIVOT Level calculation.
You do not have to think about which timeframe your are use, the indicator check this for you, and set the right parameter.
-- Indicator profile initialization routine
-- Defines indicator profile properties and indicator parameters
-- TODO: Add minimal and maximal value of numeric parameters and default color of the streams
function Init()
indicator:name("PIVOT");
indicator:description("PIVOT LINES");
indicator:requiredSource(core.Bar);
indicator:type(core.Indicator);
indicator.parameters:addInteger("HH", "Stunden", "Stunden", 0,0,24);
indicator.parameters:addColor("R3_color", "R3", "R3", core.rgb(0,0,128));
indicator.parameters:addColor("R2_color", "R2", "R2", core.rgb(0,0,255));
indicator.parameters:addColor("R1_color", "R1", "R1", core.rgb(0,128,255));
indicator.parameters:addColor("S3_color", "S3", "S3", core.rgb(128,0,0));
indicator.parameters:addColor("S2_color", "S2", "S2", core.rgb(255,0,0));
indicator.parameters:addColor("S1_color", "S1", "S1", core.rgb(255,128,128));
indicator.parameters:addColor("PP_color", "PP", "PP", core.rgb(255,255,0));
indicator.parameters:addColor("MIN_color", "LOW PREV", "LOW PREV", core.rgb(255,255,0));
indicator.parameters:addColor("MAX_color", "MAX PREV", "MAX PREV", core.rgb(255,255,0));
indicator.parameters:addColor("CLOSE_color", "CLOSE PREV", "CLOSE PREV", core.rgb(255,255,0));
end
-- Indicator instance initialization routine
-- Processes indicator parameters and creates output streams
-- TODO: Refine the first period calculation for each of the output streams.
-- TODO: Calculate all constants, create instances all subsequent indicators and load all required libraries
-- Parameters block
local first;
local source = nil;
local TF = nil;
local N = nil;
local HH = nil;
local MM = nil;
local SS = nil;
local MAX = nil;
local MIN = nil;
-- Streams block
local HIGH = nil;
-- Routine
function Prepare()
HH = instance.parameters.HH;
MM = instance.parameters.MM;
SS = instance.parameters.SS;
TF = instance.parameters.TF;
source = instance.source;
-- CHECK which TIMEFRAME is used
TF = source:barSize();
if TF == "m5" then
N = 304;
end
if TF == "m15" then
N = 104;
end
if TF == "m30" then
N = 52;
end
if TF == "h1" then
N = 26;
end
first = N + source:first();
first_COUNT = source:first();
local name = profile:id() .. "(" .. source:name() .. ")";
instance:name(name);
-- Internal DATE Stream
DATE = instance:addInternalStream (first_COUNT);
-- STREAM OUTPUT
MAX = instance:addStream("MAX", core.Line, name, "MAX", instance.parameters.MAX_color,first+2*N-1);
MIN = instance:addStream("MIN", core.Line, name, "MIN", instance.parameters.MIN_color,first+2*N-1);
CLOSE_P = instance:addStream("CLOSE_P", core.Line, name, "CLOSE_P", instance.parameters.CLOSE_color,first+2*N-1);
R3 = instance:addStream("R3", core.Line, name, "R3", instance.parameters.R3_color,first+2*N-1);
R2 = instance:addStream("R2", core.Line, name, "R2", instance.parameters.R2_color,first+2*N-1);
R1 = instance:addStream("R1", core.Line, name, "R1", instance.parameters.R1_color,first+2*N-1);
S1 = instance:addStream("S1", core.Line, name, "S1", instance.parameters.S1_color,first+2*N-1);
S2 = instance:addStream("S2", core.Line, name, "S2", instance.parameters.S2_color,first+2*N-1);
S3 = instance:addStream("S3", core.Line, name, "S3", instance.parameters.S3_color,first+2*N-1);
PP = instance:addStream("PP", core.Line, name, "PP", instance.parameters.PP_color,first+2*N-1);
end
-- Indicator calculation routine
-- TODO: Add your code for calculation output values
function Update(period)
-- GET DATE of the PERIOD
DATE[period] = source:date(period);
CC = core.dateToTable(DATE[period]);
if period >= first and source:hasData(period)then
if CC.hour == HH and CC.min == 0 and CC.sec == 0 then
MAX[period] = core.max(source.high, core.rangeTo(period,N));
MIN[period] = core.min(source.low, core.rangeTo(period,N));
CLOSE_P[period] = source.close[period];
else
MAX[period] = MAX[period-1];
MIN[period] = MIN[period-1];
CLOSE_P[period] = CLOSE_P[period-1];
end
-- PIVOT LEVEL
PP[period] = (MAX[period]+MIN[period]+CLOSE_P[period]) / 3;
R3[period] = MAX[period] + 2*(PP[period]-MIN[period]);
R2[period] = PP[period] + (MAX[period]-MIN[period]);
R1[period] = 2*PP[period] - MIN[period];
S1[period] = 2*PP[period] - MAX[period];
S2[period] = PP[period] - (MAX[period] - MIN[period]);
S3[period] = MIN[period] - 2*(MAX[period] - PP[period]);
-- PIVOT LEVEL
end
-- FIBONACCI LEVEL
-- PP[period] = ((MAX[period] - MIN[period]) * 0.500) + MIN[period];
-- R3[period] = MAX[period];
-- R2[period] = ((MAX[period] - MIN[period]) * 0.764) + MIN[period];
-- R1[period] = ((MAX[period] - MIN[period]) * 0.618) + MIN[period];
-- S1[period] = ((MAX[period] - MIN[period]) * 0.382) + MIN[period];
-- S2[period] = ((MAX[period] - MIN[period]) * 0.236) + MIN[period];
-- S3[period] = MIN[period];
-- FIBONACCI LEVEL
end
|
Thanks for providing the indicator.
I loaded the indicator, but I think there is some error in it because the chart scale becomes strange and impossible to read price bars.
Any help would be greatly appreciated.
|

08-09-2009, 03:45 AM
|
|
Member
|
|
Join Date: Apr 2009
Posts: 30
|
|
|
The problem that the fisrt bar of the calculation is zero, i don't know why at the moment. if you zoom out and then in again,or move the chart to left and then back to the end, more period were loaded. and you should see it correct.
I think it has somthing to do, wich period is first drawing.
try example
R3 = instance:addStream("R3", core.Line, name, "R3", instance.parameters.R3_color,first+2*N+1);
instead of
R3 = instance:addStream("R3", core.Line, name, "R3", instance.parameters.R3_color,first+2*N-1);
i couldn't test it at the moment.
|

08-09-2009, 08:01 PM
|
|
Member
|
|
Join Date: May 2009
Posts: 6
|
|
pivot scale solution
pmxgs0,
Quote:
Originally Posted by pmxgs0
Thanks for providing the indicator.
I loaded the indicator, but I think there is some error in it because the chart scale becomes strange and impossible to read price bars.
Any help would be greatly appreciated.
|
That problem was caused by either a wrong parameter value or your chart was set on a bigger time frame, making prices on the right look small. To solve that, try to modify the values of the parameter of your indicator. You can do this by:
1. Double click your fibonacci indicator.
2. A window will appear, click PARAMETERS tab.
3. Provide values for High, Low and Close. You can get the values from your chart by changing the chart mode to "Table".
4. Click Ok.
If the pivots still look the same as with the screen shot you have provided, try changing your timeframe to a smaller one. Try 30 minutes, 15 minutes, 5 minutes or 1 minute.
Let me know if this solves your problem.
Regina 
|

08-10-2009, 07:23 AM
|
|
Member
|
|
Join Date: Aug 2009
Posts: 13
|
|
|
Pivots
Hi,
I zoomed in and moved the chart to the right and now it's ok.
The problem, as referred by gidien, has to do with the first calculation of the pivot line which is not correct, so in order to be visible the chart gets very compressed to allow us to see that line.
Athough I'm not a very experienced programmer I'll try to see if I can correct this and I'll post it if I succeed.
thanks
|

08-11-2009, 01:56 PM
|
|
Member
|
|
Join Date: Nov 2008
Posts: 37
|
|
|
Hi
I changed the code creates output streams (changed initial item from "first + first+2*N+1" to "first", because I didnt understand what is 2 * N + 1)
-----------------
R3 = instance:addStream("R3", core.Line, name, "R3", instance.parameters.R3_color,first);
R2 = instance:addStream("R2", core.Line, name, "R2", instance.parameters.R2_color,first);
R1 = instance:addStream("R1", core.Line, name, "R1", instance.parameters.R1_color,first);
S1 = instance:addStream("S1", core.Line, name, "S1", instance.parameters.S1_color,first);
S2 = instance:addStream("S2", core.Line, name, "S2", instance.parameters.S2_color,first);
S3 = instance:addStream("S3", core.Line, name, "S3", instance.parameters.S3_color,first);
PP = instance:addStream("PP", core.Line, name, "PP", instance.parameters.PP_color,first);
------------------
Now it looks much better (there is no zoom)
Last edited by FxTopor; 08-11-2009 at 01:58 PM..
Reason: bad picture
|

08-11-2009, 08:16 PM
|
 |
Member
|
|
Join Date: May 2007
Posts: 418
|
|
|
Hello,
I need your help. I am looking for a code for standard pivot. I would like to show weekly and daily pivots in my charts, then move to shorter time frames keeping those values unaffected. I am using Trading Station II. any advise? thanks!
best,
A.
p.d. I don't know how to use Lua or any other programming language...
|

08-27-2009, 10:29 AM
|
|
Member
|
|
Join Date: Aug 2009
Posts: 13
|
|
|
Display only PP and R3 and S3
Hi,
thanks for the info below.
I would like this Pivots indicator to display only, the PP line and R3 and S3 lines.
I tried to eliminate this lines in the init() are of the code and also in the update() section, but after I did that, when I apply the indicator to the chart I get an error.
This shoul be very easy to do but somehow I'm missing something.
Any help?
thanks
Quote:
Originally Posted by FxTopor
Hi
I changed the code creates output streams (changed initial item from "first + first+2*N+1" to "first", because I didnt understand what is 2 * N + 1)
-----------------
R3 = instance:addStream("R3", core.Line, name, "R3", instance.parameters.R3_color,first);
R2 = instance:addStream("R2", core.Line, name, "R2", instance.parameters.R2_color,first);
R1 = instance:addStream("R1", core.Line, name, "R1", instance.parameters.R1_color,first);
S1 = instance:addStream("S1", core.Line, name, "S1", instance.parameters.S1_color,first);
S2 = instance:addStream("S2", core.Line, name, "S2", instance.parameters.S2_color,first);
S3 = instance:addStream("S3", core.Line, name, "S3", instance.parameters.S3_color,first);
PP = instance:addStream("PP", core.Line, name, "PP", instance.parameters.PP_color,first);
------------------
Now it looks much better (there is no zoom)
|
|

09-26-2009, 02:11 PM
|
 |
Member
|
|
Join Date: Nov 2008
Posts: 64
|
|
Quote:
Originally Posted by gidien
Hi reginad,
here is the code for a full automatic PIVOT LEVEL indicator. The only thing you can change is the time, when the pivot levels were calculated.
For explample if parameter Stunden to 6 then the pivot calculate from six a clock yesterday to six a clock today.
The code also includes the FIBO PIVOT Level calculation.
You do not have to think about which timeframe your are use, the indicator check this for you, and set the right parameter.
-- Indicator profile initialization routine
-- Defines indicator profile properties and indicator parameters
-- TODO: Add minimal and maximal value of numeric parameters and default color of the streams
function Init()
indicator:name("PIVOT");
indicator:description("PIVOT LINES");
indicator:requiredSource(core.Bar);
indicator:type(core.Indicator);
indicator.parameters:addInteger("HH", "Stunden", "Stunden", 0,0,24);
indicator.parameters:addColor("R3_color", "R3", "R3", core.rgb(0,0,128));
indicator.parameters:addColor("R2_color", "R2", "R2", core.rgb(0,0,255));
indicator.parameters:addColor("R1_color", "R1", "R1", core.rgb(0,128,255));
indicator.parameters:addColor("S3_color", "S3", "S3", core.rgb(128,0,0));
indicator.parameters:addColor("S2_color", "S2", "S2", core.rgb(255,0,0));
indicator.parameters:addColor("S1_color", "S1", "S1", core.rgb(255,128,128));
indicator.parameters:addColor("PP_color", "PP", "PP", core.rgb(255,255,0));
indicator.parameters:addColor("MIN_color", "LOW PREV", "LOW PREV", core.rgb(255,255,0));
indicator.parameters:addColor("MAX_color", "MAX PREV", "MAX PREV", core.rgb(255,255,0));
indicator.parameters:addColor("CLOSE_color", "CLOSE PREV", "CLOSE PREV", core.rgb(255,255,0));
end
-- Indicator instance initialization routine
-- Processes indicator parameters and creates output streams
-- TODO: Refine the first period calculation for each of the output streams.
-- TODO: Calculate all constants, create instances all subsequent indicators and load all required libraries
-- Parameters block
local first;
local source = nil;
local TF = nil;
local N = nil;
local HH = nil;
local MM = nil;
local SS = nil;
local MAX = nil;
local MIN = nil;
-- Streams block
local HIGH = nil;
-- Routine
function Prepare()
HH = instance.parameters.HH;
MM = instance.parameters.MM;
SS = instance.parameters.SS;
TF = instance.parameters.TF;
source = instance.source;
-- CHECK which TIMEFRAME is used
TF = source:barSize();
if TF == "m5" then
N = 304;
end
if TF == "m15" then
N = 104;
end
if TF == "m30" then
N = 52;
end
if TF == "h1" then
N = 26;
end
first = N + source:first();
first_COUNT = source:first();
local name = profile:id() .. "(" .. source:name() .. ")";
instance:name(name);
-- Internal DATE Stream
DATE = instance:addInternalStream (first_COUNT);
-- STREAM OUTPUT
MAX = instance:addStream("MAX", core.Line, name, "MAX", instance.parameters.MAX_color,first+2*N-1);
MIN = instance:addStream("MIN", core.Line, name, "MIN", instance.parameters.MIN_color,first+2*N-1);
CLOSE_P = instance:addStream("CLOSE_P", core.Line, name, "CLOSE_P", instance.parameters.CLOSE_color,first+2*N-1);
R3 = instance:addStream("R3", core.Line, name, "R3", instance.parameters.R3_color,first+2*N-1);
R2 = instance:addStream("R2", core.Line, name, "R2", instance.parameters.R2_color,first+2*N-1);
R1 = instance:addStream("R1", core.Line, name, "R1", instance.parameters.R1_color,first+2*N-1);
S1 = instance:addStream("S1", core.Line, name, "S1", instance.parameters.S1_color,first+2*N-1);
S2 = instance:addStream("S2", core.Line, name, "S2", instance.parameters.S2_color,first+2*N-1);
S3 = instance:addStream("S3", core.Line, name, "S3", instance.parameters.S3_color,first+2*N-1);
PP = instance:addStream("PP", core.Line, name, "PP", instance.parameters.PP_color,first+2*N-1);
end
-- Indicator calculation routine
-- TODO: Add your code for calculation output values
function Update(period)
-- GET DATE of the PERIOD
DATE[period] = source:date(period);
CC = core.dateToTable(DATE[period]);
if period >= first and source:hasData(period)then
if CC.hour == HH and CC.min == 0 and CC.sec == 0 then
MAX[period] = core.max(source.high, core.rangeTo(period,N));
MIN[period] = core.min(source.low, core.rangeTo(period,N));
CLOSE_P[period] = source.close[period];
else
MAX[period] = MAX[period-1];
MIN[period] = MIN[period-1];
CLOSE_P[period] = CLOSE_P[period-1];
end
-- PIVOT LEVEL
PP[period] = (MAX[period]+MIN[period]+CLOSE_P[period]) / 3;
R3[period] = MAX[period] + 2*(PP[period]-MIN[period]);
R2[period] = PP[period] + (MAX[period]-MIN[period]);
R1[period] = 2*PP[period] - MIN[period];
S1[period] = 2*PP[period] - MAX[period];
S2[period] = PP[period] - (MAX[period] - MIN[period]);
S3[period] = MIN[period] - 2*(MAX[period] - PP[period]);
-- PIVOT LEVEL
end
-- FIBONACCI LEVEL
-- PP[period] = ((MAX[period] - MIN[period]) * 0.500) + MIN[period];
-- R3[period] = MAX[period];
-- R2[period] = ((MAX[period] - MIN[period]) * 0.764) + MIN[period];
-- R1[period] = ((MAX[period] - MIN[period]) * 0.618) + MIN[period];
-- S1[period] = ((MAX[period] - MIN[period]) * 0.382) + MIN[period];
-- S2[period] = ((MAX[period] - MIN[period]) * 0.236) + MIN[period];
-- S3[period] = MIN[period];
-- FIBONACCI LEVEL
end
|
I'm not too familiar with programming. Could someone please email me at kenny.strickland@hotmail.com with instructions to install this on tradestation. Thank you in advance.
|

09-30-2009, 07:50 AM
|
|
Member
|
|
Join Date: Aug 2009
Posts: 13
|
|
|
Re:Installing the indicator
Quote:
Originally Posted by Eligason
I'm not too familiar with programming. Could someone please email me at kenny.strickland@hotmail.com with instructions to install this on tradestation. Thank you in advance.
|
Hi,
1. you need to copy the code of the indicator to notepad and save the file with lua extension (not txt).
2. Then go to marketscope's chart menu and choose manage custom indicators.
Load the file created in step 1.
After that you only have to choose insert indicator.
hope that helps
|
 |
|
| Thread Tools |
|
|
| Rate This Thread |
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|