Is it possible to define session start / end using code?

Questions about MultiCharts and user contributed studies.
arjfca
Posts: 1292
Joined: 23 Nov 2010
Has thanked: 725 times
Been thanked: 223 times

Is it possible to define session start / end using code?

Postby arjfca » 14 Oct 2012

Hello

I want to write some line of code to define pivot point for a given period Pivot point is calculated using High , Low, Close of a given period. Actually, my session is defined in the QuoteManager

Let say that I want to calculate a daily pivot points

What is a day:
- Start @ 0 GMT
- Start @ New-York Close
- Start @ New-York Open
- Start @ midnight

So my goal is to be able to set the start of a session from a input

Martin

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Is it possible to define session start / end using code?

Postby Henry MultiСharts » 05 Nov 2012

Hello Martin,

If you are referring to changing the instrument sessions from code then it is not possible.

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Is it possible to define session start / end using code?

Postby TJ » 07 Nov 2012

Hello

I want to write some line of code to define pivot point for a given period Pivot point is calculated using High , Low, Close of a given period. Actually, my session is defined in the QuoteManager

Let say that I want to calculate a daily pivot points

What is a day:
- Start @ 0 GMT
- Start @ New-York Close
- Start @ New-York Open
- Start @ midnight

So my goal is to be able to set the start of a session from a input

Martin
Your question is not very clear.

From the first part of your post,
I read that you are looking for an indicator that can calculate pivots with user definable start and stop time.
Presumably plotting various pivots on a 24 hr chart?

From the second part of your post,
you are looking to use codes to change a chart session.
Presumably switching chart sessions on the fly?

arjfca
Posts: 1292
Joined: 23 Nov 2010
Has thanked: 725 times
Been thanked: 223 times

Re: Is it possible to define session start / end using code?

Postby arjfca » 07 Nov 2012

Hello TJ

Indeed, I was not clear

My idea was to calculate pivot for different session starting time. My quest was to send a code to give a new session start time, but it is ilogic to do it

Thanks for the reply

Martin

escamillo
Posts: 203
Joined: 25 Mar 2011
Has thanked: 23 times
Been thanked: 56 times

Re: Is it possible to define session start / end using code?

Postby escamillo » 09 Nov 2012

Code: Select all

Attachments
MultiCharts1.png
(23.58 KiB) Downloaded 836 times
Last edited by escamillo on 17 Nov 2014, edited 1 time in total.

tk993
Posts: 6
Joined: 13 Aug 2013

Re: Is it possible to define session start / end using code?

Postby tk993 » 27 Aug 2013

Sorry to reopen an old thread, but I'm having the same issue, at least I think so. Here's the indicator that I found and modified slightly (though my modifications don't really have anything to do with the error (I dont' think)).

Code: Select all

// START EasyLanguage Code

{ ABC_Floor Trader Pivots V3
** Copyright (c) 2007 ABC TRADING GROUP All rights reserved. ** www.abctradinggroup.com
This study may be shared freely, as long as the copyright notice is included.}

Inputs:
StartCalcTime (0000),
EndCalcTime (2359),
PlaceTextRight (true),
PlotatDateChange (true),
PlotToDateEnd (true),
IgnoreWeekends (true),
TLSize (1),
TLStyle (1),
PivColor (yellow),
R1Color (red),
R2Color (red),
R3Color (red),
S1Color (green),
S2Color (green),
S3Color (green);

Variables:
Monday2Friday (false),
RR1 (0),
RR2 (0),
RR3 (0),
SS1 (0),
SS2 (0),
SS3 (0),
PP (0),
RR1TL (0),
RR2TL (0),
RR3TL (0),
SS1TL (0),
SS2TL (0),
SS3TL (0),
PPTL (0),
DayHi (-999999),
DayLo (+999999),
HaveTLs (false),
StartTime (0),
EndTime (0),
R1Txt (0),
R2Txt (0),
R3Txt (0),
S1Txt (0),
S2Txt (0),
S3Txt (0),
PPTxt (0),
SessClose (0),
TextStyleHoriz (1), //0: To the right of the bar specified for the text object
//1: To the left of the bar specified for the text object
//2: Centered on the bar specified for the text object
TextStyleVert (2); //0: Beneath the price specified for the text object
//1: Above the price specified for the text object
//2: Centered on the specified price location of the text object

