Swing Indicator
Forums › ProRealTime English forum › ProBuilder support › Swing Indicator
- This topic has 26 replies, 1 voice, and was last updated 2 years ago by Khaled.
-
-
10/25/2017 at 4:22 PM #50496
A request that was addressed to ProRealTime:
Good morning, I would like to recode this swing indicator in tradestation format to prorealcode language.
inputs: filter(2), stats(0);
vars : xBar(0) , xHigh(0), xLow(0), xCount(0), xSwitch(0);
vars : xSkip(0), xConfirm(0);
vars : pBar(0) , pHigh(0), pLow(0);
vars : bFirst(1);if xSwitch = 0 then
begin
if High >= xHigh then
begin
xHigh = High;
xLow = Low;
xBar = BarNumber;
xSkip = 0;
end
else
begin
xSkip = xSkip + 1;
if xSkip >= filter then
begin
xConfirm = 1;
xCount = 1;
while xCount < filter
begin
if (Low[xCount] <= Low[xCount-1]) or (xLow <= Low[filter-1])
then
begin
xCount = filter;
xConfirm = 0;
end;
xCount = xCount + 1;
end;
if xConfirm = 1 then
begin
xSwitch = 1;
if stats = 0 then
plot1[BarNumber-xBar](xHigh,”Swing”)
else
begin
if bFirst = 0 then
begin
plot2[BarNumber-xBar](xHigh-pLow,”Range”);
plot3[BarNumber-xBar](xBar -pBar,”Duration”);
end;
bFirst = 0;
end;
pHigh = xHigh;
pLow = xLow;
pBar = xBar;
xHigh = High;
xLow = Low;
xBar = BarNumber;
xSkip = 0;
end;
end;
end;
end
else
begin
if Low <= xLow then
begin
xHigh = High;
xLow = Low;
xBar = BarNumber;
xSkip = 0;
end
else
begin
xSkip = xSkip + 1;
if xSkip >= filter then
begin
xConfirm = 1;
xCount = 1;
while xCount < filter
begin
if (High[xCount] >= High[xCount-1]) or (xHigh >=
High[filter-1]) then
begin
xCount = filter;
xConfirm = 0;
end;
xCount = xCount + 1;
end;
if xConfirm = 1 then
begin
xSwitch = 0;
if stats = 0 then
plot1[BarNumber-xBar](xLow,”Swing”)
else
begin
plot2[BarNumber-xBar](pHigh-xLow,”Range”);
plot3[BarNumber-xBar](xBar -pBar,”Duration”);
end;
pHigh = xHigh;
pLow = xLow;
pBar = xBar;
xLow = Low;
xHigh = High;
xBar = BarNumber;
xSkip = 0;
end;
end;
end;
end;if ((date = lastcalcdate) and (time = lastcalctime)) then
begin
if xSwitch = 0 then
begin
if stats = 0 then
plot1[BarNumber-xBar](xHigh,”Swing”)
else
begin
plot2[BarNumber-xBar](xHigh-pLow,”Range”);
plot3[BarNumber-xBar](xBar -pBar,”Duration”);
end;
end
else
begin
if stats = 0 then
plot1[BarNumber-xBar](xLow,”Swing”)
else
begin
plot2[BarNumber-xBar](pHigh-xLow,”Range”);
plot3[BarNumber-xBar](xBar -pBar,”Duration”);
end;
end;
end;Suggestion for an anwser:
Add a filter variable and then add the indicator on the price graph:
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859if xSwitch = 0 thenif High >= xHigh thenxHigh = HighxLow = LowxSkip = 0elsexSkip = xSkip + 1if xSkip >= filter thenxConfirm = 1xCount = 1while xCount < filterif (Low[xCount] <= Low[xCount-1]) or (xLow <= Low[filter-1])thenxCount = filterxConfirm = 0endifxCount = xCount + 1wendif xConfirm = 1 thenxSwitch = 1MyxHigh=xHighxHighBar=Barindex-xskipxHigh = HighxLow = LowxSkip = 0endifendifendifelseif Low <= xLow thenxHigh = HighxLow = LowxSkip = 0elsexSkip = xSkip + 1if xSkip >= filter thenxConfirm = 1xCount = 1while xCount < filterif (High[xCount] >= High[xCount-1]) or (xHigh >= High[filter-1]) thenxCount = filterxConfirm = 0endifxCount = xCount + 1wendif xConfirm = 1 thenxSwitch = 0myxlow=xLowxLowBar=Barindex-xskipxLow = LowxHigh = HighxSkip = 0endifendifendifendifDRAWSEGMENT(xLowBar, myxlow, xHighBar, MyxHigh) COLOURED(255,0,0)return4 users thanked author for this post.
10/27/2017 at 1:22 PM #5072110/27/2017 at 4:25 PM #5074003/22/2019 at 10:56 AM #94386Come si definisce la variabile filter ???
03/22/2019 at 11:42 AM #94395massimo mamprin – English only in the English forums please.
03/22/2019 at 11:54 AM #94396Filter seems to be what is commonly called Period.
Write
1Filter=20as the first line. Change it whenever you want to.
03/24/2019 at 12:28 PM #94554Thank you
How can I change the colour of the line
In PRT i can make the input about the number of the bar when i change the colour the line is the same colour
Do you know can I change
Thanks
03/24/2019 at 2:03 PM #94557You can add 3 variables for colours:
– Red
– Green
– Blue
you can then set them with the properties.
Change the last part of line 58 as follows:
1COLOURED(Red,Green,Blue)03/24/2019 at 9:48 PM #94568I try but give me error (sintassi)
03/24/2019 at 10:43 PM #94572Post the code you have written.
03/25/2019 at 9:59 AM #945851234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162if High >= xHigh thenxHigh = HighxLow = LowxSkip = 0elsexSkip = xSkip + 1if xSkip >= filter thenxConfirm = 1xCount = 1while xCount < filterif (Low[xCount] <= Low[xCount-1]) or (xLow <= Low[filter-1])thenxCount = filterxConfirm = 0endifxCount = xCount + 1wendif xConfirm = 1 thenxSwitch = 1MyxHigh=xHighxHighBar=Barindex-xskipxHigh = HighxLow = LowxSkip = 0endifendifendifelseif Low <= xLow thenxHigh = HighxLow = LowxSkip = 0elsexSkip = xSkip + 1if xSkip >= filter thenxConfirm = 1xCount = 1while xCount < filterif (High[xCount] >= High[xCount-1]) or (xHigh >= High[filter-1]) thenxCount = filterxConfirm = 0endifxCount = xCount + 1wendif xConfirm = 1 thenxSwitch = 0myxlow=xLowxLowBar=Barindex-xskipxLow = LowxHigh = HighxSkip = 0endifendifendifendifDRAWSEGMENT(xLowBar, myxlow, xHighBar, MyxHigh) COLOURED(255,0,0)returnEDIT by Vonasi: Code tidied up using ‘Insert PRT Code’ button for you. 🙂
03/25/2019 at 10:04 AM #94587I want to point out two issues:
- To write code, please use the <> “insert PRT code” button, to make code easier to read and understand
- When you Copy remove any line number (try not to select them if possible) after Pasting the code
the latter being the cause of reported syntax errors.
03/29/2019 at 3:09 PM #9501303/29/2019 at 4:21 PM #95029ZigZag like many other indicators plots the tops and bottoms. You can take any calculation method to find and link them with segments and you’ll get something similar to zigzag.
1 user thanked author for this post.
10/07/2019 at 10:35 PM #109561 -
AuthorPosts
Find exclusive trading pro-tools on