Coding Day Session in a Signal

Questions about MultiCharts and user contributed studies.
deobisnath
Posts: 40
Joined: 17 Jul 2007

Coding Day Session in a Signal

Postby deobisnath » 11 Aug 2007

Hi :
I want to insert the code to buy/sell between 9:35 am and 16:10, only, within the signal. This is what I have so far:


var: DaySession( false );

DaySession = (currenttime > 930) and (currenttime < 1605) ;

if DaySession and CurrentBar > 1 and Close crosses over UpperBand then
begin
.....code to buy
end


Compiles without any error, but there buys/sells, no position. If I remove he DaySession code, system buys and sells during regular and night session.

Where am I going wrong?

Thanks,

Deo

Guest

Postby Guest » 12 Aug 2007

I use:

time <= 0930

Works ok

Guest

Postby Guest » 20 Aug 2007

time instead of currentime should work better imho.

give it a try.

Pipscalper
Posts: 84
Joined: 28 Jul 2006
Been thanked: 3 times

Postby Pipscalper » 20 Aug 2007

Var: OK2Trade(False);

If Time >0930 and Time < 1605 then OK2Trade=True else OK2Trade= false;

Watch out; if you have an open position at 1605 you cannot close it afterwards , so you have to add extra code for the closing of the open position.
or,
You can also use OK2Enter and OK2Close instead of OK2Trade ,to avoid this closingproblem.

deobisnath
Posts: 40
Joined: 17 Jul 2007

Thanks - is there a % day function?

Postby deobisnath » 20 Aug 2007

Thanks for your help. I am considering a
% of day condition, e.g. open position only if 25% of day has passed.

is there a % day function in EL?

Deo

Pipscalper
Posts: 84
Joined: 28 Jul 2006
Been thanked: 3 times

Postby Pipscalper » 21 Aug 2007

To my knowledge there is not such a function.

make the following;
Input : StartTime(0930),EndTime (1605),CloseAllTime(1730);

Var: OK2OpenTrade(false);

If Time>StartTime and Time < EndTime then OK2OpenTrade=true else OK2OpenTrade = false;

If Time >=CloseAllTime and Marketposition=1 then Exitlong this bar at market;

If Time >=CloseAllTime and Marketposition=-1 then ExitShort this bar at market;

Your code will give entry and exit orders between Starttime and endtime, after endtime your code has to give only closing orders.
If at CloseAlltime an open position stillexists, it will be closed at market.

Good luck.


Return to “MultiCharts”