If IgnoreWeekends then begin
If DayOfWeek(Date) >= Monday and DayOfWeek(Date) <= Friday then
Monday2Friday = true
else
Monday2Friday = false;

end
else begin
Monday2Friday = true;
end;


If Monday2Friday then begin

If Date <> Date[1] then begin
If PlaceTextRight then
TextStyleVert = 1;

If PlotatDateChange then
StartTime = Time
else
StartTime = StartCalcTime;

EndTime = Time[1];

PP = (DayHi + DayLo + SessClose[1])/3 ;
RR1 = PP * 2 - DayLo;
RR2 = PP + DayHi - DayLo;
RR3 = RR2 + DayHi - DayLo;
SS1 = PP * 2 - DayHi;
SS2 = PP - DayHi + DayLo;
SS3 = SS2 - DayHi + DayLo;

DayHi = -999999;
DayLo = +999999;
HaveTLs = false;

end; //If Date <> Date[1] then begin...

If Time > StartCalcTime and Time <= EndCalcTime then begin
If High >= DayHi then DayHi = High;
If Low <= DayLo then DayLo = Low;
If BarStatus(1) = 2 then
SessClose = Close;
end;//If Time > StartCalcTime and Time <= EndCalcTime then begin...

If HaveTLs = false then begin
HaveTLs = true;

RR1TL = TL_New(Date, StartTime, RR1, Date, EndTime, RR1);
TL_SetColor(RR1TL, R1Color);
TL_SetSize(RR1TL, TLSize);
TL_SetStyle(RR1TL, TLStyle);

RR2TL = TL_New(Date, StartTime, RR2, Date, EndTime, RR2);
TL_SetColor(RR2TL, R2Color);
TL_SetSize(RR2TL, TLSize);
TL_SetStyle(RR2TL, TLStyle);

RR3TL = TL_New(Date, StartTime, RR3, Date, EndTime, RR3);
TL_SetColor(RR3TL, R3Color);
TL_SetSize(RR3TL, TLSize);
TL_SetStyle(RR3TL, TLStyle);

SS1TL = TL_New(Date, StartTime, SS1, Date, EndTime, SS1);
TL_SetColor(SS1TL, S1Color);
TL_SetSize(SS1TL, TLSize);
TL_SetStyle(SS1TL, TLStyle);

SS2TL = TL_New(Date, StartTime, SS2, Date, EndTime, SS2);
TL_SetColor(SS2TL, S2Color);
TL_SetSize(SS2TL, TLSize);
TL_SetStyle(SS2TL, TLStyle);

SS3TL = TL_New(Date, StartTime, SS3, Date, EndTime, SS3);
TL_SetColor(SS3TL, S3Color);
TL_SetSize(SS3TL, TLSize);
TL_SetStyle(SS3TL, TLStyle);

PPTL = TL_New(Date, StartTime, PP, Date, EndTime, PP);
TL_SetColor(PPTL, PivColor);
TL_SetSize(PPTL, TLSize);
TL_SetStyle(PPTL, TLStyle);

R1Txt = Text_New(Date, StartTime, RR1, "R1");
Text_SetStyle(R1Txt, TextStyleHoriz, TextStyleVert);
Text_SetColor(R1Txt, R1Color);

R2Txt = Text_New(Date, StartTime, RR2, "R2");
Text_SetStyle(R2Txt, TextStyleHoriz, TextStyleVert);
Text_SetColor(R2Txt, R2Color);

R3Txt = Text_New(Date, StartTime, RR3, "R3");
Text_SetStyle(R3Txt, TextStyleHoriz, TextStyleVert);
Text_SetColor(R3Txt, R3Color);

