Traderji.com


k-nearest neighbors algorithm

Discuss k-nearest neighbors algorithm at the MetaTrader within the Traderji.com; sorry for late reply.. Originally Posted by Shantala Any way, how to use it Predicting ...


Go Back   Traderji.com > TOOLS & RESOURCES > Software > MetaTrader



Reply
 
Thread Tools
  #11  
Old 1st August 2014, 06:45 PM
amibrokerfans's Avatar
Member
 
Join Date: May 2012
Location: kolkata
Posts: 706
Thanks: 121
Thanked 820 Times in 290 Posts
amibrokerfans is a splendid one to beholdamibrokerfans is a splendid one to beholdamibrokerfans is a splendid one to beholdamibrokerfans is a splendid one to beholdamibrokerfans is a splendid one to beholdamibrokerfans is a splendid one to beholdamibrokerfans is a splendid one to behold
Default Re: k-nearest neighbors algorithm

sorry for late reply..

Quote:
Originally Posted by Shantala View Post
Any way, how to use it
Predicting up move on 5 min chart, down move on hourly.
Or is it for daily chart only?
Quote:
Originally Posted by Leonid View Post
Plz. share your experience. I do not use Metatrader so cannot have a first hand experience.

Thanks.


a 'prediction' is a prediction.
so you never cant rely on this type of indicators for trading!

BUT
on other hand, what we do for trading?
we do 'prediction'. we try to imagine what will be market next move and go for order.
i remember once a pro trader told that - i flip a coin, if its head i go for long, if tail i go short. and rest all about money management.

this indicator can help us to make mind set whether i go long or short. WITH OTHER confirmations.price level does not follow it much, it can be use for trend.

this indicator neutral net type. so lower time frame , much noise not accepted. atleast 1 hour min.

and "best fit" also needed on 'Npast' parameter.

but then again

a 'prediction' is a prediction.





below chart i posted 27th july 4.00 p.m

Quote:
Originally Posted by amibrokerfans View Post


and here is recent scenario..


Last edited by amibrokerfans; 1st August 2014 at 07:00 PM.
Reply With Quote
The Following 6 Users Say Thank You to amibrokerfans For This Useful Post:
amitrandive (1st August 2014), dell (1st August 2014), laotze (1st August 2014), Leonid (2nd August 2014), Shantala (1st August 2014), traderami (3rd August 2014)

Looking for a share broker?

Name:Phone:
Email:City:
State:
Are you a day trader?
  #12  
Old 27th August 2014, 01:37 PM
Member
 
Join Date: Jul 2009
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
mayank87 is on a distinguished road
Default Re: k-nearest neighbors algorithm

Hi

Please add pop up alert to following indicator

thnx in advance

// ********************************************
// INDICATOR IVERGENCE
// DATE :07-30-04
// PROGRAMMER :M.Lauronen
// COPYRIGHTS :Public Domain
// ********************************************

// --------------------------------------------
// Recommended AmiBroker indicator settings:
// Level 0
// Percent
// Middle
// Scaling: Custom 0 - 100
// --------------------------------------------

// Adjust the following parameters to suit your needs
// Adjust the following parameters to suit your needs

//period = Param("% change",0.4,0.1,25,0.1);
//period = 5;
uplimit=2;
uplimit=IIf(Interval()==in15Minute,4,IIf(Interval( )==inHourly,8,
IIf(Interval()==inDaily,12,uplimit)));
i=uplimit;
globalTitile=" ";
BuyCond =ShortCond=False;
divergenceCount=0;
highCount=0.0;

