Stop loss set at 0
Forums › ProRealTime English forum › General trading discussions › Stop loss set at 0
- This topic has 9 replies, 5 voices, and was last updated 3 years ago by robertogozzi.
-
-
05/31/2021 at 6:55 PM #170861
Hello Everyone
I am relatively new to PRT, I am trying to create a code that enters a long position whenever a price is hit and I would like to set a stop loss at the entry price.
So for instance whenever target price x is reached then buy 1 contract and if the price on the next candel drops back to the entry price x then exit long position.
PRT does not allow me to set the stop loss at 0 usd
The idea is to exit the long position before it make a loss
Does anyone any Alice on how to achieve this?
Thank you in advance.
Regards.
05/31/2021 at 8:34 PM #170862You will be at a loss the instant you execute a Buy (or SellShort).
Reason for above is that the broker takes a spread between Buy and Sell Price (also between SellShort and ExitShort).
Also IG will not let us have a Stop Loss that is nearer the Buy Price than the minimum IG specify … typically 6 for the DJI. But this can be between 10 and even 100’s at volatile periods.
Best we can do to keep Order Rejections to a minimum on the DJI is to use SL = 10, or at least 8.
06/01/2021 at 7:35 AM #170875Tutu – My initial response is exactly as GraHal’s. So that. And notice that what this comes down to is setting the StopLoss at +6 which would be about equal to the spread he mentions.
What I wanted to add :In program code you can do what you want. This would mean that you don’t work with a StopLoss command as such, but that you just exit (Sell when you are Long) when you / the program likes it. Is that at your calculated 0 ? then fine, you will lose the spread (amount). Did you calculate/expect** that the spread will be 10 ? then exit at a gain of 10 compared to your entry price and your profit will be 0 (what you wanted).
**): Before you ask, you can’t really know the spread in advance. So you’d need to take a figure of which you’ll know to be on the safe side. However, do notice that the spread can be seen in the IG platform (not sure where – or their mobile app which shows it about everywhere).
06/01/2021 at 8:57 AM #170881Thank you for your prompt reply.
I used to follow a manual strategy/ trade manually in IG by entering long positions on select stock and commodities ( based on news and some technical/ fundamental analysis) I exit the long position the same day if the price does not move higher as expected by placing a stop loss at the entry price in IG platform after the price increases a little bit higher than the minimum spread requirement (in other words I wait for the price to increase slightly before putting the stop loss at the entry price).
I am trying to replicate the same strategy in automatic trade in PRT.
Basically I buy long position at x price wait a little bit for the price to increase then assign a stop loss at the entry price (x) so that the loss is 0 (barring any slippage) if the price does not move in the desired direction.
If the price decreases outright after I entered the long position I set a different stop loss at say 10 pips.
If the price moves higher I usually set a target profit.
I am struggling to code this strategy in PRT.
06/01/2021 at 11:02 AM #170897I recommend reading posts such as this one from Nicolas:
https://www.prorealcode.com/blog/learning/breakeven-code-automated-trading-strategy/
The code that you might think would be logical for setting a stop loss to break even,
1set stop loss 0actually deactivates the stop loss (if you didn’t know that already).
06/08/2021 at 10:22 AM #17138106/09/2021 at 5:23 PM #171495Hello Everyone,
I am still facing an issue with the following code : instead of selling ( exit long position ) the system is placing a stop loss.
Basically what I am trying to achieve is this : buy at $x , if current price > $x do nothing , whenever price goes back to $x then sell at $x
Exit long123456789101112131415// Definition of code parametersDEFPARAM CumulateOrders = False // Cumulating positions deactivated// Conditions to enter long positionsc1 = (Open >= 50)IF c1 THENBUY 1 CONTRACT AT MARKETENDIFc2 = (Close = 50)IF LONGONMARKET AND c2 THENSELL AT 50ENDIFThank you
06/09/2021 at 5:29 PM #171496Replace line 14 with:
1SELL AT MARKET06/09/2021 at 6:21 PM #17150006/09/2021 at 7:18 PM #171501Yes, you can do so.
-
AuthorPosts
Find exclusive trading pro-tools on