S1Txt = Text_New(Date, StartTime, SS1, "S1");
Text_SetStyle(S1Txt, TextStyleHoriz, TextStyleVert);
Text_SetColor(S1Txt, S1Color);

S2Txt = Text_New(Date, StartTime, SS2, "S2");
Text_SetStyle(S2Txt, TextStyleHoriz, TextStyleVert);
Text_SetColor(S2Txt, S2Color);

S3Txt = Text_New(Date, StartTime, SS3, "S3");
Text_SetStyle(S3Txt, TextStyleHoriz, TextStyleVert);
Text_SetColor(S3Txt, S3Color);

PPTxt = Text_New(Date, StartTime, PP, "PP");
Text_SetStyle(PPTxt, TextStyleHoriz, TextStyleVert);
Text_SetColor(PPTxt, PivColor);
end //If HaveTLs = false then begin...
else begin
If PlotToDateEnd then
EndTime = EndTime
else
EndTime = EndCalcTime;

TL_SetEnd(RR1TL, Date, EndTime, RR1);
TL_SetEnd(RR2TL, Date, EndTime, RR2);
TL_SetEnd(RR3TL, Date, EndTime, RR3);
TL_SetEnd(SS1TL, Date, EndTime, SS1);
TL_SetEnd(SS2TL, Date, EndTime, SS2);
TL_SetEnd(SS3TL, Date, EndTime, SS3);
TL_SetEnd(PPTL, Date, EndTime, PP);

If PlaceTextRight then begin
Text_SetLocation(R1Txt, Date, EndTime, RR1);
Text_SetLocation(R2Txt, Date, EndTime, RR2);
Text_SetLocation(R3Txt, Date, EndTime, RR3);
Text_SetLocation(S1Txt, Date, EndTime, SS1);
Text_SetLocation(S2Txt, Date, EndTime, SS2);
Text_SetLocation(S3Txt, Date, EndTime, SS3);
Text_SetLocation(PPTxt, Date, EndTime, PP);
end; //If PlaceTextRight then begin...
end; //If HaveTLs then begin...

end; //If Monday2Friday then begin...
My problem with it is that it calculates based on midnight to midnight (basically). I want it to actually calculate from session open to session close. But when I put 1515 as the EndCalcTime and 1600 as the StartCalcTime it doesn't plot. (I'm central time, by the way).

User avatar
ABC
Posts: 718
Joined: 16 Dec 2006
Location: www.abctradinggroup.com
Has thanked: 125 times
Been thanked: 408 times
Contact:

Re: Is it possible to define session start / end using code?

Postby ABC » 28 Aug 2013

tk993,

you are right I designed the code to reset at midnight when I created the story. You'd need to change the code to reset at the beginning of your custom start time and block the resetting at midnight. You will also have to adapt the dates for the trendlines, so they can span over two days.

Regards,
ABC

tk993
Posts: 6
Joined: 13 Aug 2013

Re: Is it possible to define session start / end using code?

Postby tk993 » 28 Aug 2013

Hey, thanks for the reply, and thanks for the indicator. By the way, as an aside, I thought I had found two pivot points prior to making this thread, but it turns out they are basically the same.

Here's the site, it looks like they simply changed the order of the Inputs and got rid of the copy-write and added a few //comments. I'm not sure how IP works with multichart coding, but there was definitely some copying going on (either by you or them, I don't know don't care, just thought I'd let you know if you want to do anything about it). I believe you give it out for free, they want to charge for the ability to copy the code (I just typed it up to try to learn how it all works). Here's the link: http://www.daytrading-eminifutures.com/ ... omated.php

Anyways,

How would I got about that? In the other platform, I basically specify the period[day] and it calculates based on the day chart and applies it to the period I'm looking at (usually 5 minute charts).

Can I edit your code easily or is what I'm trying to do going to work best in a totally new code? I'm a complete beginner, basically from looking at your code and retyping their code and a few others, I've gotten the basic idea on how to code, but I don't know the variables (If that's what their called--the terms or however I would specify the time period or look at multiple days).


Return to “MultiCharts”