How to set up
Forums › ProRealTime English forum › ProOrder support › How to set up
- This topic has 6 replies, 2 voices, and was last updated 4 months ago by KumoNoJuzza.
-
-
08/06/2024 at 11:38 AM #236161
Hi guys,
I need help.
I want to set up the stop loss or the exit condition to the open price of the preceding bar of the tradeindex(1) as per the blue dashes the attached pic. There must be an obvious way to do it but I am stuck.
I am testing it on the following code:12345678910111213141516171819202122232425262728// 3 Candle Pattern//StrategyIf Close[2]>Open[2] and Close[1]>Open[1] and Close<Open[2] thenBear=1Bull=0ElsIf Close[2]<Open[2] and Close[1]<Open[1] and Close>Open[2] thenBear=0Bull=1EndIf// Stop Loss ManagementIf longonmarket and tradeprice(1) - close < 0 THENsell 1 contract at marketENDIFIf shortonmarket and tradeprice(1) - close > 0 THENexitshort at marketENDIF//Timeframe (1 mn)If Bull=1 and Bear[1]=1 thenbuy 1 contract at market//DrawArrowUP(BarIndex,Low)Coloured("Green")ElsIf Bear=1 and Bull[1]=1 thensellshort 1 contract at market//DrawArrowDown(BarIndex,High)Coloured("Red")EndIfThanks for your help
08/06/2024 at 12:06 PM #23616208/06/2024 at 12:16 PM #236163Sorry !! There you go
08/06/2024 at 12:27 PM #236165ok, so it’s the open of the bar when code is read, you can try to replace both line 24 and line 27 by :
set stop price open
if you run into issues of minimum distance, use min(open, minid)
where minid would be your broker’s minimum distance for this asset
1 user thanked author for this post.
08/06/2024 at 12:36 PM #236166Thanks @JC_Bywan.
I want to keep the same SL value for the duration of the position. I don’t want to update the SL at each new bar.
08/06/2024 at 1:13 PM #236170By suggesting to add set stop price open in lines 24 and 27, that’s what should happen because they are inside the same if statement as the order launching, so SL would be set only then and not updated at each new bar. You can also try to do it through a variable SL in order to graph it and visualize if behaviour matches your expectations:
1234567891011If Bull=1 and Bear[1]=1 thenbuy 1 contract at marketSL=openset stop price SLElsIf Bear=1 and Bull[1]=1 thensellshort 1 contract at marketSL=openset stop price SLEndIfgraphonprice SL2 users thanked author for this post.
08/06/2024 at 2:57 PM #236173Got it !! I ll play with it.
Thanks
-
AuthorPosts
Find exclusive trading pro-tools on