for(;i>=0.2{
numChg = i ;
i=i-0.1;
// --------------------------------------------
// Divergence for LONG
// --------------------------------------------

trendMom = RSI(5);

periods = 5;
Ksmooth = 3;
trendStoch=StochK( periods , Ksmooth);

bull=High - EMA(Close,13);
bear=Low - EMA(Close,13);
bb=bull+bear;


Hist=MACD(12,26)-Signal(12,26,9);

FI = (Close - Ref(Close, -1)) * V;


trendZig = Zig(L, numChg);


f = trendZig > Ref(trendZig, -1) AND Ref(trendZig, -1) < Ref(trendZig, -2);

p1 = ValueWhen(f, Ref(trendZig, -1), 1);
p2 = ValueWhen(f, Ref(trendZig, -1), 2);
r1 = ValueWhen(f, Ref(trendMom,-1), 1);
r2 = ValueWhen(f, Ref(trendMom,-1), 2);
stockUp1= ValueWhen(f, Ref(trendStoch,-1), 1);
stockUp2= ValueWhen(f, Ref(trendStoch,-1), 2);
bbUP1= ValueWhen(f, Ref(bb,-1), 1);
bbUP2= ValueWhen(f, Ref(bb,-1), 2);
HistUP1= ValueWhen(f, Ref(Hist,-1), 1);
HistUP2= ValueWhen(f, Ref(Hist,-1), 2);
FIUP1= ValueWhen(f, Ref(FI,-1), 1);
FIUP2= ValueWhen(f, Ref(FI,-1), 2);


f = r1 > r2 AND p1 < p2;
fStoch=stockUp1 > stockUp2 AND p1 < p2;
fbb=bbUP1> bbUP2 AND p1 < p2;
HistUP=HistUP1> HistUP2 AND p1 < p2;
FIUP= FIUP1 > FIUP2 AND p1 < p2;

sigRSI = f AND NOT Ref(f, -1) AND trendMom > Ref(trendMom, -1);
sigStockUp = fStoch AND NOT Ref(fStoch, -1) AND trendStoch > Ref(trendStoch, -1);
sigbbUp = fbb AND NOT Ref(fbb, -1) AND bb> Ref(bb, -1);
HistSigUP = HistUP AND NOT Ref(HistUP , -1) AND Hist> Ref(Hist, -1);
FISigUP = FIUP AND NOT Ref(FIUP, -1) AND FI> Ref(FI, -1);

//_N(str = "(" + period + ")");
///Plot(trendMom, "RSI" + str, colorWhite);
Plot(trendZig, "zig", colorBlack,styleOwnScale);
Plot(sigRSI* 100, "RsiSigUp", colorGreen, styleHistogram + styleThick + styleNoLabel);
Plot(sigStockUp* 100, "StockSigUp", colorGreen, styleHistogram + styleThick + styleNoLabel);
Plot(sigbbUp* 100, "bbUp", colorGreen, styleHistogram + styleThick + styleNoLabel);
Plot(HistSigUP * 100, "MACDUp", colorGreen, styleHistogram + styleThick + styleNoLabel);
Plot(FISigUP * 100, "FIUP", colorGreen, styleHistogram + styleThick + styleNoLabel);



// --------------------------------------------
// Divergence for SHORT
// --------------------------------------------

trendZig2 = Zig(H, numChg);

f = trendZig2 < Ref(trendZig2, -1) AND Ref(trendZig2, -1) > Ref(trendZig2, -2);

p1 = ValueWhen(f, Ref(trendZig2, -1), 1);
p2 = ValueWhen(f, Ref(trendZig2, -1), 2);
r1 = ValueWhen(f, Ref(trendMom,-1), 1);
r2 = ValueWhen(f, Ref(trendMom,-1), 2);
stockDown1= ValueWhen(f, Ref(trendStoch,-1), 1);
stockDown2= ValueWhen(f, Ref(trendStoch,-1), 2);
bbDown1= ValueWhen(f, Ref(bb,-1), 1);
bbDown2= ValueWhen(f, Ref(bb,-1), 2);
HistDown1= ValueWhen(f, Ref(Hist,-1), 1);
HistDown2= ValueWhen(f, Ref(Hist,-1), 2);
FIDown1= ValueWhen(f, Ref(FI,-1), 1);
FIDown2= ValueWhen(f, Ref(FI,-1), 2);



f = r1 < r2 AND p1 > p2;
fStoch=stockDown1 < stockDown2 AND p1 > p2;
fbb=bbDown1 < bbDown2 AND p1 > p2;
HistDown=HistDown1< HistDown2 AND p1 > p2;
FIDown= FIDown1 < FIDown2 AND p1 > p2;

sigRSIDown = f AND NOT Ref(f, -1) AND trendMom < Ref(trendMom, -1);
sigStock = fStoch AND NOT Ref(fStoch, -1) AND trendStoch < Ref(trendStoch, -1);
sigbbDown = fbb AND NOT Ref(fbb, -1) AND bb < Ref(bb, -1);
HistSigDown = HistDown AND NOT Ref(HistDown , -1) AND Hist< Ref(Hist, -1);
FISigDown = FIDown AND NOT Ref(FIDown, -1) AND FI< Ref(FI, -1);

//_N(str = "(" + period + ")");
Plot(sigRSIDown* 100, "rsiSigDown", colorRed, styleHistogram + styleThick + styleNoLabel);
Plot(sigStock* 100, "StockSigDown", colorRed, styleHistogram + styleThick + styleNoLabel);
Plot(sigbbDown* 100, "bbDown", colorRed, styleHistogram + styleThick + styleNoLabel);
Plot(HistSigDown * 100, "MAcdDown", colorRed, styleHistogram + styleThick + styleNoLabel);
Plot(FISigDown* 100, "FIDown", colorRed, styleHistogram + styleThick + styleNoLabel);


divergenceCount+=IIf(sigRSI,1,0) + IIf(FISigUP,1,0)+
IIf(sigStockUp ,1,0)+ IIf(sigbbUp ,1,0)+ IIf(HistSigUp ,1,0);

divergenceCount+=IIf(sigRSIDown ,1,0) + IIf(sigStock ,1,0)+
IIf(sigbbDown ,1,0)+ IIf(HistSigDown ,1,0)+ IIf(FISigDown,1,0);



BuyCondTmp=sigRSI OR sigStockUp OR sigbbUp OR HistSigUp OR FISigUP;
ShortCondTmp=sigRSIDown OR sigStock OR sigbbDown OR HistSigDown OR FISigDown;
highCount+=IIf(BuyCondTmp OR ShortCondTmp,numChg,0.0);

BuyCond = BuyCond OR BuyCondTmp ;
BuyCond=BuyCond AND (highCount>10);
ShortCond= ShortCond OR ShortCondTmp;
ShortCond=ShortCond AND (highCount>10);



globalTitile+=WriteIf(BuyCondTmp OR ShortCondTmp ,""+i,"")+

WriteIf(sigRSI,"rsiup ","")+WriteIf(sigStockUp,"stochup ","")+WriteIf(sigbbUp,"bbup ","")
+WriteIf(HistSigUP ,"macdup ","")+ WriteIf(FISigUP,"FIUP ","")



+WriteIf(sigRSIDown ,"rsiDown ","")+WriteIf(sigStock ,"stochDown ","")+WriteIf(sigbbDown,"bbDown ","")
+WriteIf(HistSigDown ,"macdDown ","")+ WriteIf(FISigDown,"FIDown ","")
+ WriteIf(BuyCondTmp OR ShortCondTmp ,"\n","");






} //for

Title=globalTitile;



FirstTradeTime = 091500; // Earliest time to take a trade
LastTradeTime = 151500; // Latest time to take new trades
ExitAllPositionsTime = 151500;
//change = Param("% change",0.1,0.1,25,0.1);
z = Zig(Close, 0.8 );

Buy=(BuyCond ) ;//AND (TimeNum() >= FirstTradeTime AND TimeNum() <= LastTradeTime );
Sell = IIf(z < Ref(z, -1), 1, 0) ;// OR TimeNum() > ExitAllPositionsTime;
Short=(ShortCond ) ;//AND (TimeNum() >= FirstTradeTime AND TimeNum() <= LastTradeTime );
Cover = IIf(z > Ref(z, -1), 1, 0) ;//OR TimeNum() > ExitAllPositionsTime;

Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);
Short=ExRem(Short,Cover);
Cover=ExRem(Cover,Short);


