How to create a breakout box between 2 hours, Code please?
Forums › ProRealTime English forum › ProOrder support › How to create a breakout box between 2 hours, Code please?
- This topic has 56 replies, 5 voices, and was last updated 6 years ago by robertogozzi.
Tagged: BreakOut
-
-
07/12/2018 at 11:52 AM #75863
You shoud add
1AND Not daysForbiddenEntryin lines 26 and 29, just before THEN.
Those days are FORBIDDEN, just remove the ones you want trading to be allowed.
1 user thanked author for this post.
07/12/2018 at 12:47 PM #7586707/23/2018 at 10:49 AM #76499I have been using the Auto Trading and it is working great, after all of the help from everybody 😉 but it only ever buys £1 per point, either way.
I have been into Options>Trading Options > Auto trading, but there is nothing for position size? ( I have seen it on the simplified creation) and on the website link https://www.prorealcode.com/blog/learning/money-management-prorealtime-code/ from Nicholas, but I can’t seem to add it in.
If I want £3 per point, example, how can I add this please?
The link above does state how to amend it, but as my code has gotten longer and longer, I keep getting error messages when I try to insert the position size.
07/23/2018 at 11:03 AM #76501I keep getting error messages when I try to insert the position size.
It would be easier for everyone if you posted the code on here as otherwise we are all just going to be guessing what you might have done wrong.
07/23/2018 at 11:34 AM #765021234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556defparam flatafter = 210000daysForbiddenEntry = OpenDayOfWeek = 1 OR OpenDayOfWeek = 2 OR OpenDayOfWeek = 3 OR OpenDayOfWeek = 4 OR OpenDayOfWeek = 6 OR OpenDayOfWeek = 0if longonmarket thenalreadybuy=1endifif shortonmarket thenalreadysell=1endifif intradaybarindex=0 thenalreadybuy=0alreadysell=0endifif time = 061000 thenyh = highest[86](high)yL=lowest[86](low)os = 2*pipsizeendiftcondition = time>080000 and time<200000if tcondition thenif close<yh+os and not alreadybuy thenbuy 1 contract at yh+os PositionSize 3 stopendifif close>yl+os and not alreadysell thensellshort 1 contract at yl-os PositionSize 3 stopendifendifset stop ploss 30ONCE TrailStart = 30 //30 Start trailing profits from this pointONCE ProfitPerCent = 0.666 //66.6% Profit to keepIF Not OnMarket THENy1 = 0y2 = 0ELSIF LongOnMarket AND close > (TradePrice + (y1 * pipsize)) THEN //LONGx1 = (close – tradeprice) / pipsize //convert price to pipsIF x1 >= TrailStart THEN //go ahead only if 30+ pipsy1 = max(x1 * ProfitPerCent, y1) //y = % of max profitENDIFIF y1 THEN //Place pending STOP order when y>0SELL AT Tradeprice + (y1 * pipsize) STOP //convert pips to priceENDIFELSIF ShortOnMarket AND close < (TradePrice – (y2 * pipsize)) THEN //SHORTx2 = (tradeprice – close) / pipsize //convert price to pipsIF x2 >= TrailStart THEN //go ahead only if 30+ pipsy2 = max(x2 * ProfitPerCent, y2) //y = % of max profitENDIFIF y2 THEN //Place pending STOP order when y>0EXITSHORT AT Tradeprice – (y2 * pipsize) STOP //convert pips to priceENDIFENDIFLastly, I have a slight issue with the breakout box settings, if the time condition is 8-8, as below:
tcondition = time>080000 and time<200000.
Eg: Sell example: If the price has moved out of the breakout box at say 7:30, it seems to buy at 8 regardless, I would like the sell trade to be cancelled if the box has been broken before 8. The buy remains active, but the same conditions as the above.
Hopefully this makes sense.
07/23/2018 at 11:49 AM #76503Hopefully this makes sense.
I don’t know what else might be wring as I am just about to run it, but surely Lines 25 to 32 need to read as below (without PositionSize 3) ??
Also DaysForbiddenEntry in Line 3 is not used in the code??
Attached is what I get on DJI at 10 min TF (what TF and Market is it supposed to run on?). Ignore the Win %, it is low due to the PRT Even Trades Glitch some of us are experiencing.
1234567if tcondition thenif close<yh+os and not alreadybuy thenbuy 1 contract at yh+os stopendifif close>yl+os and not alreadysell thensellshort 1 contract at yl-os stopendif1 user thanked author for this post.
07/23/2018 at 12:28 PM #76510GraHal,
Many thanks, 5 min chart, I am on.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657defparam flatafter = 210000daysForbiddenEntry = OpenDayOfWeek = 2if longonmarket thenalreadybuy=1endifif shortonmarket thenalreadysell=1endifif intradaybarindex=0 thenalreadybuy=0alreadysell=0myprofit=strategyprofitendifif time = 061000 thenyh = highest[86](high)yL=lowest[86](low)os = 1*pipsizeendiftcondition = time>080000 and time<200000if tcondition and strategyprofit<=myprofit and yh>0 and yl>0 thenif close<yh+os and not alreadybuy AND Not daysForbiddenEntry thenbuy 1 contract at yh+os stopendifif close>yl+os and not alreadysell AND Not daysForbiddenEntry thensellshort 1 contract at yl-os stopendifendifset stop ploss 15ONCE TrailStart =130 //30 Start trailing profits from this pointONCE ProfitPerCent = 0.8 //66.6% Profit to keepIF Not OnMarket THENy1 = 0y2 = 0ELSIF LongOnMarket AND close > (TradePrice + (y1 * pipsize)) THEN //LONGx1 = (close - tradeprice) / pipsize //convert price to pipsIF x1 >= TrailStart THEN //go ahead only if 30+ pipsy1 = max(x1 * ProfitPerCent, y1) //y = % of max profitENDIFIF y1 THEN //Place pending STOP order when y>0SELL AT Tradeprice + (y1 * pipsize) STOP //convert pips to priceENDIFELSIF ShortOnMarket AND close < (TradePrice - (y2 * pipsize)) THEN //SHORTx2 = (tradeprice - close) / pipsize //convert price to pipsIF x2 >= TrailStart THEN //go ahead only if 30+ pipsy2 = max(x2 * ProfitPerCent, y2) //y = % of max profitENDIFIF y2 THEN //Place pending STOP order when y>0EXITSHORT AT Tradeprice - (y2 * pipsize) STOP //convert pips to priceENDIFENDIFI have added the forbidden code in.Removing the position size works on a back test, but how do I code in, the position size, (i.e £3 per point instead of the standard £1 per point)Also, eg DJI, 5 min chart, 2/7/18. Breakout box was broken at 6:05, the system bought at 08:50, not sure why?I would like to code in, if the price has broken out already before 8, the sell trade gets cancelled. (same conditions for the buy)07/23/2018 at 2:23 PM #7651307/26/2018 at 11:29 AM #76791Is it possible to add a non trade condition to the pro auto trading?
I would like to add a condition, in that, if the breakout box is over 300 pips, the trades, buy and sell are not allowed to happen.
I have tried to code it in, but for some reason it won’t work.
Please could somebody have a look and see where I have gone wrong.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263defparam flatafter = 210000daysForbiddenEntry = OpenDayOfWeek = 2if longonmarket thenalreadybuy=1endifif shortonmarket thenalreadysell=1endifif intradaybarindex=0 thenalreadybuy=0alreadysell=0myprofit=strategyprofitendifif time = 061000 thenyh = highest[86](high)yL=lowest[86](low)os = 1*pipsizeendifif yh-yL >=300*pipsize THENresult=0elseresult=1endiftcondition = time>080000 and time<200000if tcondition and strategyprofit<=myprofit and yh>0 and yl>0 thenif close<yh+os and not alreadybuy AND Not daysForbiddenEntry thenbuy 1 contract at yh+os stopendifif close>yl+os and not alreadysell AND Not daysForbiddenEntry thensellshort 1 contract at yl-os stopendifendifset stop ploss 15ONCE TrailStart =30 //30 Start trailing profits from this pointONCE ProfitPerCent = 0.6666 //66.6% Profit to keepIF Not OnMarket THENy1 = 0y2 = 0ELSIF LongOnMarket AND close > (TradePrice + (y1 * pipsize)) THEN //LONGx1 = (close - tradeprice) / pipsize //convert price to pipsIF x1 >= TrailStart THEN //go ahead only if 30+ pipsy1 = max(x1 * ProfitPerCent, y1) //y = % of max profitENDIFIF y1 THEN //Place pending STOP order when y>0SELL AT Tradeprice + (y1 * pipsize) STOP //convert pips to priceENDIFELSIF ShortOnMarket AND close < (TradePrice - (y2 * pipsize)) THEN //SHORTx2 = (tradeprice - close) / pipsize //convert price to pipsIF x2 >= TrailStart THEN //go ahead only if 30+ pipsy2 = max(x2 * ProfitPerCent, y2) //y = % of max profitENDIFIF y2 THEN //Place pending STOP order when y>0EXITSHORT AT Tradeprice - (y2 * pipsize) STOP //convert pips to priceENDIFENDIF07/26/2018 at 12:16 PM #7679407/26/2018 at 12:29 PM #7679707/27/2018 at 12:03 PM #76881I’m hoping this is the last question. 😉 Sorry Roberto.
I have read lots about selling after n bars, but I would only like to sell after n bars, if the trade is losing.
I have input the following code, but it sells regardless of profit / loss.
1234if onmarket and BARINDEX-TRADEINDEX(1)>30 thenSELL AT MARKETEXITSHORT AT MARKETendifIs it possible to remain in the trade after 30 bars if winning, but if after 30 bars I am losing, it sells the trade?
Many thanks again in advance.
07/27/2018 at 12:39 PM #76882You need below or something similar… 🙂
position perf is a %
1234if onmarket and positonperf < - 0.0001 and BARINDEX-TRADEINDEX(1)>30 thenSELL AT MARKETEXITSHORT AT MARKETendifOR
1234if onmarket and abs(Close - tradeprice < 0) and BARINDEX-TRADEINDEX(1)>30 thenSELL AT MARKETEXITSHORT AT MARKETendifsyntax might be wrong, I have my grandkids here and they want to watch Horrid Henry! 🙂
07/27/2018 at 1:10 PM #76884The code you found lets you close any open trade after N bars, regardless of performance, you ahould add a condition testing whether TRADEPRICE is higher or lower than the current CLOSE and act accordingly.
123IF Close < TRADEPRICE AND (TradeInex - BarIndex) > 30 THENSELL AT MARKETENDIFthis will close any long trade after 10 bars if the curent price is below entry price.
07/27/2018 at 1:17 PM #76885I think it should be (Barindex – TradeIndex) and not (TradeIndex – BarIndex) and it closes after 30 bars not 10.
I’m guessing you are on your phone Robertogozzi as the code was not inserted correctly – I tidied it up for you 🙂
1 user thanked author for this post.
-
AuthorPosts