New position with similar conditions only when the first position take breakeven
Forums › ProRealTime English forum › ProOrder support › New position with similar conditions only when the first position take breakeven
- This topic has 14 replies, 4 voices, and was last updated 2 years ago by robertogozzi.
-
-
08/16/2020 at 7:38 AM #14171008/16/2020 at 7:51 AM #141712
Only if the first one closed at breakeven (no profit at all)?
08/16/2020 at 10:04 AM #141716Fran55, could you please elaborate bit more?
Are you saying something like:
- Open first position
- When it has reached a profit of x points, move stoploss of first position to breakeven and open second position with similar conditions as position 1.
If this indeed is the case, there is a very nice grid strategy here which can be customised to your needs: https://www.prorealcode.com/topic/grid-orders-with-one-combined-stop-loss-and-limit-can-it-be-done/
If something else, please explain.
08/16/2020 at 11:33 AM #14172008/16/2020 at 12:08 PM #141721Breakeven with second position123456789101112131415161718192021222324defparam CUMULATEORDERS = TRUEOnce OpenPositions=0Ordersize = 1 //amend to reflect how many postions you want each time// Conditions to enter long positionsIF Not LongOnmarket and YourConditions THEN //specify your buy conditionsBUY Ordersize CONTRACTS AT MARKETSL = YourStopLoss //specify your original stop lossOpenPositions = OrdersizeENDIF// Conditions to exit long positionsIf (OpenPositions=OrderSize) AND YourConditions THEN //Opening Second position and updating stoplossOnce SL = positionPrice //this moves your stoploss to position-1 buyprice//remove keyword "Once" if yuo want both positions to be at breakeven. That is, stoploss will be between buying prices of position1 and Position2,BUY Ordersize CONTRACTS AT MARKETENDIF<Specify Conditions to exit long positions>set stop ploss SLSimilarly amend for short conditions.
I know there is an issue on copied links to work, so you couldn’t access above. Hopefully someone can advise how to access above link.
08/16/2020 at 12:09 PM #141722The outcome of the last closed position is returned by PositionPerf(1), so you just need to check it was 0:
12345If MyConditions and Not OnMarket and PositionPerf(1) = 0 then.. Buy/Sellshort........Endif08/16/2020 at 4:33 PM #14174908/16/2020 at 4:54 PM #141751This to accumulate a position after a 0.6% increase:
12345If MyConditions AND ((PositionPerf * 100) >= 0.6) then.. Buy/Sellshort........Endif08/16/2020 at 6:44 PM #14175908/16/2020 at 6:48 PM #141760Yes, if you use a 5-minute TF it will add a position when that bar closes.
08/16/2020 at 7:36 PM #14176508/16/2020 at 9:32 PM #141781There you go:
12345If MyConditions AND (abs(Countofposition) < 3) Then.. Buy/Sellshort........Endif04/22/2021 at 3:10 PM #167796Hello, I tried the following code without success, the second position does not execute:
12345678910If Not Longonmarket and CtimeAchat1 AND CaMom1bis AND CaMom2bis AND CaLoc4bis AND CaLoc5bis AND CaFig6bis AND CaFig7bis and CaWillA2 THENBUY n SHARES AT MARKETset target %profit takeprofitbisset stop loss Stoplossbis ptrailing 46ENDIFIf longonmarket and ((positionperf*100)>=x1) AND (abs(Countofposition)<3) AND CtimeAchat1 AND CaMom1 AND CaMom2 AND CaLoc4 AND CaLoc5 AND CaFig6 and CaWillA1 THENBuy n shares at marketset target %profit takeprofitset stop loss Stoploss ptrailing 50endifBearing, independently, the positions run normally.
Could you help me ?
04/22/2021 at 4:09 PM #167802Try to abide by the basic rules, as highlighted in yellow below:
- Always use the ‘Insert PRT Code’ button when putting code in your posts to make it easier for others to read.
- Only post in the language of the forum that you are posting in. For example English only in the English speaking forums and French only in the French speaking forums.
Thank you 🙂
04/22/2021 at 4:15 PM #167804Try GRAPHing as many variables as possible to spot any issue:
1234Graph NGraph ((positionperf*100)>=x1)Graph (abs(Countofposition)<3)Graph ..... -
AuthorPosts
Find exclusive trading pro-tools on