[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [amibroker] Need some code help, please



PureBytes Links

Trading Reference Links

I thought I would be able to cut and paste what you did from one AFL
(DagsPeaker) to another (NateSystem), but I am just too dumb. What I want
to do now is run an Explore on my database of funds where only the following
are chosen:
1) The NateSystem_s1.AFL you wrote for us is giving a green (buy) arrow
(I have attached it); and-
2) Using the ADX/DMI indicator, the +DMI is greater than the -DMI (same
as you did for the DagsPeaker. I left your work in the rest of the post)


At 09:49 PM 10/6/01 -0400, you wrote:
> Nate, David: I'd exclude "and ADXdown" from Sell criteria (unless you
>are planning to go short): you do not want to stay with your trade until
>ADX becomes bearish. So the result will be: /* Dags Peaker and adx v1.3
>
>v1.1: Changed peak val arg to 6 (from 10)
>v1.0: Initial version
>*/
> */
>> MDI(14);
>< MDI(14);
>pv = Peak(Close, 3);
>
>Buy = IsTrue (Cross(Close, pv + pv/500))and ADXup;
>Sell = IsTrue (Cross( pv + pv/1000, Close));
>
>inTrade = Flip (Buy, Sell);
>MaxGraph=5;
>Graph0 = Close;
>Graph1 = pv;
>Graph0BarColor = IIf (Ref (inTrade, -1), 5, 1);
>Graph1BarColor = IIf (Buy, 5, IIf (Sell, 4
>>
Sorry to load you with this- If it is too much, let me know and I'll try to
figure it out myself (yea, right!)

Nate
/*
* Nate's system: combination of Jaco MRI, Williams, and MACD
* Dima's addition: ADX, and stochastic
*/

// Adjustable criteria
moBuyCriteria = 60; // 70?
moSellCriteria = 20; // 30?
rocPeriod = 10;
jacoHold =20; // Hold period
exitOnOverbought = 0;


pctStop = 
IIF (name() == "SAFGX", 0.92,
IIF (name() == "ARGFX", 0.93, 
IIF (name() == "BGRFX", 0.95,
IIF (name() == "CSRSX", 0.93,
IIF (name() == "DEFIX", 0.91, // OR 96 !!!
IIF (name() == "DMCVX", 0.96,
IIF (name() == "DTSVX", 0.92,
IIF (name() == "FRESX", 0.93,
IIF (name() == "NBGNX", 0.92,
IIF (name() == "OAKLX", 0.93,
IIF (name() == "PRSVX", 0.91,
IIF (name() == "SKSEX", 0.94,
IIF (name() == "OAKSX", 0.92,

IIF (name() == "Bpscx", 0.95, 
IIF (name() == "wmcvx", 0.95, // 92 and 95 are the best; results do not very much
IIF (name() == "CSRSX", 0.95, 
IIF (name() == "PRHSX", 0.93,
IIF (name() == "REPSX", 0.96,
IIF (name() == "TMRFX", 0.94,
IIF (name() == "WGROX", 0.93, // 93 or 96 are the best; intermediate are worse
IIF (name() == "CGMFX", 0.94,
IIF (name() == "FBRVX", 0.95,
IIF (name() == "^SPC", 0.92,
IIF (name() == "^SML", 0.92,
IIF (name() == "^WSX", 0.91,

0.93)))))))))))))))))))))))));
maLen = 1;
peakCf = 3;


yc = ref (close, -1);

highestval = max (peak (ma(yc,maLen),peakCf ), hhv (ma (yc, maLen), 14));

stopprice = highestval * pctStop;


// Jaco MRI
/* MRI developed by Jaco Jonker*/

mo=close/ref(close,1)*100 - rsi(14);
HV = hhv(mo,200);
LV = llv(mo,200);
AV = (HV+LV)/2;


jacoBuy = isTrue (mo > moBuyCriteria);
jacoBuy = hold (jacoBuy, jacoHold);
jacoSell = isTrue (mo < moSellCriteria);
jacoSell = hold (jacoSell, jacoHold);

// Williams AC+
outsidebar = outside();
insidebar = H <= Ref(H,-1) and L >= Ref(L,-1);
upbar = H > ref(H,-1) and L >= ref(L, -1);
downbar = L < ref(L,-1) and H <= ref(H,-1);
barcolor=iif(outsidebar, 1, 
iif(downbar, 4, 
iif(upbar, 5, 
iif(insidebar,6, 0 ) ) ) );


var1=ma( A , 34);
var2=ma( A,5);
var3=var2-var1;
var4=var3-ma(var3,5);

wilBuy = var4 > 0;
wilSell = var4 < 0;

// Graph0=var4;
// graph0style=2+4;
// Graph1=wilders(var4,5);
// Graph1Style=5;
// Graph0Barcolor=Barcolor;

// MACD
macdBuy = macd() > signal();
macdSell = macd() < signal();

// MA (instead of Zig-Zag)
mac = ma (c, 10);
maBuy = close > mac AND ref (close > mac, -1); // AND mac >= ref (mac, -1);
maSell = close < mac;

// ROC
rr = roc (close, rocPeriod);

absRocBuy = rr > 0;
absRocSell = rr < 0;

marr = ma (rr, 3);
rocDirBuy = marr > ref (marr, -1); // slope is up
rocDirSell = NOT rocDirBuy;

/* detect the last bar */
barnumber = cum( 1 );
lastbar = barnumber == lastvalue( barnumber ) -1;

buyLine = jacoBuy AND wilBuy AND macdBuy AND maBuy AND rocDirBuy;
buy1 = cross (buyLine, 0);

// Recalculate SL x% from the highest high since taking the position
highestval = hhv (yc, barssince (buy1));

sellSignal = jacoSell AND wilSell AND macdSell AND maSell AND rocDirSell;
stopprice = highestval * IIF (sellSignal, 0.96, pctStop);

sellLineNoLastBar = (exitOnOverbought AND sellSignal) OR cross (stopprice, close);
rocDirSell OR cross (stopprice, close);
sellLine = sellLineNoLastBar OR lastbar;

sell1 = cross (sellLine, 0);
sellNoLastBar = cross (sellLineNoLastBar , 0);
sell2 = cross (sellSignal, 0);

buy = ExRem (buy1, sell1);
sell = ExRem (sell1, buy1);

inTrade = flip (buy, sell);
/*
graph0 = close;
graph0barcolor = IIF (inTrade, 5, 1);
*/
maxgraph = 12;
graph0 = jacoBuy;
graph1 = wilBuy * 2;
graph2 = macdBuy * 3;
graph3 = maBuy * 4;
graph4 = rocDirBuy * 5;
graph5 = jacoSell * -1;
graph6 = wilSell * -2;
graph7 = macdSell * -3;
graph8 = maSell * -4;
graph9 = rocDirSell * -5;
graph10 = buy1 * 6 - sellNoLastBar * 6 -sell2 * 3;

graph0style = graph1style = graph2style = graph3style = graph4style = graph5style = graph6style = graph7style = graph8style = graph9style = 28;
graph10style = 9;
graph0color = graph5color = 2;
graph1color = graph6color = 3;
graph2color = graph7color = 4;
graph3color = graph8color = 5;
graph4color = graph9color = 6;
graph10color = 7;
title = "Nate's system " + name() ;