Cross Over Strategy HELP please
Forums › ProRealTime English forum › ProOrder support › Cross Over Strategy HELP please
- This topic has 22 replies, 2 voices, and was last updated 6 years ago by crolakstrading.
-
-
02/06/2018 at 6:56 PM #61765
sorry Im keep coming back.. soo after so many attempts i came up with this..
1234567891011121314151617181920212223242526272829defparam cumulateorders=false// Conditions to enter long positionsi1 = exponentialaverage[9](close)i2 = exponentialaverage[40](close)long = i1 crosses over i2short = i1 crosses under i2IF NOT LongOnMarket AND long[5]and summation[4](long) = 0 THENEntryPrice = highest[5](high) + (5* pipsize)BUY 1 CONTRACTS AT EntryPrice STOPENDIF// Conditions to exit long positionsIf LongOnMarket AND short THENSELL AT MARKETENDIF// Conditions to enter short positionsIF NOT LongOnMarket AND short[5]and summation[4](short) = 0 THENEntryPrice = lowest[5](low) - (5 * pipsize)SELLSHORT 1 CONTRACTS AT EntryPrice STOPENDIF// Conditions to exit short positionsIF ShortOnMarket AND long THENEXITSHORT AT MARKETENDIFwhich give me the entry as the topline or the bottomline as per the indicator.. but only issue is its only trigger on the 5th candle.. 5th bar didn’t get triggered, it doesn’t continue as a stop order? is there a way to sort it out.. please help!
Thanks
Ro
02/06/2018 at 11:08 PM #61813In lines 10 and 21 you only check the fifth previous bar, if it’s true the pending order is placed, but the next bar the fifth previous bar will become the sixth previous bar and your condition will obviously be false!
Since a pending order only lasts one bar…. it’ll never be triggered.
How many bars do you want the pending order to be kept in place, after the fifth one?
02/07/2018 at 12:19 AM #61819oh ok.. lets say once we get the Entryprice and confirmed then we get a pending order for that price for next 10 bars and probably cancel after 10 bars??
thanks Roberto.
02/07/2018 at 12:32 PM #61860Line 21 should read
1IF NOT ShortOnMarket AND short[5]and summation[4](short) = 0 THEN02/07/2018 at 12:57 PM #61861I modified your code to accomodate for counting elapsed bars since the crossing occurrs. I did not test it, give me some feedback.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748defparam cumulateorders = falseONCE MaxBars = 10ONCE CrossingBar = 0ONCE CrossUp = 0ONCE CrossDn = 0// Conditions to enter long positionsi1 = exponentialaverage[9](close)i2 = exponentialaverage[40](close)long = i1 crosses over i2short = i1 crosses under i2if long[5] thenCrossingBar = BarIndex //save the bar ID when the crossing occurred the previous 5th barCrossUp = 1CrossDn = 0endifif short[5] thenCrossingBar = BarIndex //save the bar ID when the crossing occurred the previous 5th barCrossUp = 0CrossDn = 1endifif OnMarket thenCrossingBar = 0 //reset it to zero when on marketCrossUp = 0CrossDn = 0endifIF NOT LongOnMarket AND CrossUp AND ((BarIndex - CrossingBar) <= MaxBars) THENEntryPrice = highest[5](high) + (5* pipsize)BUY 1 CONTRACTS AT EntryPrice STOPENDIF// Conditions to exit long positionsIf LongOnMarket AND short THENSELL AT MARKETENDIF// Conditions to enter short positionsIF NOT ShortOnMarket AND CrossDn AND ((BarIndex - CrossingBar) <= MaxBars) THENEntryPrice = lowest[5](low) - (5 * pipsize)SELLSHORT 1 CONTRACTS AT EntryPrice STOPENDIF// Conditions to exit short positionsIF ShortOnMarket AND long THENEXITSHORT AT MARKETENDIF1 user thanked author for this post.
02/08/2018 at 1:08 AM #61936hi Roberto.. thanks..
This is actually given better result.. but some of the entry prices isnt right.. i think its only take the 5th candles high and 5pips above..
Entry price should be.. once the cross over happen and wait for 5 bars and enter the highest high within that 5 bars and 5 pips above!! lets say cross over and the highest high is the 3rd candle with that 5 bars and it should be 5 pips above on that 3rd candle… indicator works perfectly fine as it say below.. if its long we get the TOPLINE perfectly!!
123456789101112131415CrossOver = fast crosses over slowIF CrossOver THENBullTrend = 1BearTrend = 0SideWays = 0CrossUnder = 0//cross = slow[1]DRAWARROWUP(barindex,LOW-5*pointsize) COLOURED(0,255,10)endifIF CrossOver[5] THENIF summation[4](CrossOver OR CrossUnder) = 0 THENTopLine = highest[5](high) + (5 * pipsize)DRAWTEXT("---#TopLine#---",barindex-3,TopLine,SansSerif,Bold,10)coloured(0,153,0)ENDIF02/08/2018 at 1:27 AM #61940Try this one, I moved lines 30 and 41 inside a prior IF…ENDIF block.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748defparam cumulateorders = falseONCE MaxBars = 10ONCE CrossingBar = 0ONCE CrossUp = 0ONCE CrossDn = 0// Conditions to enter long positionsi1 = exponentialaverage[9](close)i2 = exponentialaverage[40](close)long = i1 crosses over i2short = i1 crosses under i2if long[5] thenCrossingBar = BarIndex //save the bar ID when the crossing occurred the previous 5th barCrossUp = 1CrossDn = 0EntryPrice = highest[5](high) + (5* pipsize)endifif short[5] thenCrossingBar = BarIndex //save the bar ID when the crossing occurred the previous 5th barCrossUp = 0CrossDn = 1EntryPrice = lowest[5](low) - (5 * pipsize)endifif OnMarket thenCrossingBar = 0 //reset it to zero when on marketCrossUp = 0CrossDn = 0endifIF NOT LongOnMarket AND CrossUp AND ((BarIndex - CrossingBar) <= MaxBars) THENBUY 1 CONTRACTS AT EntryPrice STOPENDIF// Conditions to exit long positionsIf LongOnMarket AND short THENSELL AT MARKETENDIF// Conditions to enter short positionsIF NOT ShortOnMarket AND CrossDn AND ((BarIndex - CrossingBar) <= MaxBars) THENSELLSHORT 1 CONTRACTS AT EntryPrice STOPENDIF// Conditions to exit short positionsIF ShortOnMarket AND long THENEXITSHORT AT MARKETENDIF02/12/2018 at 5:04 PM #62450Thanks very much Roberto.. i think this is pretty much gives the right entry.. i will test this and let you know!!!!
-
AuthorPosts
Find exclusive trading pro-tools on