swingHigh/swingLow

Questions about MultiCharts and user contributed studies.
gian9081
Posts: 14
Joined: 08 Jan 2015
Has thanked: 1 time

swingHigh/swingLow

Postby gian9081 » 08 Jan 2015

Hello,
Could anyone help me please?

I'm trying to write a simple code that identifies the HighPoint and LowPoint, which must meet two conditions. When these points have been identified, I want to represent them in a way that there is an alternation between these points; that is, when it is represented a LowPoint, it must be followed by a HighPoint, without that there are other Low in the middle; and vice versa. And when i did it, i would to put the value in the Array.
I hope that someone can help me.
I attach the code.

Code: Select all

inputs: Price ( Low ), Price1 ( High ), RightStrenght ( 3 ) ;
vars: min1 ( 0 ), max1 ( 0 );
Array: EArray[2](0);

condition1 = Price[3]<Price[4] And Price[3]<Price[5] And Price[3]<Price[6] And Price[3]<Price[2] And Price[3]<Price[1] And Price[3]<Price;
condition2 = Price1[3]>Price1[4] And Price1[3]>Price1[5] And Price1[3]>Price1[6] And
Price1[3]>Price1[2] And Price1[3]>Price1[1] And Price1[3]>Price1;
if condition1 then
begin
min1 = Price[3];
EArray[1]=min1;
Plot1[RightStrenght]( EArray[1], "swing Low" );
print(EArray[1]);
end
else
min1=0;
EArray[1]=0;
NoPlot ( 1 );
if condition2 then
begin
max1 = Price1[3];
EArray[2]=max1;
Plot2[RightStrenght]( EArray[2], "swing High" );
print(EArray[2]);
end
else
max1=0;
EArray[2]=0;
min1 = 0;
NoPlot ( 1 );
NoPlot ( 2 );

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

Re: swingHigh/swingLow

Postby Henry MultiСharts » 09 Jan 2015

Hello gian9081,

Please specify the particular difficulty you have.

gian9081
Posts: 14
Joined: 08 Jan 2015
Has thanked: 1 time

Re: swingHigh/swingLow

Postby gian9081 » 09 Jan 2015

ok, sorry if i was not precise. I would like to represent in the graph of multicharts the "HighPoint" and the "LowPoint" alternating. When the graph identified a HighPoint the next point that will be represent must be a LowPoint, and not another HighPoint. So i can't understand how to represent in the graph in succession HighPoint followed by a LowPoint and so on.
I hope to be more clearer

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

Re: swingHigh/swingLow

Postby Henry MultiСharts » 12 Jan 2015

Hello gian9081,

I have added a variable to filter the plots per your condition. Please try the code:

Code: Select all

inputs: Price ( Low ), Price1 ( High ), RightStrenght ( 3 ) ;
vars: min1 ( 0 ), max1 ( 0 ), hold(0);
Array: EArray[2](0);

condition1 = Price[3]<Price[4] And Price[3]<Price[5] And Price[3]<Price[6] And Price[3]<Price[2] And Price[3]<Price[1] And Price[3]<Price;

condition2 = Price1[3]>Price1[4] And Price1[3]>Price1[5] And Price1[3]>Price1[6] And
Price1[3]>Price1[2] And Price1[3]>Price1[1] And Price1[3]>Price1;

condition3=hold=0 or hold=2;

condition4=hold=0 or hold=1;

if condition1 and condition3 then
begin
min1 = Price[3];
EArray[1]=min1;
Plot1[RightStrenght]( EArray[1], "swing Low" );
print(EArray[1]);
hold=1;
end
else
min1=0;
EArray[1]=0;
NoPlot ( 1 );
// hold=0;
if condition2 and condition4 then
begin
max1 = Price1[3];
EArray[2]=max1;
Plot2[RightStrenght]( EArray[2], "swing High" );
print(EArray[2]);
hold=2;
end
else
max1=0;
EArray[2]=0;
min1 = 0;
NoPlot ( 1 );
NoPlot ( 2 );
//hold=0;

gian9081
Posts: 14
Joined: 08 Jan 2015
Has thanked: 1 time

Re: swingHigh/swingLow

Postby gian9081 » 13 Jan 2015

The code works, thank you very much

gian9081
Posts: 14
Joined: 08 Jan 2015
Has thanked: 1 time

swinglow/swinghigh2

Postby gian9081 » 13 Jan 2015

Hello,
Could anyone help me please?

I'm trying to write this simple code. I would like to find 4 points, min1 max1 min2 max2 in this sequence. i can find the first two point, but i can't identify the other two. I would like that the min2 is higher than the min1 and that the max2 respect the condition that max2-min2>max1-min1. I don't understand how to put in the code that min2 and max2 are points next min1 and max1. So the sequence that i want to find is: min1, max1, min2, max2 and with the Plot represent in the graph.
I hope I was clear and that someone can help me

Code: Select all

inputs: Price ( Low ), Price1 ( High ), RightStrenght ( 3 ) ;
vars: min1 ( 0 ), max1 ( 0 ), min2 ( 0 ), max2 ( 0 ), hold(0);
Array: EArray[4](0);

condition1 = Price[3]<Price[4] And Price[3]<Price[5] And Price[3]<Price[6] And Price[3]<Price[2] And Price[3]<Price[1] And Price[3]<Price;

