First SwingHigh and first SwingLow in intraday chart

Questions about MultiCharts and user contributed studies.
monexx
Posts: 87
Joined: 20 Feb 2014
Has thanked: 26 times
Been thanked: 7 times

First SwingHigh and first SwingLow in intraday chart

Postby monexx » 09 May 2014

Hello,
Could anyone help me please?

I have the simple code swing reversals:

[IntrabarOrderGeneration=false]
variables:
support(0),
resistance(0);

if SwingHigh(1,high,1,2)<>-1 then resistance=SwingHigh(1,high,1,2);
if SwingLow(1,low,1,2)<>-1 then support=SwingLow(1,low,1,2);

if high < resistance then buy next bar at resistance stop;
if low > support then sellshort next bar at support stop;

if marketposition<>0 then begin
if Time>=2300 then buytocover next bar at market;
if Time>=2300 then sell next bar at market;
end;



How to create support and resistance using only the first swinghigh of session
and the first swinglow of session

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

Re: First SwingHigh and first SwingLow in intraday chart

Postby TJ » 09 May 2014

Hello,
Could anyone help me please?
I have the simple code swing reversals:
[IntrabarOrderGeneration=false]
variables:
support(0),
resistance(0);
if SwingHigh(1,high,1,2)<>-1 then resistance=SwingHigh(1,high,1,2);
if SwingLow(1,low,1,2)<>-1 then support=SwingLow(1,low,1,2);
if high < resistance then buy next bar at resistance stop;
if low > support then sellshort next bar at support stop;
if marketposition<>0 then begin
if Time>=2300 then buytocover next bar at market;
if Time>=2300 then sell next bar at market;
end;
How to create support and resistance using only the first swinghigh of session
and the first swinglow of session
You will need to give more detail on your idea... on the surface, it can be interpreted as something simple, or something complicated.

Can you draw a chart to illustrate what you want to do?

it could be as simple as adding a counter...

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

Re: First SwingHigh and first SwingLow in intraday chart

Postby TJ » 09 May 2014

ps.
[FAQ] How to Post Codes (that people can read)
viewtopic.php?f=16&t=11713

monexx
Posts: 87
Joined: 20 Feb 2014
Has thanked: 26 times
Been thanked: 7 times

Re: First SwingHigh and first SwingLow in intraday chart

Postby monexx » 10 May 2014

Hello,
Could anyone help me please?
I have the simple code swing reversals:
[IntrabarOrderGeneration=false]
variables:
support(0),
resistance(0);
if SwingHigh(1,high,1,2)<>-1 then resistance=SwingHigh(1,high,1,2);
if SwingLow(1,low,1,2)<>-1 then support=SwingLow(1,low,1,2);
if high < resistance then buy next bar at resistance stop;
if low > support then sellshort next bar at support stop;
if marketposition<>0 then begin
if Time>=2300 then buytocover next bar at market;
if Time>=2300 then sell next bar at market;
end;
How to create support and resistance using only the first swinghigh of session
and the first swinglow of session
You will need to give more detail on your idea... on the surface, it can be interpreted as something simple, or something complicated.

Can you draw a chart to illustrate what you want to do?

it could be as simple as adding a counter...



Hello,

explanation thoughts:

After the open session is created first swinghigh=resistance and first swinglow=support.
This resistance and support will remain stored until the end of the session.
If the high of a bar is under resistance then buy next bar at resistance stop.
If the low of a bar is over support then sellshort next bar at support stop.
At the end of session will support and resistance canceled.
After open a new session is created new first swinghigh=resistance and new first swinglow=support
...and so on...

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

Re: First SwingHigh and first SwingLow in intraday chart

Postby TJ » 10 May 2014

Hello,

explanation thoughts:

After the open session is created first swinghigh=resistance and first swinglow=support.
This resistance and support will remain stored until the end of the session.
If the high of a bar is under resistance then buy next bar at resistance stop.
If the low of a bar is over support then sellshort next bar at support stop.
At the end of session will support and resistance canceled.
After open a new session is created new first swinghigh=resistance and new first swinglow=support
...and so on...
What you need is to "freeze" the value of the first resistance and support.

