Help please to code a One Shot Trading System
Forums › ProRealTime English forum › ProOrder support › Help please to code a One Shot Trading System
- This topic has 5 replies, 3 voices, and was last updated 2 years ago by
Berwick.
-
-
05/25/2022 at 11:45 AM #193833
- If +20 points from 8:00am price, open Long.
- If – 20 points from 8:00am price, open Short.
- For Long & Short trades, SL = -20 TP = +96.
- If +10 in profit, move stop to -10, close 50 % of pos size.
- If +40 in profit, move stop to +16 and close 50% of remaining pos size.
- If +44 in profit, start trailing stop to trail by + 20, then move by +1 for each successive +1 rise.
- Trade exits either by TS or the TP (+96).
- System then Quits.
05/28/2022 at 11:48 AM #194062There you go:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081ONCE LotSize = 4 //lots to be tradedONCE Offset = 20 * PipSize //offset fom 8am priceONCE Distance = 7 //Distance rquired by the broker for pending oifers (to be checked with the broker)ONCE PriceAt8 = 0ONCE ExitPrice = 0IF Not OnMarket AND OnMarket[1] THENQUITENDIFIF IntraDayBarIndex = 0 THENPriceAt8 = 0ENDIFIF OpenTime = 080000 THENPriceAt8 = closeENDIFIF OnMarket AND Not OnMarket[1] THENEntry = TradePriceENDIFIF Not OnMarket AND PriceAt8 > 0 THENIF close >= (PriceAt8 + Offset) THENBUY LotSize Contract at MarketELSIF close <= (PriceAt8 - Offset) THENSELLSHORT LotSize Contract at MarketENDIFExitPrice = 0TrailFlag = 0TrailBase = 20SET TARGET pPROFIT 96SET STOP pLOSS 20ENDIFIF OnMarket THENMyProfit = PositionPrice * PositionPerf / PipSizePositions = abs(CountOfPosition)IF MyProfit >= 44 THENIF LongOnMarket THENExitPrice = Entry + TrailBase * PipSizeELSEExitPrice = Entry - TrailBase * PipSizeENDIFTrailBase = TrailBase + 1ELSIF MyProfit > 40 AND TrailFlag = 1 THENTrailFlag = 2IF LongOnMarket THENExitPrice = Entry + 16 * PipSizeSELL (Positions / 2) CONTRACTS at MarketELSEExitPrice = Entry - 16 * PipSizeEXITSHORT (Positions / 2) CONTRACTS at MarketENDIFELSIF MyProfit >= 10 AND TrailFlag = 0 THENTrailFlag = 1IF LongOnMarket THENExitPrice = Entry - 10 * PipSizeSELL (Positions / 2) CONTRACTS at MarketELSEExitPrice = Entry + 10 * PipSizeEXITSHORT (Positions / 2) CONTRACTS at MarketENDIFENDIFIF ExitPrice > 0 THENIF LongOnMarket THENIF close >= (ExitPrice + Distance) THENSELL AT ExitPrice STOPELSIF close <= (ExitPrice - Distance) THENSELL AT ExitPrice LIMITELSE//SELL AT MarketENDIFELSEIF close <= (ExitPrice - Distance) THENEXITSHORT AT ExitPrice STOPELSIF close >= (ExitPrice + Distance) THENEXITSHORT AT ExitPrice LIMITELSE//EXITSHORT AT MarketENDIFENDIFENDIFENDIF//graphonprice Entry//graphonprice ExitPrice coloured(255,0,0,255)//graph MyProfitI added a DISTANCE as required by the broker (the correct value is to be checked with the broker) for pending orders. If an order is placed at an incorrect price, the oredr is rejected and the strategy stopped (in both demo and real, not in backtest, of course).
As to the DISTANCE I added two commented lines (thus ignored) to exit at MARKET if the distance is not enough. If you wat to use those two lines, simply remove the leading slashes.
To disable the distance, set it to 0.
5 users thanked author for this post.
05/28/2022 at 2:10 PM #19407405/28/2022 at 3:41 PM #194081Roberto is so very kind helping us all out, coding our ideas!
Let us know how you get on Monday please Berwick. I’m going to give it a go also! 🙂
1 user thanked author for this post.
05/28/2022 at 4:08 PM #194084A 20-pip SL is so tight that it almost always is hit and the strategy is stopped immediately.
To test it, I used a 100-pip SL and commented out the QUIT instruction.
1 user thanked author for this post.
05/28/2022 at 8:09 PM #194090Roberto is so very kind helping us all out, coding our ideas!
Let us know how you get on Monday please Berwick. I’m going to give it a go also! 🙂
GraHal, please be aware that this is not the entry strategy that I use, my initial request was for a trade manager and it is this part of the code that I am really interested in. Monday may be a quiet day on the markets as it is Memorial Day in the US.
2 users thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on