Permission denied!

Stock Portfolio Organizer

The ultimate porfolio management solution.

Shares, Margin, CFD's, Futures and Forex
EOD and Realtime
Dividends and Trust Distributions
And Much More ....
For Portfolio Manager Click Here

WiseTrader Toolbox

#1 Selling Amibroker Plugin featuring:

Advanced Adaptive Indicators
Advanced Pattern Exploration
Neural Networks
And Much More ....
Find Out More Here

GEN_CROSS_CONF for Amibroker (AFL)
miheer123
almost 14 years ago
Amibroker (AFL)

Rating:
3 / 5 (Votes 2)
Tags:
trading system, amibroker

I am not a coder but this formula i collect from this site http://lurama125.com/TradingResources.htm. You can go there to read more about this indicator.

You will need two include files that go in the include directory of Amibroker:
http://wisestocktrader.com/indicatorpasties/120-liba-afl
http://wisestocktrader.com/indicatorpasties/119-pebslib-afl

Screenshots

Similar Indicators / Formulas

weighted moving average scan
Submitted by naninn over 13 years ago
Kase Peak Osc. V2 batu
Submitted by batu1453 over 10 years ago
Kase CD V2batu
Submitted by batu1453 over 10 years ago
Ichimoku
Submitted by prashantrdx over 10 years ago
EMA System Ribbon
Submitted by yo123 over 13 years ago
Three-Bar Inside Bar Pattern
Submitted by EliStern over 13 years ago

Indicator / Formula

Copy & Paste Friendly
//GEN_CROSS_CONF.AFL

#include_once <LibA.afl>;
SetBarsRequired(500000);

pebstime = Hour()*60+Minute();

OptimizerSetEngine("cmae");


Lastticktime = Param("Lastticktime",9999,0,9999,1); //If like in SA there is a closing tick instead of a closing bar, then we execute immediately there instead of the usual delay of 1 bar
Firsttradetime = Param("FirstTradeTime",0,0,9999,1); //Never do any trade before this time
Lasttradetime = Param("LastTradeTime",9999,0,9999,1); //Never do any trade after this time
Firstsignaltime = Param("FirstSignalTime",0,0,9999,1); //do not trade on signals that trigger before this time, remember trade is entered usually 1 bar delay after signal
Lastsignaltime = Param("LastSignalTime",9999,0,9999,1); //do not trade on signals that trigger after this time, remember trade is entered usually 1 bar delay after signal
ExitatClose = ParamToggle("Exit at Close of Day","No|Yes");
xxxdelay = 1-(pebstime>=Lastticktime)*1; //Ignore the delay when last tick, otherwise that trade will only happen next morning
Confirm = ParamToggle("Confirming bar required","N|Y",1);


fn1 = ParamList("Fn1","ema|sma|brkema|brkema2|brkema3|brkema4|frama|kama|tsf|dema|tema|wilder|hull");
n_fn1_par = Param("n_Fn1",7,1,100,1);
fn2 = ParamList("Fn2","ema|sma|brkema|brkema2|brkema3|brkema4|frama|kama|tsf|dema|tema|wilder|hull");
n_fn2_par = Param("n_Fn2",21,1,100,1);
n_fn1_opt = ParamToggle("Optimize n_Fn1","No|Yes",1);
n_fn2_opt = ParamToggle("Optimize n_Fn2","No|Yes",1);
target_fn = ParamList("TargetFn","OHLC4|O|H|L|C|ema|sma|brkema|brkema2|brkema3|brkema4|frama|kama|tsf|dema|tema|wilder|hull");
n_targetfn_par = Param("n_TargetFn",20,1,100,1);
n_targetfn_opt = ParamToggle("Optimize n_TargetFn","No|Yes",0);
Cntxt = ParamList("Context","None|Contextfilter|Contextfilter2|Contextfilter_Hist60");

firststoptime = Param("First Stoptime",0,0,9999,1);
Laststoptime = Param("Last Stoptime",9999,0,9999,1);
TradeSL = Param("Trade stoploss",99999,0,99999,1);
TradeSP = Param("Trade stopprofit",99999,0,99999,1);
DaySL = Param("Day stoploss",99999,0,99999,1);
DaySP = Param("Day stopprofit",99999,0,99999,1);
MonthSL = Param("Month stoploss",99999,0,99999,1);
MonthSP = Param("Month stopprofit",99999,0,99999,1);



