Reducing tradesize after Xpoints from entry
Forums › ProRealTime English forum › ProOrder support › Reducing tradesize after Xpoints from entry
- This topic has 6 replies, 2 voices, and was last updated 6 years ago by
Benson3.
-
-
12/18/2019 at 4:56 PM #115181
Hi All,
I am trying to code a reduction of the tradesize by half when being long/short and the current high/low reaches 20(before 15:00hr) or 40 (after 15:00hr) points. The remaining half will stay in until price closes below/above the lowest/highest point of the last 12 candlesticks. If the required points aren’t reached, but it does close on or above 10 points I want the stop loss to move to break even.
Additionally, I always want to exit when price closes below/above the lowest/highest point of the last 12 candlesticks or at a loss of 15 points. Whichever is sooner.
So far, I have come up with this, but it’s a mess:
123456789101112131415161718192021222324252627282930313233343536373839404142AM = time < 150000PM = time >= 1500000// Condiciones de salida de posiciones largasc3 = (close < lowest[12](low[1]))c17 = High >= (TradePrice + 20)c18 = High >= (Tradeprice + 40)c21 = close >= (tradeprice + 10)IF LongOnMarket ThenSet Stop ploss 15EndifIF LongOnMarket ThenIf c21 thenSet Stop ploss tradepriceEndifIf (AM AND c17) OR (PM AND c18) ThenSell CountOfLongShares/2 contracts at marketElsif c3 THENSELL AT MARKETEndifEndif// Condiciones de salida de posiciones cortasc6 = (close > highest[12](high[1]))c19 = low <= (TradePrice - 20)c20 = low <= (Tradeprice - 40)c22 = close <= (tradeprice - 10)IF ShortOnMarket ThenSet Stop ploss 15EndifIF ShortOnMarket ThenIf c22 thenSet Stop ploss tradepriceEndifIf (AM AND c19) OR (PM AND c20) ThenBuy CountOfShortShares/2 contracts at marketElsif c6 THENEXITSHORT AT MARKETEndifEndifI would appreciate some help.
Thanks
12/18/2019 at 5:09 PM #115182Are you aware that currently it is not possible to partially close a position using ProOrder when live trading? It is possible to test with partial closure when running a back test but you cannot put that strategy live in either demo or real trading.
12/18/2019 at 8:10 PM #115197Oh, that’s unfortunate. I have removed that part from the code and replaced it with just a profit target. However, it still doesn’t always do what I want it to do. That is exiting when price closes above or below the highest or lowest price of the last 12 candlesticks and moving the stop loss to break even after closing 10 points or higher from the entry price. Do you have any tips?
12345678910111213141516171819202122232425// Condiciones de salida de posiciones largasc3 = (close < lowest[12](low[1]))c21 = close >= (tradeprice + 10)IF LongOnMarket ThenIf c21 thenSet Stop ploss tradepriceElsif c3 THENSELL AT MARKETEndifEndif// Condiciones de salida de posiciones cortasc6 = (close > highest[12](high[1]))c22 = close <= (tradeprice - 10)IF ShortOnMarket ThenIf c22 thenSet Stop ploss tradepriceElsif c6 THENEXITSHORT AT MARKETEndifEndifSET TARGET PPROFIT 5012/18/2019 at 9:41 PM #115200SET STOP PLOSS requires a distance and not a price.
Try this (not tested):
12345678910111213141516171819// Condiciones de salida de posiciones largasc3 = (close < lowest[12](low[1]))c21 = close >= (tradeprice + 10)IF LongOnMarket ThenIf c21 or c3 thensell at marketEndif// Condiciones de salida de posiciones cortasc6 = (close > highest[12](high[1]))c22 = close <= (tradeprice - 10)IF ShortOnMarket ThenIf c22 or c6 thenEXITSHORT AT MARKETEndifSET TARGET PPROFIT 5012/19/2019 at 10:43 AM #115223This immediately exits my position, I just want to move the stop loss to break even. However, on your advice that set stop ploss requires a distance I changed tradeprice with just 0.1 that seems to work. It doesn’t work with 0 for some reason though. Anyway, thanks for your help.
12/19/2019 at 11:30 AM #115243SET STOP LOSS 0 cancels the stop order.
When trying to code break even stop losses you have to be aware of how close to price your broker will let you place the stop – and this can change at times of high volatility. So if you are only a few pips in profit and try to move your stop to break even then it is likely that your broker will reject the order – if your strategy tries too many candles in a row then they will stop the strategy and either close the trade or orphan it depending on your settings.
12/19/2019 at 5:37 PM #115264 -
AuthorPosts
Find exclusive trading pro-tools on