eg.

Code: Select all

var:
First.SwingHigh(false),
First.SwingLow(false);

If Date <> Date[1] then
begin
First.SwingHigh = false;
First.SwingLow = false;
end;

If First.SwingHigh = false then
begin
if SwingHigh(1,high,1,2)<>-1 then resistance=SwingHigh(1,high,1,2);
First.SwingHigh = True;
end;

// do the same for SwingLow

monexx
Posts: 87
Joined: 20 Feb 2014
Has thanked: 26 times
Been thanked: 7 times

Re: First SwingHigh and first SwingLow in intraday chart

Postby monexx » 10 May 2014

Hello,

explanation thoughts:

After the open session is created first swinghigh=resistance and first swinglow=support.
This resistance and support will remain stored until the end of the session.
If the high of a bar is under resistance then buy next bar at resistance stop.
If the low of a bar is over support then sellshort next bar at support stop.
At the end of session will support and resistance canceled.
After open a new session is created new first swinghigh=resistance and new first swinglow=support
...and so on...
What you need is to "freeze" the value of the first resistance and support.

eg.

Code: Select all

var:
First.SwingHigh(false),
First.SwingLow(false);

If Date <> Date[1] then
begin
First.SwingHigh = false;
First.SwingLow = false;
end;

If First.SwingHigh = false then
begin
if SwingHigh(1,high,1,2)<>-1 then resistance=SwingHigh(1,high,1,2);
First.SwingHigh = True;
end;

// do the same for SwingLow





Thank you very much for your help.

I added the code but does not yet work as expected logic.

I do not know where I made ​​a mistake.
Try it on euro fx 1 hourly chart.

Code: Select all

[IntrabarOrderGeneration=false]
var:
First.SwingHigh(false),
First.SwingLow(false),
resistance(0),
support(0);


If Date <> Date[1] then
begin
First.SwingHigh = false;
First.SwingLow = false;
end;

If First.SwingHigh = false then
begin
if SwingHigh(1,high,1,2)<>-1 then resistance=SwingHigh(1,high,1,2);
First.SwingHigh = True;
end;

If First.SwingLow = false then
begin
if SwingLow(1,low,1,2)<>-1 then support=SwingLow(1,low,1,2);
First.SwingLow = True;
end;


if high < resistance then buy next bar at resistance stop;
if low > support then sellshort next bar at support stop;

if marketposition<>0 and Time >= 2300 then begin
buytocover next bar at market;
sell next bar at market;
end;

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

Re: First SwingHigh and first SwingLow in intraday chart

Postby TJ » 10 May 2014

Thank you very much for your help.

I added the code but does not yet work as expected logic.

I do not know where I made ​​a mistake.
Try it on euro fx 1 hourly chart.

Code: Select all

[IntrabarOrderGeneration=false]
var:
First.SwingHigh(false),
First.SwingLow(false),
resistance(0),
support(0);


If Date <> Date[1] then
begin
First.SwingHigh = false;
First.SwingLow = false;
end;

If First.SwingHigh = false then
begin
if SwingHigh(1,high,1,2)<>-1 then resistance=SwingHigh(1,high,1,2);
First.SwingHigh = True;
end;

If First.SwingLow = false then
begin
if SwingLow(1,low,1,2)<>-1 then support=SwingLow(1,low,1,2);
First.SwingLow = True;
end;


if high < resistance then buy next bar at resistance stop;
if low > support then sellshort next bar at support stop;

if marketposition<>0 and Time >= 2300 then begin
buytocover next bar at market;
sell next bar at market;
end;
Hahah...

Hint:
you can only trade **IF** and only if a swing high/low has occurred.

Tips:
Instead of jumping into a strategy, you can start with an indicator... plot a dot at where you want to BUY or SELL... and see how things pan out.

monexx
Posts: 87
Joined: 20 Feb 2014
Has thanked: 26 times
Been thanked: 7 times

Re: First SwingHigh and first SwingLow in intraday chart

Postby monexx » 12 May 2014

Thank you very much for your help.

I added the code but does not yet work as expected logic.

