Dit is de TS code voor ROC trend vlgs
http://www.belbelta.nl/Let op in TS moet je indicatoren appart programmeren.
----------------------------------------
{***************************************
Written by:
Description:
****************************************}
{---- INDICATOR ----}
{
{---- inputs ----}
?inputs: xEMABars(16), xROCBars(50), xTrendBars(100);
?{---- variables ----}
?vars: xEMA(0),xROCEMA(0),xTrend(0);
?{---- calculate EMA and ROC ----}
?xEMA = XAverage(Close,xEMABars);
?if xEMA[xRocBars]=0 then xROCEMA = 0
?else xROCEMA = 100*xEMA/xEMA[xROCBars]-100;
?xTrend = XAverage(Close,xTrendBars);
?{---- let's do some plotting ----}
?if xROCEMA>0 then plot1 (xROCEMA,"ROC")
?else plot2 (xROCEMA);
}
{---- SIGNAL ----}
{---- inputs ----}
?inputs: xEMABars(16), xROCBars(50), xTrendBars(100), xProfit(10), xStopLoss(10);
?{---- variables ----}
?vars: xEMA(0),xROCEMA(0),xTrend(0),xStopLevel(0),xProfitLevel(0);
?{---- calculate EMA and ROC ----}
?xEMA = XAverage(Close,xEMABars);
?if xEMA[xRocBars]=0 then xROCEMA = 0
?else xROCEMA = 100*xEMA/xEMA[xROCBars]-100;
?xTrend = XAverage(Close,xTrendBars);
?{---- check for signals ----}
?if xROCEMA crosses above 0 then begin
? ?if Close>xTrend then Buy else ExitShort;
? ?end;
?if xROCEMA crosses below 0 then begin
? ?if Close<xTrend then Sell else ExitLong;
? ?end;
?
?{---- handle long side ----}
?if MarketPosition=1 then begin
? ?xProfitLevel = EntryPrice(0)+xProfit;
? ?xStopLevel = EntryPrice(0)-xStopLoss;
? ?if Close>xProfitLevel or Close<xStopLevel then exitlong; ?
? ?end;
?{---- handle short side ----}
?if MarketPosition=-1 then begin
? ?xProfitLevel = EntryPrice(0)-xProfit;
? ?xStopLevel = EntryPrice(0)+xStopLoss;
? ?if Close<xProfitLevel or Close>xStopLevel then exitshort; ?
? ?end;