condition2 = Price1[3]>Price1[4] And Price1[3]>Price1[5] And Price1[3]>Price1[6] And
Price1[3]>Price1[2] And Price1[3]>Price1[1] And Price1[3]>Price1;

condition3=hold=0 or hold=4;

condition4=hold=0 or hold=3;

condition5=hold=0 or hold=2;

condition6=hold=0 or hold=1;


if condition1 and condition3 then
begin
min1 = Price[3];
EArray[1]=min1;
Plot1[RightStrenght]( EArray[1], "swing Low" );
print(EArray[1]);
hold=3;
end
else
min1=0;
EArray[1]=0;
NoPlot ( 1 );
// hold=0;
if condition2 and condition4 then
begin
max1 = Price1[3];
EArray[2]=max1;
Plot2[RightStrenght]( EArray[2], "swing High" );
print(EArray[2]);
hold=2;
end
else
max1=0;
EArray[2]=0;
min1 = 0;
NoPlot ( 1 );
NoPlot ( 2 );
//hold=0;

if condition1 and condition5 then
begin
min2 = Price[3];
if min2 > min1 then
begin
EArray[3]=min2;
Plot3[RightStrenght](EArray[3], "Swing Low2");
print(EArray[3]);
hold=1;
end
else
min2 = min1;
max1 = 0;
EArray[3]=0;
Plot1[RightStrenght]( EArray[1], "swing Low" );
//hold=0;
end;
if condition2 and condition6 then
begin
max2 = Price1[3];
if max2 - min2 > max1 - min1 then
begin
EArray[4]=max2;
Plot4[RightStrenght](EArray[4], "Swing High2");
print(EArray[4]);
hold=4;
end
else
max2 = max1;
EArray[4]=0;
Plot1[RightStrenght]( EArray[1], "swing Low" );
Plot2[RightStrenght]( EArray[2], "swing High" );
hold=2;

end


gian9081
Posts: 14
Joined: 08 Jan 2015
Has thanked: 1 time

Re: swingHigh/swingLow

Postby gian9081 » 14 Jan 2015

How can i put in the code that min2 is the next point that respect the condition1 then the min1 and max2 is the next point that respect the condition2 then the max2?

User avatar
Sky
Posts: 47
Joined: 05 Dec 2013
Has thanked: 19 times
Been thanked: 4 times

Re: swingHigh/swingLow

Postby Sky » 29 Mar 2015

Hi...I ran this code and cannot understand why it misses several obvious High Swing points and Low Swing points? I reviewed the code that Henry modified and this is the code I ran on 5m bars of ESZ4. See the attached pic to see the missing HIPs and LOPs.....am I missing something here? It looks like the code should have identified these points?

Image
Attachments
2015-03-29 15_18_23-MultiCharts64 - Untitled Desktop - ContSymTest-2_5m_PIGs-MTP - [ESZ4 - 5 Minutes_Swing HL w_Array_Test_2.jpeg
(163.03 KiB) Downloaded 1156 times

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

Re: swingHigh/swingLow

Postby TJ » 29 Mar 2015

Hi...I ran this code and cannot understand why it misses several obvious High Swing points and Low Swing points? I reviewed the code that Henry modified and this is the code I ran on 5m bars of ESZ4. See the attached pic to see the missing HIPs and LOPs.....am I missing something here? It looks like the code should have identified these points?
Can you identify the criteria that you think they have met to qualify as High/Low Swing points?

You can pick one circle as a test exercise,
and go through the conditions one by one?

User avatar
Sky
Posts: 47
Joined: 05 Dec 2013
Has thanked: 19 times
Been thanked: 4 times

Re: swingHigh/swingLow

Postby Sky » 30 Mar 2015

Hey there TJ...been a long time since my last visit, hope you are well. If I go to the top right ellipse (largest on the pic) and we go forward 3 bars from the HIP and that becomes price1 and follow the code for identifying a swing high, I think this point meets the condition? Am I missing something?

From Price1 bar, go back 3 bars to Price1[3] which is the HIP and I believe it meets the conditions?

Thanks.

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

Re: swingHigh/swingLow

Postby TJ » 30 Mar 2015

Hey there TJ...been a long time since my last visit, hope you are well. If I go to the top right ellipse (largest on the pic) and we go forward 3 bars from the HIP and that becomes price1 and follow the code for identifying a swing high, I think this point meets the condition? Am I missing something?

From Price1 bar, go back 3 bars to Price1[3] which is the HIP and I believe it meets the conditions?

Thanks.
Yes, you only have half the logic.

if condition1 and condition3 then begin...

User avatar
Sky
Posts: 47
Joined: 05 Dec 2013
Has thanked: 19 times
Been thanked: 4 times

Re: swingHigh/swingLow

Postby Sky » 30 Mar 2015

Ok, I see, the previous "swing" was a high so the next identifying point would be a low, etc.

Thanks for the help.

maubonvi
Posts: 16
Joined: 26 Sep 2014

Re: swingHigh/swingLow

Postby maubonvi » 31 Mar 2015

Hello gian9081,
I saw your code, and I wonder, how could it be written if I want to do the trendline between point and point instead of the lines? Why had they trendline, are very interesting breakout.
...watch the image attached.
What do you think?

Regards

Mauro
Attachments
BrkTrenLine.JPG
(166.37 KiB) Downloaded 991 times


Return to “MultiCharts”