Simple Coding Help - No Promise.

how to edit AFL for autotrading so
buy and cover on same signal
sell and short on same signal
1) as like buy ---sell+short---cover+buy----
2) as like sell ---buy+cover---short+sell----
 

sr114

Well-Known Member
I Had asked for some help but the code might be a little complicated and nobody could helped. I tried the whole week with every possible loop combination with no success.
I ripped the code code appart and left only a part of it to make it simple if anyone might be able to help me.
What I would like to do is how to loop the code to plot only the last n trendlines, and I will adapt it later to the rest of the code.

Do u want the plot in this way? I think u need this as per ur query.


[ images from 2 afl -
upper pane is the mod afl
lower pane is the afl u posted]



rgds
Subroto
 
Last edited:

sr114

Well-Known Member
Subroto ji can u pls share the AFL ?
Thank u
Shiraj
Here is the afl

Code:
 Plot(C,"Price",1,64,0,0,0,0);
_SECTION_BEGIN("Trendlines Multitimeframe");
// Amibroker AFL code by Edward Pottasch, 6/8/2011
// Using fractals to create automatic trendlines
// Using option to show multiple timeframes

xx=BarIndex();x=xx;Lx=LastValue(x);
nbar=Param("N Pivot Bars",3,2,50,1); 
pds=Param(" No of Bar to plot?", 50,10,200,5);

    fc=2;
    pk=H>Ref(HHV(H,nbar*fc),-1) AND Ref(HHV(H,nbar),nbar)<=H;
    tr=L<Ref(LLV(L,nbar*fc),-1) AND Ref(LLV(L,nbar),nbar)>=L;

px0=ValueWhen(pk,x,0); tx0=ValueWhen(tr,x,0);
px1=ValueWhen(pk,x,1); tx1=ValueWhen(tr,x,1);
px2=ValueWhen(pk,x,2); tx2=ValueWhen(tr,x,2);
ph0=ValueWhen(pk,H,0); tl0=ValueWhen(tr,L,0);
ph1=ValueWhen(pk,H,1); tl1=ValueWhen(tr,L,1);
ph2=ValueWhen(pk,H,2); tl2=ValueWhen(tr,L,2);

pkh=IIf(pk,H,Null);
trl=IIf(tr,L,Null);

y0=ValueWhen(tr,trl,0); 
y1=ValueWhen(tr,trl,1);
x0=ValueWhen(tr,xx,0);
x1=ValueWhen(tr,xx,1);

aa=(Y0-Y1)/(X0-X1);
ls1=aa*(xx-X1)+Y1;
dls1=ls1-Ref(ls1,-1);

y0=ValueWhen(pk,pkh,0); 
y1=ValueWhen(pk,pkh,1);
x0=ValueWhen(pk,xx,0);
x1=ValueWhen(pk,xx,1);

aa=(Y0-Y1)/(X0-X1);
hs1=aa*(xx-X1)+Y1;
dhs1=hs1-Ref(hs1,-1);

    dd=0.0;
    Vh=dd*(ValueWhen(pk,C)-ValueWhen(pk,Ref(C,-1)))/ValueWhen(pk,C);
    Vl=dd*(ValueWhen(tr,C)-ValueWhen(tr,Ref(C,-1)))/ValueWhen(tr,C);
   
    ls1=IIf(dls1>=Vl,ls1,Null);
    hs1=IIf(dhs1<=Vh,hs1,Null);
    
bi = BarIndex();

Plot(IIf(bi<  LastValue( bi )-pds ,Null,ls1),"\nLower Trendline",colorBrightGreen,styleLine|styleNoRescale,0,0,0,-1);

Plot(IIf(bi<  LastValue( bi )-pds ,Null,hs1),"\nUpper Trendline",colorRed,styleLine|styleNoRescale,0,0,0,-1);

_SECTION_END();
rgds
Subroto
 
I am now working on a data file (.txt) and i would like to import it into the database in Amibroker. The txt file looks like this:

2015/01/02/09/14/01; 23676; 23676; 23676; 23676; 283
2015/01/02/09/15/00; 23680; 23709; 23665; 23672; 283

And I'm stuck at the first column, which displays date and time at the same time. I know I have to modify the ASCII import setting file (default.format), but after looking at the doc below I still have no idea on how i should change the setting to import the txt above.

P.S. Changing the format of my txt doesn't help, as it's a real-time data feed actually.

Link FYI: http://www.amibroker.com/guide/d_ascii.html

Thank you !!!
 

Similar threads