Rewrite SwingTeller code from binck ProTrader to Prorealtime code
Forums › ProRealTime English forum › ProOrder support › Rewrite SwingTeller code from binck ProTrader to Prorealtime code
- This topic has 66 replies, 6 voices, and was last updated 7 years ago by AVT.
-
-
03/24/2017 at 12:44 PM #29755
Dear Prorealtime members,
Is there someone who can change this code of a different banksystem (protrader binq) to a prorealtime code.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091{- Filename: dynamische RSI -}varRSIPeriode: integer; // parameterwaardeStdDevUp, StdDevDown: real;BolBandPeriode: integer;i: integer;RSIValues, TARValues, UpperBand, LowerBand: TSeries;UpperCrossings, LowerCrossings: TLineCrossings;begin// Indicator parameter definitiesRSIPeriode := CreateParameterInteger('RSI periode', 1, 999, 7, true);BolBandPeriode := CreateParameterInteger('Boll. MA periode', 1, 999, 50, true);StdDevUp := CreateParameterReal('StdDevUp', 1, 9, 2, true);StdDevDown := CreateParameterReal('StdDevDown', 1, 9, 2, true);// Indicator definitiewith Indicator dobeginRequiredBars := 5*RSIPeriode + BolBandPeriode;end;// IndicatorberekeningRSIValues := RSI(Close, RSIPeriode);UpperBand := BollingerBand(RSIValues, BolBandPeriode, maSimple, StdDevUp);LowerBand := BollingerBand(RSIValues, BolBandPeriode, maSimple, -StdDevDown);TARValues := CreateSeries(BarCount);// signalen berekenenUpperCrossings := Crossings(RSIValues, UpperBand);LowerCrossings := Crossings(RSIValues, LowerBand);for i:=1 to BarCount-1 dobegin{RSI crosses over OB lijn = OB entry (signal)RSI > OB lijn = OB (condition)RSI crosses under OB = OB Exit (signal)RSI between OB en OS = Neutral (condition)RSI crosses under OS lijn = OS entry (signal)RSI < OS lijn = OS (condition)RSI crosses over OS = OS Exit (signal)RSI between OB en OS = Neutral (condition)}TARValues[i] := TARValues[i-1];if UpperCrossings[i] = lc1Over2 thenbeginEnterShort(i);TARValues[i] := 1;end elseif UpperCrossings[i] = lc2Over1 thenbeginExitShort(i);TARValues[i] := 0;end elseif LowerCrossings[i] = lc2Over1 thenbeginEnterLong(i);TARValues[i] := -1;end elseif LowerCrossings[i] = lc1Over2 thenbeginExitLong(i);TARValues[i] := 0;end;end;with CreateLine(RSIValues) dobeginColor := clLime;Name := 'RSI';end;with CreateLine(UpperBand) dobeginColor := clSilver;Name := 'OB';end;with CreateLine(LowerBand) dobeginColor := clSilver;Name := 'OS';end;with CreateLine(TARValues) dobeginColor := clWhite;Name := 'TAR';LineContent := lcTAR;Visible := false;end;end.I hope someone can help me with this
03/27/2017 at 3:23 PM #30005Seems to be an automated trading system based on RSI with Bollinger Bands, isn’t it?
This code seems to draw white lines too when signals occurs. So do you want to code it as a ProOrder automatic trading system or an indicator to draw lines when you get signals?
Is this strategy profitable? Do you use it yourself? Thanks.
03/27/2017 at 4:40 PM #30027Hi,
Thank you for your response!
I use it as an indicator combined with some other indicators, but this one is probably the most important and is most of the time accurate.
I just want the rsi with bollinger I dont mind about the signals.
Are you able to rewrite it for prorealtime?
Joerie
03/28/2017 at 9:25 AM #30072Ok, so here are a couple of indicators that may do this job already:
https://www.prorealcode.com/prorealtime-indicators/traders-dynamic-index-tdi/
https://www.prorealcode.com/prorealtime-indicators/rsi-self-adjusting-bands/
Tell me if that suits your query or not, many thanks.
03/28/2017 at 10:06 AM #30082Thats Perfect, Thank you very much!
One more thing,
Can you also help me with this indicator (Swingcounter)
It is a swingcounter that counts a row of green or red candles. I attached a picture to this document. I want it to be exactly like the picture so the numbers need to appear in the graphic chart and not below the chart as an indicator.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118{- Filename: Swingteller Perfect -}procedure TextAboveBar(Bar:integer; Text: string;fFontSize:integer; AColor:TColor);beginwith CreateText(BarPosition[Bar], High[Bar] * 1.003, Text) dobeginVertPosition := vpTop;HorzPosition := hpCenter;Color := AColor;Font.Size := fFontSize;end;end;//=== Procedure ================================================================procedure TextBelowBar(Bar: integer; Text: string;fFontSize:integer; AColor:TColor);beginwith CreateText(BarPosition[Bar], Low[Bar] * 0.997, Text) dobeginVertPosition := vpBottom;HorzPosition := hpCenter;Color := AColor;Font.Size := fFontSize;end;end;// === BEGIN ===================================================================vari,j,iFirst,Lb,UpCount,DownCount,FtSize : integer;UpCol,DwCol,BUpCol,BDwCol : TColor;HideCol,HideCnt : boolean;r: real;BEGIN// --- Indicator eigenschappen -----------------------------------------------with Indicator dobeginRequiredBars := 10;NewBand := false;HiddenParams := true;end;// --- Parameters ------------------------------------------------------------Lb := CreateParameterInteger('Lookback', 1, 10, 4, true);HideCnt:= CreateParameterBoolean('Hide Count?',false,true);UpCol := CreateParameterColor('Count Up', clGreen);DwCol := CreateParameterColor('Count Down', clRed);FtSize := CreateParameterInteger('FontSize', 10, 25, 8, false);HideCol:= CreateParameterBoolean('Hide BarColors?',true,false);BUpCol := CreateParameterColor('BarColor Up', clGreen);BDwCol := CreateParameterColor('BarColor Down', clRed);// --- Indicatorberekening & Weergave ----------------------------------------iFirst := FirstValidIndex(Close);i := iFirst+Lb;while i<BarCount dobeginif (UpCount > 0) and (Close[i] > Close[i-Lb]) thenbeginif not HideCol then SetParentBarColor(i, BUpCol);DownCount := 0;UpCount := UpCount+1;if (UpCount = 9) or (i=BarCount-1) thenbeginif not HideCnt thenfor j:=0 to UpCount-1 do TextAboveBar(i-j, IntToStr(UpCount-j), FtSize, UpCol);UpCount := 0;i := i+1;end;end elseif (DownCount > 0) and (Close[i] < Close[i-Lb]) thenbeginif not HideCol then SetParentBarColor(i, BDwCol);UpCount := 0;DownCount := DownCount+1;if (DownCount = 9) or (i=BarCount-1) thenbeginif not HideCnt thenfor j:=0 to DownCount-1 do TextBelowBar(i-j, IntToStr(DownCount-j), FtSize, DwCol);DownCount := 0;i := i+1;end;end elseif DownCount = 0 thenbeginr := Min(Min(Close[i-1], Close[i-2]), Close[i-3]);if Close[i] < r thenbeginDownCount := 1;UpCount := 0;// if not HideCnt then TextBelowBar(i, IntToStr(DownCount), FtSize, DwCol);if not HideCol then SetParentBarColor(i, BDwCol);end;end elseif UpCount = 0 thenbeginr := Max(Max(Close[i-1], Close[i-2]), Close[i-3]);if Close[i] > r thenbeginUpCount := 1;DownCount := 0;// if not HideCnt then TextAboveBar(i, IntToStr(UpCount), FtSize, UpCol);if not HideCol then SetParentBarColor(i, BUpCol);end;end;i := i+1;end;//=== END ======================================================================END.03/28/2017 at 10:36 AM #30090I remember having already coded something like this before, this is the code:
1234567891011121314151617181920212223242526272829//case BullishIf close > close[4] THENhighcount=highcount+1ELSEhighcount=0Endif//case BearishIf close < close[4] THENlowcount=lowcount+1ELSElowcount=0ENDIF//signals spottedIf highcount = 9 Thenbearish = 9Elsif lowcount = 9 Thenbullish = 9elsif highcount = 1 thenbearish = 1elsif lowcount = 1 thenbullish = 1Elsebearish = 0bullish = 0EndifRETURN bullish coloured(0,200,0) as "bullish signal _ count", bearish coloured(200,0,0) as "bearish signal _ count"But .. it was before the 10.3 release and the ability the draw text on chart, so only the 1st count reset and the 9th count appear. Could you please confirm that the signals given for the 9th count is good? If it’s ok, I’ll try to add text on price chart instead.
03/28/2017 at 10:54 AM #30099Heyy,
Thanks alot. This one doesn’t look good to me.
Swing +1 starts when a candle closes higher then the 3 candles before. And the swing -1 starts when the candle closes lower then 3 candles before. When a Fully swing has appeared (Swing 1 -> 9) it stops counting because the 10th candle is called the resting candle. If the 11th candle also closes higher then the 3 candles before the swing starts again at swing 1 (in green colour and red for -1). Also if a swing doesnt succeed in reaching number 9 all the numbers dissapear from the chart. So only the full swings till 9 are and the current swing at the moment is displayed in the graphic. But if the current swing doesnt succeed then it will also dissapear.
Hope you can understand this a little bit haha
03/28/2017 at 11:22 AM #3010904/03/2017 at 10:57 AM #30799Another try with this code, hope it’s better. But, the swing counts are not displayed while the actual swing is forming, it will be only displayed if the count is 9 (because we can’t erase what’s already written on chart). If this code is correct, I will change it to make it possible.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253Lb=4//begin swing Upif UpCount=0 thenr = Max(Max(Close[1], Close[2]), Close[3])if close>r thenUpCount=1DownCount=0endifendif//continue swing Upif UpCount>0 and Close>Close[Lb] thenDownCount=0UpCount=UpCount+1//draw countif(UpCount=9) thena=9for i = 1 to 9drawtext("#a#",barindex[i],low[i]-averagetruerange[10],Dialog,Standard,12) coloured(0,200,0)a=a-1next//reset countUpCount=0endifendif//begin swing Downif DownCount=0 thenr = Min(Min(Close[1], Close[2]), Close[3])if close<r thenDownCount=1UpCount=0endifendif//continue swing Downif DownCount>0 and Close<Close[Lb] thenUpCount=0DownCount=DownCount+1//draw countif(DownCount=9) thena=9for i = 1 to 9drawtext("#a#",barindex[i],high[i]+averagetruerange[10],Dialog,Standard,12) coloured(200,0,0)a=a-1next//reset countDownCount=0endifendifreturn04/03/2017 at 11:26 AM #30808Hi Nicolas,
We are getting close 🙂
First i see there is a digit shown 1.0 etc .. its should only be just 1
Also i see the count is not staring at the right moment i will send a printscreen where the counter goes wrong
And yes it should be perfect if the count was shown during the swing and not only when it completes to 9
rgds
John
04/03/2017 at 4:04 PM #3083904/03/2017 at 5:00 PM #30846Yes thank you. You can write comments and upload picture here instead! Your malware problem seems gone now, good news!
I managed the “resting bar”, but I’d like to change the way numbers are displayed to delete the digit and still with variable, instead of writing drawtext 9 times.. I’ll get back with some news later.04/03/2017 at 6:08 PM #30865Glad to hear that.
Ive attached a printscreen.
counter works but but at some points it isnt quite doing what it should
In this case it jumps from 9.0 to 2.0 on the next bar
It would also already be a great improvement to show the first bar with the 1 so at least one can see where the swing starts
Im sure you work something out 🙂
rgds
John
04/04/2017 at 12:47 AM #30899Hi Nicolas ,
Been looking through a few charts and i find the start of the counter is wrong in many cases
If a upswing starts the current close must be higher then the close of 4 bars earlier
For the downswing to start the close of the current day must be lower then 4 days ago
It must keep counting as long as that is the case. I think you have that working but the starting point often is wrong.
rgds
John
04/04/2017 at 9:09 AM #30958I think this new WIP version should be ok. Because code is read from top to bottom, sometimes counting were wrong, so I stacked the code in another way (my bad sorry).
About the Close superior or inferior to the one 4 bars earlier, it is not how it is coded in the original code posted by joerie1, it is looking for the current Close to be superior to highest one of the last 3 bars (up swing) and vice versa for the down swing, but I modified as per your suggestion..
-
AuthorPosts
Find exclusive trading pro-tools on