Bollinger Band Crosses
Forums › ProRealTime English forum › ProOrder support › Bollinger Band Crosses
- This topic has 15 replies, 5 voices, and was last updated 2 years ago by GraHal.
-
-
09/09/2021 at 11:46 PM #177173
MyLongConditions = close CROSSES OVER BollingerDOWN[20]
MyShortConditions = close CROSSES UNDER BollingerUP[20]Based on the above codes, may i know how the crosses are physically presented on charts.
I have a strategy where some of the crosses are not being considered as crosses though they look very similar to the others that are added as being crosses.
The following screenshot support my observations.
09/10/2021 at 8:22 AM #177176MyLongConditions is: previous Close is under previous Bollinger Down and current Close is above Bollinger Down
MyShortConditions is: previous Close is above previous Bollinger Up and current Close is below current Bollinger Up
In your first example, there is already an opened order, you might have a condition to prevent new order if one is already present? Second example, I dont know what’s happening, better to analyze the whole code to get a real idea of whats going on on that particular case.
09/10/2021 at 1:34 PM #177206Hello Nicolas,
Thanks for the information, but I dont remember applying any condition to prevent new order if one is already present.
Please see below my strategy and advise accordingly:
123456789101112131415161718192021222324//------------------------------------------// BollingerBands Strategy//----Backtest-------MyLongConditions = close CROSSES OVER BollingerDOWN[20]MyShortConditions = close CROSSES UNDER BollingerUP[20]p = 20upper = bollingerup[p]lower = bollingerdown[p]middle = average[p]BandwidthAbs= upper-lowerBandwidthCentage= (BandwidthAbs/middle)*100//Bandwidth% should be adjusted based on securities and timeframesIF MyLongConditions THENIF BandwidthCentage > 0.00 THENBUY 1 CONTRACTS AT MARKETENDIFELSIF MyShortConditions THENIF BandwidthCentage > 4.00 THENSELL AT MARKETENDIFENDIF09/10/2021 at 4:30 PM #177214Add Not OnMarket to your conditions:
1IF MyLongConditions AND Not OnMarket THEN1ELSIF MyShortConditions AND Not OnMarket THEN09/10/2021 at 8:33 PM #17722709/10/2021 at 8:53 PM #177228My fault, an order is likely to have been triggered but can’t exit.
Remove Not OnMarket from the ELSIF line.
09/12/2021 at 12:50 PM #177307You may want to use the “graph” command in probacktest to visualise data in a specific window for debugging and/or investigating unexpected behaviour, in order to find out if it’s a platform bug, or a user code bug, or not a bug but a misplaced expectation, etc… Here with adding as last line:
1graph MyShortConditionsit shows the cross in 2nd circle is detected on July 9th.
In case you were expecting a short position to open there, then it wasn’t a cross detection issue, it was about “sell” vs “sellshort” commands. Sell (used in your above code) exits an existing long position. Sellshort (not used in your above code) initiates a short position.
https://www.prorealcode.com/documentation/sell/
https://www.prorealcode.com/documentation/sellshort/(not entering into further details of when there is or isn’t an opposite position already open and being reversed rather than just exited, or when defparam cumulateorders = true or false settings is used)
09/12/2021 at 2:55 PM #177316JC_Bywan,
Thanks very much for the information.
But if you follow the thread from the beginning, Nicolas already asked whether i apply conditions to prevent new orders when one is already present and my reponse is NO. Now i have even provided my codes to you where you are able to confirm there is no such conditions so am confused you are making reference to that fact.
Or if what i have stated above do not represent the meaning of your information then can you please explain what you mean by : “Sell(used in your above code) exits an existing long position.”
Regards
09/12/2021 at 9:17 PM #17734009/12/2021 at 9:47 PM #177342not even a single signal , no cross over or cross under for all timeframes and asset classes
Try below and it may trigger orders using the values you show in your conditions.
1BandwidthCentage= (BandwidthAbs/middle)*1000 (in place of 100)Also, don’t you need SellShort (in place of Sell) at Market at Line 22?
09/12/2021 at 10:13 PM #17734509/12/2021 at 10:30 PM #177349Hello Nicolas,
Many thanks for providing more insight.
So if Sell is the instruction used to close buy order, does it then follow that for bollinger upperband cross to become a signal (Sell in this case), then there should have been already in existence a corresponding bollinger lowerband cross signal (Buy). It also follows that in a setup where there are 1 lowerband cross signal(Buy) followed by 3 successive upperband crosses, only one of these 3 crosses will become a Sell signal to close the earlier 1 Buy signal, the remaining 2 crosses will not qualify for signal . Am i right?
09/13/2021 at 10:27 AM #177400Yes … we can only Sell (Close a Long) if we have a Buy / Long trade open.
Am i right?
Yes … the remaing two crosses / Sell signals will do nothing if there are no open Longs to Sell / Close.
09/18/2021 at 9:15 PM #17787509/19/2021 at 8:46 AM #177888Hello,
I also need help to explain the attached screenshot where there are 5 consecutive Buy signals followed by 2 consecutive upperband crosses.
Only one of the upperband crosses converted to Sell signal to close one of the 5 Buy signals, leaving the other upperband cross as just a cross. Does it mean the remaining 4 Buy signals have been cancelled.
Also may i know whether it was the 1st, 2nd, 3rd, 4th or the 5th Buy signal that was closed by the Buy signal.
Regards
-
AuthorPosts
Find exclusive trading pro-tools on