Filter=BuyCond OR ShortCond;
//Filter=Filter AND (TimeNum()>091500 AND TimeNum()<100000);


AddColumn(BuyCond,"DiverBuy");
AddColumn(ShortCond,"DiverSell");
AddColumn(divergenceCount,"no of diver");
AddColumn(highCount,"high");
//AddTextColumn(globalTitile,"indicators");
//AddColumn(StrLen(globalTitile),"StrLen",1);
Reply With Quote
  #13  
Old 8th November 2015, 12:03 PM
monkeybusiness's Avatar
Member
 
Join Date: May 2015
Posts: 679
Thanks: 7,355
Thanked 1,376 Times in 532 Posts
monkeybusiness has much to be proud ofmonkeybusiness has much to be proud ofmonkeybusiness has much to be proud ofmonkeybusiness has much to be proud ofmonkeybusiness has much to be proud ofmonkeybusiness has much to be proud ofmonkeybusiness has much to be proud ofmonkeybusiness has much to be proud ofmonkeybusiness has much to be proud ofmonkeybusiness has much to be proud of
Default Re: k-nearest neighbors algorithm

Quote:
Originally Posted by amibrokerfans View Post
sorry for late reply..










below chart i posted 27th july 4.00 p.m



and here is recent scenario..


Hi AMibrokerfans,