if (NOT n_fn1_opt){
n_fn1= n_fn1_par;
}
else
{
n_fn1 = Optimize("n_Fn1",n_fn1_par,1,100,1);
}

if (NOT n_fn2_opt){
n_fn2= n_fn2_par;
}
else
{
n_fn2 = Optimize("n_Fn2",n_fn2_par,1,100,1);
}

if (NOT n_targetfn_opt){
n_targetfn= n_targetfn_par;
}
else
{
n_targetfn = Optimize("n_TargetFn",n_targetfn_par,1,20,1);
}




symbol = ParamStr("Basesymbol",Name());

// trade on next bar open
SetTradeDelays( 0, 0, 0, 0 );
BuyPrice = SellPrice = Open;
ShortPrice = CoverPrice = Open;

//Points only
PositionSize = MarginDeposit = 1;


SetForeign(symbol);

switch (target_fn){

case "OHLC4":
xxx = (O+H+L+C)/4;
break;
case "O":
xxx = O;
break;
case "H":
xxx=H;
break;
case "L":
xxx=L;
break;
case "C":
xxx = C;
break;
case "ema":
xxx = EMA((O+H+L+C)/4,n_targetfn);
break;
case "sma":
xxx = MA((O+H+L+C)/4,n_targetfn);
break;
case "brkema":
xxx = brkema(n_targetfn);
break;
case "brkema2":
xxx = brkema2(n_targetfn);
break;
case "brkema3":
xxx = brkema3(n_targetfn);
break;
case "brkema4":
xxx = brkema4(n_targetfn);
break;
case "frama":
xxx = frama(n_targetfn);
break;
case "kama":
xxx = kama(n_targetfn,2,30);
break;
case "tsf":
xxx = TSF((O+H+L+C)/4,n_targetfn);
break;
case "dema":
xxx = DEMA((O+H+L+C)/4,n_targetfn);
break;
case "tema":
xxx = TEMA((O+H+L+C)/4,n_targetfn);
break;
case "wilder":
xxx = Wilders((O+H+L+C)/4,n_targetfn);
break;
case "hull":
xxx = HullMA((O+H+L+C)/4,n_targetfn,0);
break;

}

switch (fn1){
case "ema":
aaa = EMA(xxx,n_fn1);
break;
case "sma":
aaa = MA(xxx,n_fn1);
break;
case "brkema":
aaa = brkema(n_fn1);
break;
case "brkema2":
aaa = brkema2(n_fn1);
break;
case "brkema3":
aaa = brkema3(n_fn1);
break;
case "brkema4":
aaa = brkema4(n_fn1);
break;
case "frama":
aaa = frama(n_fn1);
break;
case "kama":
aaa = kama(n_fn1,2,30);
break;
case "tsf":
aaa = TSF(xxx,n_fn1);
break;
case "dema":
aaa = DEMA(xxx,n_fn1);
break;
case "tema":
aaa = TEMA(xxx,n_fn1);
break;
case "wilder":
aaa = Wilders(xxx,n_fn1);
break;
case "hull":
aaa = HullMA(xxx,n_fn1,0);
break;

}

switch (fn2){
case "ema":
bbb = EMA(xxx,n_fn2);
break;
case "sma":
bbb = MA(xxx,n_fn2);
break;
case "brkema":
bbb = brkema(n_fn2);
break;
case "brkema2":
bbb = brkema2(n_fn2);
break;
case "brkema3":
bbb = brkema3(n_fn2);
break;
case "brkema4":
bbb = brkema4(n_fn2);
break;
case "frama":
bbb = frama(n_fn2);
break;
case "kama":
bbb = kama(n_fn2,2,30);
break;
case "tsf":
bbb = TSF(xxx,n_fn2);
break;
case "dema":
bbb = DEMA(xxx,n_fn2);
break;
case "tema":
bbb = TEMA(xxx,n_fn2);
break;
case "wilder":
bbb = Wilders(xxx,n_fn2);
break;
case "hull":
bbb = HullMA(xxx,n_fn2,0);
break;

}


Confirmvalue = IIf(aaa>=bbb,( Close > ValueWhen( Cross( aaa, bbb ), Max( Open, Close ), 1 ) ),( Close < ValueWhen( Cross( bbb, aaa ), Min( Open, Close ), 1 ) ));
confirmvalue = IIf(Confirm,Confirmvalue,1);

