.

# Ultimate Support Resistance Trading AFL - Amibroker AFL Code

### Click Image To Enlarge. Please Rate And Comment.

```_SECTION_BEGIN("ATR Study");
//* ATR Study:  */

Exclude = MA(V,50)<200 ;
MaxGraph = 12;
Graph0 = C;
Graph0Color = 1;
Graph0Style = 64;

RegLength = 5;//Optimize("RegLength",5, 2,11,2);
ATRMultiplier = 1;//Optimize("ATRMultiplier",1,0.7,1.25,.05);

Graph9 = LLV(L+ATRMultiplier*ATR(SellATRPeriod),SellOffset);  /*  GREEN */

Graph8Style=Graph9Style = 5;
Graph9Color=  5;  /* 5 is green */
Graph8Color = 4;  /* 4 is red */

ticker = 0.0;//Optimize("Tickerk",0,0,1,0.125);

Buy = Cross(C,Graph8) AND C>Graph9 AND LinRegSlope(EMA(C,17),2)>0;
Sell = Cross(Graph8,C) AND LinRegSlope(C,2)<0;

PlotShapes(Sell*shapeDownTriangle,colorYellow);

SellStop= Ref(Graph8,-1);   //IIf(Cross(Graph8,C),Ref(Graph8,-1),0);
SellPrice = Min( SellStop, High )- ticker;

//ApplyStop(2,3,Optimize("TrailingStop",15,0,20,5),1);

NumColumns = 8;
Column0Format = 1.0;
Column0Name = "Long/Sell";
Column1 = C;
Column1Name = "Close       ";
Column1Format = 1.2;
Column2 = MA(V,17);
Column2Name = "17 Ma Vol   ";
Column2Format = 1.0;
Column3 = MA(C,17)/MA(C,50);
Column3Name = "% 17/50 ";
Column3Format = 1.2;
Column3Format = 1.2;
Column4= MA(C,17);
Column4Name="17 C ma";
Column4Format = 1.2;
Column5= MA(C,50);
Column5Name="50 C ma";
Column5Format = 1.2;

Column6Format = 1.2;
Column7= SellPrice;
Column7Name="Sellprice";
Column7Format = 1.2;
_SECTION_END();

_SECTION_BEGIN("Boe Tie");

/* Boe Tie - AFL Implementation by Geoff Mulhall 12-5-2001 */

dollars = 5000; /* Or whatever you investment is to be - for the bangforbuck calculation */
maShort = 10;
maMedium = 20;
maLong = 30;

/* Bow Tie conditions - Short term moving average has crossed the medium term moving average sometime in the last 15 days - Add more conditions for more days */

cond11 = Ref(Cross(MA(Close,maShort),MA(Close,maMedium)),-1) > 0;
cond12 =  Ref(Cross(MA(Close,maShort),MA(Close,maMedium)),-2) > 0;
cond13 =  Ref(Cross(MA(Close,maShort),MA(Close,maMedium)),-3) > 0;
cond14 =  Ref(Cross(MA(Close,maShort),MA(Close,maMedium)),-4) > 0;
cond15 =  Ref(Cross(MA(Close,maShort),MA(Close,maMedium)),-5) > 0;
cond16 =  Ref(Cross(MA(Close,maShort),MA(Close,maMedium)),-6) > 0;
cond17 =  Ref(Cross(MA(Close,maShort),MA(Close,maMedium)),-7) > 0;
cond18 =  Ref(Cross(MA(Close,maShort),MA(Close,maMedium)),-8) > 0;
cond19 =  Ref(Cross(MA(Close,maShort),MA(Close,maMedium)),-9) > 0;
cond110 =  Ref(Cross(MA(Close,maShort),MA(Close,maMedium)),-10) > 0;
cond111 =  Ref(Cross(MA(Close,maShort),MA(Close,maMedium)),-11) > 0;
cond112 =  Ref(Cross(MA(Close,maShort),MA(Close,maMedium)),-12) > 0;
cond113 =  Ref(Cross(MA(Close,maShort),MA(Close,maMedium)),-13) > 0;
cond114 =  Ref(Cross(MA(Close,maShort),MA(Close,maMedium)),-14) > 0;
cond115 =  Ref(Cross(MA(Close,maShort),MA(Close,maMedium)),-15) > 0;

cond1 = cond11 OR cond12 OR cond13 OR cond14 OR cond15 OR cond16 OR cond17 OR cond18 OR cond19 OR cond110 OR cond111 OR cond112 OR cond113 OR cond114 OR cond115;

/* Moving averages must be in the correct order at the buy signal */

cond2 = (MA(Close,maShort) > MA(Close,maMedium)) AND (MA(Close,maMedium) > MA(Close,maLong));

/* Signal is given when the close crosses above the short term moving average */

cond3 = Cross(Close,MA(Close,maShort));

Filter =  cond1 AND cond2 AND cond3;

Sell = 0;

BangForBucks = (dollars/Close) * ATR(200);

NumColumns = 3;
Column0 = Close;
Column0Format = 3.2;
Column0Name = "Close";
Column1 = ATR(maLong);
Column1Format = 3.4;
Column1Name = "ATR - maLong";
Column2 = BangForBucks;
Column2Format = 3.2;
Column2Name = "BangForBucks";

_SECTION_END();
```
{"ft_lang_label":"__label__en","ft_lang_prob":0.5275878,"math_prob":0.99745,"size":4044,"snap":"2021-31-2021-39","text_gpt3_token_len":1477,"char_repetition_ratio":0.23960397,"word_repetition_ratio":0.0,"special_character_ratio":0.37611276,"punctuation_ratio":0.2901734,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.98867446,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-09-21T11:18:11Z\",\"WARC-Record-ID\":\"<urn:uuid:84d2d75f-daa0-4db2-a4b8-e2cff39b9df6>\",\"Content-Length\":\"186600\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:9d81b229-0efc-4f4b-a98b-54dc6d4acd12>\",\"WARC-Concurrent-To\":\"<urn:uuid:554157c8-125d-4e4c-aa1c-4b1bf50c8639>\",\"WARC-IP-Address\":\"172.217.0.51\",\"WARC-Target-URI\":\"https://www.aflbank.com/2017/05/ultimate-support-resistance-trading-afl.html\",\"WARC-Payload-Digest\":\"sha1:UO7IJPT4H5JD7B5MM4XSZ2HPOPJGCU6C\",\"WARC-Block-Digest\":\"sha1:MHMPM45BLV37ZPGGIMMTLFGSM2XCD7JL\",\"WARC-Identified-Payload-Type\":\"application/xhtml+xml\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-39/CC-MAIN-2021-39_segments_1631780057202.68_warc_CC-MAIN-20210921101319-20210921131319-00103.warc.gz\"}"}