I have downloaded file from 4shared, but the image posted by you looks very different from the charts I am getting, can you please explain settings of this indicator.

Regards.

Reply With Quote
Reply

Bookmarks


Advertise Here

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads for: k-nearest neighbors algorithm
Thread Thread Starter Forum Replies Last Post
Algorithm. Here an other way how they are used in today's world. DanPickUp General Chit Chat 22 6th September 2013 05:49 PM
Neural Network & Genetic Algorithm based Analysis karthiksv84 Technical Analysis 1 4th January 2008 11:59 AM


All times are GMT +5.5. The time now is 07:59 PM.

Indemnity, Disclaimer & Disclosure Notice:
* By visiting Traderji.com you automatically indicate that you agree to our Forum Rules, Indemnity, Disclaimer & Disclosure Notice and General Content Disclaimer Notice and indemnify Traderji.com, its associates and related parties of all claims howsoever resulting from the usage of the forum/site.
* Disclaimer: Trading or investing in stocks & commodities is a high risk activity. Any action you choose to take in the markets is totally your own responsibility. You are recommended to make appropriate enquiries and seek appropriate advise before sending money, incurring any expenses, acting on recommendations or entering into any commitment in relation to any advertisement published here. Traderji.com does not vouch for any claims made by the advertisers of products and services. Traderji.com will not be held liable for any consequences in the event such claims are not honoured by the advertisers. Traderji.com will not be liable for any, direct or indirect, consequential or incidental damages or loss arising out of the use of any information by anybody mentioned anywhere on this site.
* Disclosure: The information in this forum is neither an offer to sell nor solicitation to buy any of the securities mentioned herein. The writers may or may not be trading in the securities mentioned.
* All names or products mentioned are trademarks or registered trademarks of their respective owners.
General Content Disclaimer Notice:
In light of our policy of encouraging candid, open exchanges of views and the rapid distribution of information originating from many sources, Traderji.com cannot determine the accuracy or legality of any information that may be uploaded to the forum. Opinions, advice and all other information expressed by participants in discussions are those of the author. You rely on such information at your own risk. You are urged to seek professional advice for specific, individual situations and not rely solely on advice or opinions given in the discussions. Since Traderji.com is an open and free discussion forum, any comments made by members of this forum in their posts reflect their own views and not of the owner or administrator of Traderji.com. Thus the owner/administrator indemnify themselves of all claims whatsoever and will not be liable or responsible for any members comments/views in this forum Traderji.com. Although we constantly delete all irrelevant content and/or SPAM, if you should find any objectionable or offensive posts made by members of this forum which you would like to bring to our notice for removal then please Contact Us.
 


Our Partner Websites: www.chittorgarh.com, IPO Investment Portal | www.topsharebrokers.com, Broker Comparision
Copyright © www.Traderji.com 2001 - , All rights reserved.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271