Привет всем!! Вот нашел прау скриптов но т.к в программировании полный ноль то прошу что бы вы смогли довести д оума этот индикатор.
Вот код, проблема в том что когда вставляю в мт4, выдает ошибку , я пытался ее исправить но как писал, в программировании 0
скаченно с сайта
http://wiki.fxprogra...r_Ehlers_Filter
function Init()
indicator:name("Nonlinear Ehlers Filter");
indicator:description("Nonlinear Ehlers Filter");
indicator:requiredSource(core.Bar);
indicator:type(core.Indicator);
indicator.parameters:addInteger("Length", "No name", "No description", 15);
indicator.parameters:addColor("Color of Ehlers", "Color of Ehlers", core.rgb(255, 0, 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 Length;
local priceSource = nil;
local first;
local source = nil;
-- Streams block
local Ehlers = nil;
-- Routine
function Prepare()
Length = instance.parameters.Length;
source = instance.source;
first = source:first() + Length + 5;
priceSource = instance:addInternalStream(source:first());
local name = profile:id() .. "(" .. source:name() .. ", " .. Length .. ")";
instance:name(name);
Ehlers = instance:addStream("Ehlers", core.Line, name, "Ehlers", instance.parameters.Ehlers_color, first)
end
-- Indicator calculation routine
-- TODO: Add your code for calculation output values
function Update(period)
priceSource[period] = (source.high[period] + source.low[period]) / 2;
if period >= first and source:hasData(period) then
local i = 0;
local Num = 0;
local SumCoef = 0;
for i = 0, Length - 1 do
local Coef = math.abs(priceSource[period - i] - priceSource[period - i - 5]);
Num = Num + Coef * priceSource[period - i];
SumCoef = SumCoef + Coef;
end
Ehlers[period] = Num / SumCoef;
end
end
это 1 код а вот еще:
сайт
http://forum.esignal...?threadid=29610
/*********************************
Provided By:
eSignal (Copyright c eSignal), a division of Interactive Data
Corporation. 2008. All rights reserved. This sample eSignal
Formula Script (EFS) is for educational purposes only and may be
modified and saved under a new file name. eSignal is not responsible
for the functionality once modified. eSignal reserves the right
to modify and overwrite this EFS file with each new release.
Description:
Ehlers Filter
Version: 1.0 01/16/2009
Formula Parameters: Default:
Length 15
Thickness line 2
Line Color Green
Display Cursor Labels True
Notes:
The related article is copyrighted material. If you are not
a subscriber of Stocks & Commodities, please visit <a href="
http://www.traders.com." target="_blank">www.traders.com.</a>
**********************************/
var fpArray = new Array();
var bInit = false;
function preMain() {
setPriceStudy(false);
setShowCursorLabel(false);
setShowTitleParameters( false );
setStudyTitle("Ehlers Filter");
setCursorLabelName("Ehlers", 0);
setDefaultBarFgColor(Color.green, 0);
setPlotType(PLOTTYPE_LINE, 0);
setDefaultBarThickness(2, 0);
askForInput();
var x=0;
fpArray[x] = new FunctionParameter("LineColor", FunctionParameter.COLOR);
with(fpArray[x++]){
setName("Line Color");
setDefault(Color.green);
}
fpArray[x] = new FunctionParameter("ViewValue", FunctionParameter.BOOLEAN);
with(fpArray[x++]){
setName("Display Cursor Labels");
setDefault(true);
}
fpArray[x] = new FunctionParameter("Length", FunctionParameter.NUMBER);
with(fpArray[x++]){
setLowerLimit(1);
setDefault(15);
}
fpArray[x] = new FunctionParameter("Thickness", FunctionParameter.NUMBER);
with(fpArray[x++]){
setName("Line Thickness");
setLowerLimit(1);
setDefault(2);
}
}
var xCoef = null;
var xPrice = null;
function main(Length, Thickness, LineColor, ViewValue) {
var nNum = 0;
var nSumCoef = 0;
var nCount = 0;
var nFilt = 0;
if ( bInit == false ) {
setDefaultBarFgColor(LineColor, 0);
setDefaultBarThickness(Thickness, 0);
setShowCursorLabel(ViewValue);
xPrice = hl2();
xCoef = efsInternal("Calc_Coef", xPrice)
bInit = true;
}
for (nCount = 0; nCount < Length; nCount++) {
nNum += xCoef.getValue(-nCount) * xPrice.getValue(-nCount);
nSumCoef += xCoef.getValue(-nCount);
}
if (nSumCoef != 0) {
nFilt = nNum / nSumCoef;
}
return nFilt;
}
function Calc_Coef(xPrice) {
var nRes = 0;
nPrice = 0;
nPrice = xPrice.getValue(-5);
if (nPrice == null) nPrice = 0;
nRes = Math.abs(xPrice.getValue(0) - nPrice);
return nRes;
}
т.е как уже поняли , это код который надо довести до ума , что бы он стал индикатором в мт4.
Сообщение изменено: Ravenloff, 15 Февраль 2011 - 09:20 .