I do not know where I made ​​a mistake.
Try it on euro fx 1 hourly chart.

Code: Select all

[IntrabarOrderGeneration=false]
var:
First.SwingHigh(false),
First.SwingLow(false),
resistance(0),
support(0);


If Date <> Date[1] then
begin
First.SwingHigh = false;
First.SwingLow = false;
end;

If First.SwingHigh = false then
begin
if SwingHigh(1,high,1,2)<>-1 then resistance=SwingHigh(1,high,1,2);
First.SwingHigh = True;
end;

If First.SwingLow = false then
begin
if SwingLow(1,low,1,2)<>-1 then support=SwingLow(1,low,1,2);
First.SwingLow = True;
end;


if high < resistance then buy next bar at resistance stop;
if low > support then sellshort next bar at support stop;

if marketposition<>0 and Time >= 2300 then begin
buytocover next bar at market;
sell next bar at market;
end;
Hahah...

Hint:
you can only trade **IF** and only if a swing high/low has occurred.

Tips:
Instead of jumping into a strategy, you can start with an indicator... plot a dot at where you want to BUY or SELL... and see how things pan out.

I think now it is working properly.
According to you is the correct logic or I forgot something?

Code: Select all

[IntrabarOrderGeneration=false]
var:
resistance(-1),
support(-1);


If Date <> Date[1] then
begin
resistance=-1;
support=-1;
end;

If resistance=-1 then
begin
if SwingHigh(1,high,1,2)<>-1 then resistance=SwingHigh(1,high,1,2);

end;

If support=-1 then
begin
if SwingLow(1,low,1,2)<>-1 then support=SwingLow(1,low,1,2);

end;

if high<resistance then buy next bar at resistance stop;
if low>support then sellshort next bar at support stop;

if marketposition<>0 and Time>=2300 then begin

buytocover next bar at market;
sell next bar at market;
end;

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

Re: First SwingHigh and first SwingLow in intraday chart

Postby TJ » 12 May 2014

::
I think now it is working properly.
According to you is the correct logic or I forgot something?
::

Code: Select all

::
if low>support then sellshort next bar at support stop;
::
Note: Low is always larger than -1.

Take another read of my tips above.

monexx
Posts: 87
Joined: 20 Feb 2014
Has thanked: 26 times
Been thanked: 7 times

Re: First SwingHigh and first SwingLow in intraday chart

Postby monexx » 12 May 2014

::
I think now it is working properly.
According to you is the correct logic or I forgot something?
::

Code: Select all

::
if low>support then sellshort next bar at support stop;
::
Note: Low is always larger than -1.

Take another read of my tips above.
Is it right now? :-)

Code: Select all

[IntrabarOrderGeneration=false]
var:
First.SwingHigh(false),
First.SwingLow(false),
resistance(0),
support(0);


If Date <> Date[1] then
begin
First.SwingHigh = false;
First.SwingLow = false;
end;

If First.SwingHigh = false then
begin
if SwingHigh(1,high,1,2)<>-1 then resistance=SwingHigh(1,high,1,2);
if SwingHigh(1,high,1,2)=resistance then First.SwingHigh = True;
end;

If First.SwingLow = false then
begin
if SwingLow(1,low,1,2)<>-1 then support=SwingLow(1,low,1,2);
if SwingLow(1,low,1,2)=support then First.SwingLow = True;
end;


if First.SwingHigh=true and high<resistance then buy next bar at resistance stop;
if First.SwingLow=true and low>support then sellshort next bar at support stop;

if marketposition<>0 and Time >= 2300 then begin
buytocover next bar at market;
sell next bar at market;
end;

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

Re: First SwingHigh and first SwingLow in intraday chart

Postby TJ » 12 May 2014

Is it right now? :-)
::
Congratulations... You've got it. :-)

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

Re: First SwingHigh and first SwingLow in intraday chart

Postby TJ » 12 May 2014

Alternative coding:

Code: Select all


If First.SwingHigh = false
AND SwingHigh(1,high,1,2)<>-1
then begin
resistance=SwingHigh(1,high,1,2);
First.SwingHigh = True;
end;


Return to “MultiCharts”