Posts: 1
Please rate this topic Current rating: 3.0 Votes: 1
RSS
djessi
FREE Member
Offline
  • From: Germany
  • Registered: 03-14-19
  • Posts: 1
  • Gender: male
  • Age: 19
  • Email

counting bars if condition

I need some help to program an indicator based on standard indicators: I would like to count numbers of bars, if a specific indicator setting is given, eg. two moving averages are pointing in the same direction. From the first crossing I would like to count the numbers of bars since this crossing. I tried with while and for loops, but I didn't get the right result. To make it clear: the first bar after crossing should get a "1", if condition is still active 2nd bar should get a "2" value. In case of crossing the other direction, it should start with "1" again.

it looks like:

i=0;

while (MA1>MA2[i])

counter[i]=counter[i-1]+1;

counter--;

What i am doing wrong?

Thank you in advance[/i][/i]

MT4talk on Facebook
>> Join Group

>> Join Page
Online Users & Stats
  • Total number of registered users: 44,938
  • Newest registered user: Pablor98
  • Total number of topics: 11,634
  • Total number of posts: 38,064

Online users: 4,915 guests, 182 Members:

A27an, a41006688, aaaa, abedjaber1971, Abhialka, Ac Williams, Adamblacky, admin, Agostino Visentini, Ahmad.Q, Ahmed Abdiaziz Mohamed Japanes, Ahmed Salim, AKALLAI86, akinssun, alapia, Alberto Pierobon, Alex Baumgärtner, amigoyoucef7, andraiva, andretombini, antovic, antropos, arappuleeswaran, ariadjogja, Arif365, AZZARRO13, b.filipov, badmanix, betuboxem, bijeljina1956, broke2, brolyssj, Bruno Oliveira, bukhalaf, bukohsk, BUNDER, calvinseanego, candyboy_tushar, carl132, Carlixton, Chánh Phan, Cindy Cãmƥbëƪƪ, cjhenning777, Cocojambo, Cretu Vasile, davbene74, Denis Maxime, Denise Konrad, EAInspirer, ebi50, elishaab, Etsenn, fabiobottoifx, Felixpukiat, fire, flsekme, forex.bvt, forexnfx, Francis Yip, fredd, Gabino, gilfx, Hafiz Mohd, HEMILCO, Herberth Zandomenico, hincer, IGWE, Inokko, Isaac Luciaka, ismaelfiure, jaffarmsh, jaysonajax, Jemz Dorris, Jlccorp, john.solgaard, joindonald, jurv2186, kantod, karnadi, Kemal, krauser010, Kris Cyngiel Ceglarz, Kyosuke Tagawa, lawrencetownsendnz, lee, lmsomni, louis, m.p.s., madoqa, magnosud, mahmoud.abuammuna, mania, MarianNick123, martinfousek67, martinsalva, Mateusz726, mdjindian, metaldgo, Minsoo Seok, mj-business, Mogbolu Simeon, moh55, mt4fx122, MT5, nakatama1, nienhuis2214, nousername, nuno1234, obaydullahsabbir, olegsbajuks, omtei, orchen, oscarudp, otari, Pablor98, padil1988, paksi1972, paolocroci69, pasroc, Paul328, Pavels Gerinovics, pero1994, phoenix-00, podroznik1809, Prashant Davanageri, propa, Pumpumarn, Quan Hoang Nguyen, quintana, Randall, Raymond#7372, Ricard Blas Claro, Richard Chiang, Richierich23, Rigonzalez9, sakhkalyan, sakollip68, Sankiraibi, Saptara Amorn, sarahw, serdg124, shigeichi, Siduduzo Shezi, soltern, Spegas Santun Berseri, stephenokereke, T116, Taufiq Hidayat, thirxx84, ThreeLions, timpte, tobi_ffm, topaz790, totus, tradingralf, tsirouflis, tskabilan, tuisk909, vadvid, vduubus, Vicran, Victoriano, vindiou, Vink92, vrmech, vufx1972, walidshahbudin, Walker Silva, Wei Deng, willfr, Wish Sh, yahavuzan, yama, yingtidarat, Ylts, zedeai, zionbc, Zoltan0013, zooba, zzzpoin, Василь Новосельский, דרור וסרמן

NOTE: Hacked or illegal versions of copyrighted Forex robots are highly prohibited on MT4talk.com. If you upload any illegal version of any copyrighted Forex robot, your forum account will be banned. No exceptions.

MT4talk is a User Generated Content website. All content uploaded to MT4talk by our users (MT4talk forum members) is User Generated Content. 


To use the MT4talk forum, you must agree to these terms! - MT4talk.com is a self-service Forex forum! You can only download open source Forex robots that other forum members are uploading! All Forex robots that tested by the MT4talk EA tester team, is it's a back-test on a real Forex account. The MT4talk EA tester team making the back-test on this website is to give you a starting point, however, you should always make your own test. All tests provided on this forum are provided for education purposes! MT4talk does not provide guarantee or support for the Forex robots listed on the forum!


CFTC RULE 4.41 – HYPOTHETICAL OR SIMULATED PERFORMANCE RESULTS HAVE CERTAIN LIMITATIONS. UNLIKE AN ACTUAL PERFORMANCE RECORD, SIMULATED RESULTS DO NOT REPRESENT ACTUAL TRADING. ALSO, SINCE THE TRADES HAVE NOT BEEN EXECUTED, THE RESULTS MAY HAVE UNDER-OR-OVER COMPENSATED FOR THE IMPACT, IF ANY, OF CERTAIN MARKET FACTORS, SUCH AS LACK OF LIQUIDITY. SIMULATED TRADING PROGRAMS, IN GENERAL, ARE ALSO SUBJECT TO THE FACT THAT THEY ARE DESIGNED WITH THE BENEFIT OF HINDSIGHT. NO REPRESENTATION IS BEING MADE THAT ANY ACCOUNT WILL OR IS LIKELY TO ACHIEVE PROFIT OR LOSSES SIMILAR TO THOSE SHOWN.

Disclaimer - No representation is being made that any Forex account will or is likely to achieve profits or losses similar to those shown on backtests in this forum. In fact, there are frequently sharp differences between hypothetical performance results and the actual results subsequently achieved by any particular trading program. Hypothetical trading does not involve financial risk, and no hypothetical trading record can completely account for the impact of financial risk in actual trading. All information on this forum is for educational purposes only and is not intended to provide financial advice. Any statements posted by forum members about profits or income expressed or implied, do not represent a guarantee. Your actual trading may result in losses as no trading system is guaranteed. You accept full responsibilities for your actions, trades, profit or loss, and agree to hold the MT4talk team and forum members of this information harmless in any and all ways.

Copyright MT4talk.com Forum Rules - Privacy Policy.