Thank you both.
Probably with a practical example we can understand each other better.

Let's say that I want to build a strategy based on 4Hours bars (Barperiod = 240), that enters a Long Trade whenever the price breaks the highest point of the last 30 bars, from below.
What I would write is this:


Code:
#include <profile.c>


function run(){

StartDate = 2018;
EndDate = 2018;
LookBack = 30;
BarPeriod = 240;
asset("EUR/USD");

var enterPrice = HH(30, 1);
EntryTime = 100;

TakeProfit=70*PIP;
Stop=50*PIP;

	if (enterPrice != Entry){    //whenever a new price is found
		printf("n%d-%d-%d |%d| %d:%d:%.0f", day(), month(), year(), dow(), hour(), minute(), second() );
		printf(" - Enter at %.5f", enterPrice);
		Entry = enterPrice;
		enterLong();
	}

}



What am I doing wrong?
Is this kind of scripting correct for Zorro?

Plus, what if I want to make sure only 1 trade at a time is open?
Usually I put the enterLong() line between an if like this:

Code:
if(NumOpenTotal<1){
	enterLong()
}



But here it doesn't seem to work.

Thanks again so much.

Last edited by kerplunk1899; 01/09/19 21:39.