Grid orders with one combined stop loss and limit, can it be done?

Forums ProRealTime English forum ProOrder support Grid orders with one combined stop loss and limit, can it be done?

Viewing 15 posts - 1 through 15 (of 308 total)
  • #5409

    Hi Traders,

    This is my first post in the forum so let me introduce myself. I discovered the user friendly and creative PRT platform a couple of months ago and made the switch from the more frustrating MT4 platform, I have been trading FX along with commodity and index CFDs for over 7 years and picked up a few good strategies along the way, one which I am going to share and ask for help coding.

    The strategy is based on scaling into positions while maintaining the same risk by placing stop orders in the direction of the trend and momentum of the selected instrument, for instance earlier this week I was anticipating that EUR/USD would drop and at the time the market price was 1.1385. I would start the system placing an order to sell 1 contract at market price along with several sell stop orders to sell additional contracts at predetermined intervals by 20 pips, 1.1365, 1.1345 and 1.1325 etc.

    The key for the strategy is to maintain the same risk as more contracts are added to the position, starting with a 1% risk on the initial market order taken at 1.1385 with 1% risk equaling 100 pips with a stop loss at 1.1485, once the second order is filled at 1.1365 the 1% risk is maintained by the stop loss being moved automatically to 1.1425 (50 pips from the average price at 1.1375), once the third order is filled at 1.1345 the 1% risk is maintaned by the stop loss being moved automatically to 1.1398 (33 pips from the new average price at 1.1365) and on it goes until reaching the desired number of contracts, in my case most often 5-10 contracts. In a perfect world I would like to include a function to set the stop loss to break even once reaching a certain percentage of profit but I have not figured that part out yet…

    If going for 5 contracts at 20 pip intervalls the first 100 pips yield a 3% return and evry additional 20 pips yield 1 additional percent, for instance given that pullbacks and whipsaws are moderate and do not cause an exit by the stop loss a 240 pip move yield a 10% profit with only 1% risk, I say that is pretty sweet R:R and MM 🙂

    I already have the code to do this on the frustrating and not so reliable MT4 platform but can it be coded for PRT?

    A few weeks ago I thought of course it can be done! Now I am a bit less convinced since I have made two requests to the inhouse ProRealTime programmers and been given two different sets of code but neither of them works as intended for my IG account so now I am asking all of you and in particular Nicolas if it es even possible to code this?

    This is the first code provided by the PRT programmers;

    And here is the second code;

    In the first code the SL function seemed to be working fine but not the order placement which tended to place all orders virtually instantly at the same price, in second code the orders were sometimes place at the proper intervalls and sometimes at the same price as a previous order.

    Please help me figure this out, I look forward to any replies and assistance!

     

    Regards, Filip

    1 user thanked author for this post.
    #5414

    Hi !

    Im trying to code a simular strategy and and having trouble to. So i would be very happy if someone can solve this problem.

    Regards, Henrik

    #5440

    Hello,

    Welcome here and thanks for sharing your strategy with everyone.

    About your tests and bugs finding, have you spotted them in real market conditions or only in backtest please?

    So the 1% stoploss would be dynamically compute at each bar for the whole basket orders, isn’t it?

    #5482

    Hi fellows,

    I appreciate your interest and fast replies.

    I have only been forward testing in real market conditions so far.

    Yes, I suppose so regarding the stoploss or alternatively move automatically to a new fixed level once a new order is triggerd.

    As mentioned above it seems that the first code is working better for the stoploss but the entry orders have been filled at the same or random levels…

     

     

    #5487

    Hi,

    I rewrote the whole thing for the sell side only. I think it should make it, but test it with minimal lot size under real market conditions please.

    I add 2 GRAPH instructions for displaying the new stoploss and the average price position of the whole basket for debugging purpose (see picture attached). Please have a look if it’s ok with your strategy.

     

    #5489

    Wow, you are really fast Nicolas, I’m impressed!

    Sure thing, I will test it in real market conditions first thing on Monday morning and come back with an update.

    Thanks a lot for your help and have a nice weekend.

     

    #5499

    HI!

    This would work in small timeframe like 1 sec but not in 1h, 1d or 1w. The problem is that its hard to find god buy/sell conditions in small timeframes. How do you solve that? Im using IG version by the way. Is it possible to build indicators to simulate 15min, 1d, 1w price and then connect other inducaters to that  simulated price timeframe?

    Regards, Henrik

    #5597

    Hello Nicolas,

    Unfortunately I lost my remote connection from work today so I have only been able to test for a couple of hours tonight. I learned that graphs are not allowed when testing in real market conditions so I did a slight modification to the code removing the graphs;

    However I also did some backtesting and it seems like the code cause the positions to close at -1 % each instead of -1 % in total, see the attached screenshot, for the first set of trades with 10 sell orders the average price once all orders had been filled was 1.4162 and the-1 % in total SL should have kicked in at about 10 pips higher around 1.4172.

    Nicolas do you have an idea how to fix this please?

     

    #5603

    Sorry for graph instruction, i always forget to remove it when i send code to people … 🙂 It’s only for debugging purpose and not allowed by ProOrder.

    Well, I never used averaging down in real market conditions with IG. So I believe the problem is in the use of POSITIONPRICE which would return the average open price of the whole trades… Apparently not! I will ask PRT guys why.

    So I believe the solution is in the first code you post (from ProRealTime services), so remove the lines 11 to 19 from my code and add this instead:

     

     

    #5607

    No worries I would probably forget it all the time too 🙂

    I updated the code with some minor modifications replacing “lots” with “shares” to match your code with the first one I got;

    In backtesting the problem remains, five orders triggered but not exited until way past the total -1 %. Could it be due to the first code being a long only and yours being short only? Or is necessary for line 1 – 9 in the first code to be included for the SL to work?

    #5609

    Maybe averagetade variable is not calculated correctly? Do the whole orders closed at the same time anyway? I’ll have a look by tomorrow.

    #5623

    I have just tested once more, this time with long only orders, and set the exit at 1% and things go well under tester:

     

    POSITIONPRICE is really the average open price of the whole opened orders.

     

    #5678

    Thanks Nicolas, it looks like we are making a lot of progress.

    I only removed a zero from (positionprice*0.001), the entry orders seem to be working good except for a minor issue that sometimes when the system is started it buys two contracts instead of one, in addition occasionally the intervals are a bit larger around 30 instead of 20 pips I guess this is due to dependency to close of the current candle?

    If you have time it would be great if it is possible to a limit function to exit all positions for an instrument.

    I have begun testing your latest code in real time market conditions so we will see if it works and I will give an update tomorrow!

     

     

    #5680

    About the 30 pips instead of 20, it is obviously about the one time test only on each bar.

    And for the 2 contracts instead of 1 only at system start up, I have no clue right now… sorry. Maybe the entry position has to be better defined than a close versus close[1] ?

    #5716

    Hey guys,

    I bought a new aparment today so I haven’t had as much time for testing as I wanted but I set up the system on NZD/JPY and Dax which have been running on real market conditions for about 24 hours now.

    The good news is that the entries seem to work very good with orders being filled at every 20 pips with small differencies. The less good news is that the SL seem to kick in too early with (positionprice*0.001) at only -0.1 % but kick in too late with (positionprice*0.01) with floating loss of CAD 200 on a USD 10 000 account. I may have missed something in the calculations but so far I can’t figure it out.

    NOTE! Due to my lack of experience of PRT and lack of coding knowledge I have not mentioned one of the most important features, since this strategy is meant to manage R:R and MM for manual trades, though taken automatically, it is crucial that no new entry orders are placed after a SL kicked in. The system must wait to be started again manually, how can this feature be added?

Viewing 15 posts - 1 through 15 (of 308 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login