Hi,
I have been trying to work out how to implement the same settings that are used in the trailing stop in the simplified creation, and use them in creation by programming as ProOrder does not allow for combined stops.
The issue seems to be for most of the other trailing stops are based on bar closing data which doesn’t not help this strategy as its done on the daily time frame, so they wait too long to be able to act on the moves. All I am looking for is an exact replica of the trailing stop in the simplified that can be used with the normal stop in programming so it can be tested in auto trading.
I have taken a screenshot of the programming done by the simplified creation to help illustrate what I am using currently. I have looked at the other trailing stops and used them in the back test but for some reason I am getting very different results, which is why I am asking for any idea’s on here. I realise there has been a lot of talk on this already but since they are showing different results I thought I need some help in understanding this.
Here is the code from simplified :
// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
// Conditions to enter long positions
c1 = (close > open)
IF c1 THEN
BUY 1 PERPOINT AT MARKET
ENDIF
// Conditions to exit long positions
c2 = (close CROSSES UNDER open)
IF c2 THEN
SELL AT MARKET
ENDIF
// Conditions to enter short positions
c3 = (close < open)
IF c3 THEN
SELLSHORT 1 PERPOINT AT MARKET
ENDIF
// Conditions to exit short positions
c4 = (close CROSSES OVER open)
IF c4 THEN
EXITSHORT AT MARKET
ENDIF
// Stops and targets
SET STOP pLOSS 10 pTRAILING 5
SET TARGET pPROFIT 40
I would really appreciate any help or insight into what I need to better understand to make this happen.
Thank you in advance for your time,
Always use the ‘Insert PRT Code’ button when putting code in your posts to make it easier for others to read.
Apologies for the miscopied code, here it is in the correct format.
Thank you
MODERATORS EDIT: Your first post was edited by a moderator to insert the code correctly so it was not necessary to post it again. I have deleted the code in this post to shorten the topic and make it easier to read..
That was the same topic, the answers you’ll read there apply to you, as well:
https://www.prorealcode.com/topic/using-set-stop-and-trail-stop/
ProOrder does not allow for combined stops.
Not exactly, should be read as: ProOrder with IG does not allow for combined stops.
Ah thank you for the clarification, I was not aware of that.
Hi,
Yes I have read that post, and used the code in my programming. Maybe I am then asking the wrong question, in fact I probably am, sorry. What settings should I be using in that programming to get the same result as a 5 point/pip trailing stop as was entering in the simplified creation?
In the simplified I only entered one number but I need the trailing step and start in the code and this is where I am going wrong, I have read other feeds but I can’t find something that answers the equivalent question.
I did also read somewhere that it (the code) needs to wait until the end of the bar to reset, or something similar and since I am trading daily bars in the strategy this might be making it hold on to the trade rather than exiting.
I really appreciate any help in this, I hope the above makes sense.
Thank you in advance
At line 33 just remove the second part (after 10). Leave everything else.
In the trailing stop code set 5 for start and 1 for step.
Hi robertogozzi,
Thank you for clarifying that, I have had issues with PRT on my mac and havent been able to access the program recently.
The way to create the same trailing stop as you have suggested removes the profit target, correct?
I would like to keep my profit target, I have tried to find a forum post with this is in but I have found it hard to get more details on this. Essentially I am trying to recreate a strategy that I created in simplified creation to automation but because of the stops and trailing stops IG wont let me but I am struggling to find the right code, and my coding skills are not up to the task right now.
Any help would be much appreciated,
Best
Remove the “SET STOP pLOSS 10″ from your code and add a pending stop order with:
//long position:
sell at tradeprice-10*pointsize stop
//short position
exitshort at tradeprice+10*pointsize stop
Thank you very much!
And apologies for not appreciating sooner, the support on this forum is phenomenal.
Very much appreciated to a novice like myself.
Best.