Buysignal = (aaa>=bbb) AND Confirmvalue AND (pebstime>=firstsignaltime) AND (pebstime<=Lastsignaltime);
Sellsignal = (aaa<bbb) AND Confirmvalue AND (pebstime>=firstsignaltime) AND (pebstime<=Lastsignaltime) OR ((pebstime>=Lastticktime) AND ExitAtClose );

Shortsignal = (aaa<bbb) AND Confirmvalue AND (pebstime>=firstsignaltime) AND (pebstime<=Lastsignaltime);
Coversignal = (aaa>=bbb) AND Confirmvalue AND (pebstime>=firstsignaltime) AND (pebstime<=Lastsignaltime) OR ((pebstime>=Lastticktime) AND ExitAtClose);

//is this the best spot to remove the extra signals? i think so because after contextfilters you expect and do not want to remove consecutive buy or short signals
Buysignal = ExRem(Buysignal,Sellsignal);
Shortsignal = ExRem(Shortsignal,Coversignal);


Longstate = Flip(Buysignal,(Sellsignal OR Shortsignal));
Shortstate = Flip(Shortsignal,(Coversignal OR BuySignal));

Totalstate = Longstate*1+Shortstate*(-1);
totalstate = Ref(totalstate,-xxxdelay); //apply trade delay before applying contextfilter as contextfilters already have trade delay built in =




switch (Cntxt){
case "None":
break;
case "Contextfilter":
Totalstate = Contextfilter(Totalstate);
break;
case "Contextfilter2":
Totalstate = Contextfilter2(Totalstate);
break;
case "Contextfilter_Hist60":
Totalstate = Contextfilter_Hist60(Totalstate);
break;
}

//apply stops; delay already built in here correctly? still need to adjust for lastticktime 0 delay
totalstate = TradeSLSP(totalstate,1,tradeSL,tradeSP,firststoptime,Laststoptime,Lastticktime);
totalstate = DaySLSP(totalstate,1,DaySL,DaySP,firststoptime,Laststoptime,Lastticktime);
totalstate = MonthSLSP(totalstate,1,MonthSL,MonthSP,firststoptime,Laststoptime,Lastticktime);


Buysignal = (totalstate>0) AND (pebstime>=firsttradetime) AND (pebstime<=Lasttradetime);
Sellsignal = (totalstate<=0) AND (pebstime>=firsttradetime) AND (pebstime<=Lasttradetime);

Shortsignal = (totalstate<0) AND (pebstime>=firsttradetime) AND (pebstime<=Lasttradetime);
Coversignal = (totalstate>=0) AND (pebstime>=firsttradetime) AND (pebstime<=Lasttradetime);

RestorePriceArrays();


Buy = Buysignal;
Sell = Sellsignal;

Short = Shortsignal;
Cover = Coversignal;

Longstate = Flip(Buysignal,(Sellsignal OR Shortsignal));
Shortstate = Flip(Shortsignal,(Coversignal OR BuySignal));

Totalstate = Longstate*1+Shortstate*(-1);
//this totalstate already has the trade delay in

PlotOHLC(0,0,Totalstate,Totalstate,_DEFAULT_NAME(),IIf(Totalstate<0,colorRed,colorGreen),styleCloud);
SetChartBkColor(colorBlack);

9 comments

1. rajaswamy

good indicator sir but not working pls guide how to install it i tried thet include also but not working can you pls tell briefly how to install it

2. tsunamizawa

go to the website lurama125.com, copy pebslib.afl & liba.afl and paste the afls to folder: include. it must be working well.

3. sajid

Totalstate = Contextfilter2(Totalstate);
ERROR 30 SHOW
CHECK IT AGAIN

4. tsunamizawa

copy gen_cross_conf.afl and put it to amibroker/formula/custom.

copy pebslib.afl & liba.afl and put them to amibroker/formula/include.

just do it and it must be work fine.

5. tunglam4991

hi my Friend,
Pls check it again, its not work fine. Thanks

6. SADAI

You can copy and paste the two afl in this afl starting

http://wisestocktrader.com/indicatorpasties/120-liba-afl
http://wisestocktrader.com/indicatorpasties/119-pebslib-afl

7. tunglam4991

Hi SADAI – my friend,
I tried to do this by your way, but it still can’t display fine on Ami. Please help me another better way. Thank you so much and looking forward to hearing from you soon.

8. SADAI

I pasted and replacing the third line #include . It is working

9. tunglam4991

Hi SADAI – my friend,

I really high appreciate your help, I got it following your instructions. Thank you.

Leave Comment

Please login here to leave a comment.

Back