Gamestudio Links
Zorro Links
Newest Posts
folder management functions
by 7th_zorro. 04/16/24 13:19
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
LPDIRECT3DCUBETEXTUR
E9

by Ayumi. 04/12/24 11:00
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 04/11/24 14:56
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (7th_zorro), 442 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
11honza11, ccorrea, sakolin, rajesh7827, juergen_wue
19045 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
How to count #471048
02/17/18 10:15
02/17/18 10:15
Joined: Dec 2017
Posts: 42
Mongolia
T
Tuguldur717 Offline OP
Newbie
Tuguldur717  Offline OP
Newbie
T

Joined: Dec 2017
Posts: 42
Mongolia
how to count how many price candles cross over line of moving average of price in a given time interval?

Re: How to count [Re: Tuguldur717] #471052
02/17/18 13:55
02/17/18 13:55
Joined: Dec 2017
Posts: 42
Mongolia
T
Tuguldur717 Offline OP
Newbie
Tuguldur717  Offline OP
Newbie
T

Joined: Dec 2017
Posts: 42
Mongolia
Is there anybody to help me?

Re: How to count [Re: Tuguldur717] #471059
02/17/18 19:15
02/17/18 19:15
Joined: Aug 2017
Posts: 102
Spain
B
Brax Offline
Member
Brax  Offline
Member
B

Joined: Aug 2017
Posts: 102
Spain
In a very simplified way:

Code:
static var crossed = 0;

function run()
{
  BarPeriod = 24*60;
  asset("EURUSD");
  vars price = series(priceClose());
  vars ema = series(EMA(price,10));

  if(crossOver(price, ema) || crossUnder(price,ema))
    crossed = 0;
  else
    crossed++;
}



Hope it helps.

Last edited by brax; 02/17/18 19:20.
Re: How to count [Re: Brax] #471084
02/19/18 02:45
02/19/18 02:45
Joined: Dec 2017
Posts: 42
Mongolia
T
Tuguldur717 Offline OP
Newbie
Tuguldur717  Offline OP
Newbie
T

Joined: Dec 2017
Posts: 42
Mongolia
Thank you bro. I will test it.

Re: How to count [Re: Tuguldur717] #471131
02/20/18 11:44
02/20/18 11:44
Joined: Aug 2017
Posts: 102
Spain
B
Brax Offline
Member
Brax  Offline
Member
B

Joined: Aug 2017
Posts: 102
Spain
Hello.

Reviewing your question i've noticed you probably really wanted to do this:

Code:
function run()
{
    StartDate = 20150601;
    EndDate = 20151201;
    BarPeriod = 24*60;
    asset("EUR/USD");
    
    vars price = series(priceClose());
    vars ema = series(EMA(price,10));
    vars crosses = series(0);
    
    int i;
    var period = 5;
    var crossed = 0;

	for(i=0; i<period; i++)
		if(crossOver(price+i, ema+i) || crossUnder(price+i,ema+i))
                     crosses[0] = ++crossed

    PlotWidth = 1024;
    PlotHeight1 = 400;
    plot("EMA",ema,MAIN,PURPLE);
    plot("Crossed",crossed,NEW,RED);
    plot("Crosses",crosses,NEW,BLUE);
}



This is a rolling counting of crosses with a moving average. The "crosses" series is not necessary, but in case you want to further evaluate the results, this way you'll have a mechanism to do it, instead of just incrementing a variable.

Take a look to the series instruction, you'll learn a lot:
http://www.zorro-trader.com/manual/en/series.htm

If this is not what you wanted, then i hope it helps you with further developments.

Bye.

Re: How to count [Re: Brax] #471134
02/20/18 12:08
02/20/18 12:08
Joined: Dec 2017
Posts: 42
Mongolia
T
Tuguldur717 Offline OP
Newbie
Tuguldur717  Offline OP
Newbie
T

Joined: Dec 2017
Posts: 42
Mongolia
Thank very much you are the one who response in 220 people. You made truthful response. I am proud of you bro. Just now i am testing your code...


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1