Page 1 of 1

Refer the close of a specific bar?

Posted: Nov 01 2011
by grt260
Hi all,

I want to know whether EL have a function that can find the close of a specific bar? for example, i want to refer the close of the bar at 10:00am , and if the close now > the close of 10:00am bar, then buy.

it is just a simple condition using time as a condition, i want even more complex condition that can mark the close of the specific bar, How can i mark it and recall it?

Thanks again!

Re: Refer the close of a specific bar?

Posted: Nov 01 2011
by furytrader
I imagine it would be something like this:

Code: Select all

vars: SpecialClose(0);

If Time = 1000 Then SpecialClose = Close;
If Time > 1000 and C > SpecialClose Then [Insert Trade Logic Here];

Re: Refer the close of a specific bar?

Posted: Nov 01 2011
by TJ
Hi all,

I want to know whether EL have a function that can find the close of a specific bar? for example, i want to refer the close of the bar at 10:00am , and if the close now > the close of 10:00am bar, then buy.

it is just a simple condition using time as a condition, i want even more complex condition that can mark the close of the specific bar, How can i mark it and recall it?

Thanks again!
There are a few background questions you must decide before delving into coding:

1. what is the instrument and chart resolution?

2. is this a recurring time that you need? eg. you want the close price of 10:00am everyday?

or,

3. the time might be variable? say, the time now might be 3pm or it might be 2pm, and you want to know the close at 11:00am or 10:30am?

4. do you need to know the time from previous days? eg. comparing 10am volume with 10am price of yesterday.


Each of the scenario might require a different coding method.

Re: Refer the close of a specific bar?

Posted: Nov 01 2011
by grt260
I imagine it would be something like this:

Code: Select all

vars: SpecialClose(0);

If Time = 1000 Then SpecialClose = Close;
If Time > 1000 and C > SpecialClose Then [Insert Trade Logic Here];
Thanks, it is easy to use time as a condition, but how about i use ES>=+5 (data2, change compare to yesterday close), and mark the bar of close in data1?
vars: var0(0),specialclose(0);
if time=0415 then close of data2=var0;
if close of data2 - var0>=5 then specialclose=close of data1

however, in the above scripts, the specialclose will change and cannot fixed to the first bar that ES>=+5.

How to mark and fix in the first bar that ES>=+5 of close of data1?
thanks.

Re: Refer the close of a specific bar?

Posted: Nov 01 2011
by Henry MultiŠ”harts
The symbol name cannot be compared with such values as time or price.
You need to compare the symbol name with the symbol name, price with price...
You can assign the first close of calculation to the SpecialClose by writing in your script:

Code: Select all

once SpecialClose = close;

Re: Refer the close of a specific bar?

Posted: Nov 01 2011
by grt260
The symbol name cannot be compared with such values as time or price.
You need to compare the symbol name with the symbol name, price with price...
You can assign the first close of calculation to the SpecialClose by writing in your script:

Code: Select all

once SpecialClose = close;
Thanks,
in order to make it clear what's my aim,
here is the indicator i created, and it is successfully mark the close,

Code: Select all

variables: var0(0),var1(0),var2(0);
if time =0415 then var0=close of data2 else var0=var0[1];

if close of data2-var0 >= 5 then

var2=close of data1;

else var2=0;

if close[1]of data2-var0 >=5 then var2=var2[1];

plot1(var2);
However it is not working if i change it to Signal....

Code: Select all

variables: var0(0),var1(0),var2(0);

if time=0415 then var0=close of data2 else var0=var0[1];

if close of data2-var0>=5 then

var2=close of data1

else var2=0;

if close[1]of data2-var0 >=5 then var2=var2[1];

if var2<>0 then
buy next bar at market;
Why is that happen? is there any way i can simplify the script by using "Once"?

Re: Refer the close of a specific bar?

Posted: Nov 02 2011
by Henry MultiŠ”harts
Please describe what do you mean by "it is not working ".
If you want the signal calculation to match to the indicator calculation-you need to enable Intra bar order generation for the signal.