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?
- This topic has 307 replies, 1 voice, and was last updated 7 months ago by OtherAttorney.
-
-
04/20/2016 at 9:36 PM #5723
Something’s wrong here, you’re right. The average position price minus 1% is 75.626 for your basket of 3 orders this morning and they exited @76.30 at 16:00 …
Just to be sure: exit is calculated @ average position price minus 1% of this price = average position * 0.99 / are we ok with this?
On my backtest (screenshot attached), trades are not closed, graph instruction return exactly the ‘newsl’ variable where the trades are supposed to close… Are you sure you don’t have change the multiplier to 0.001 instead of 0.01?
As for the strategy to shutdown after a loss, we can use STRATEGYPROFIT to achieve this, just change the line2 with this code:
1if NOT ONMARKET AND close>close[1] AND STRATEGYPROFIT=0 thenSo the first order will only be launched one time and grid orders are not initiated if there are no other orders on market.
04/21/2016 at 7:13 AM #5733Good morning Nicolas,
Yes I’m absolutely ok with exit is calculated @ average position price minus 1% of this price = average position * 0.99.
It turns out that I had indeed changed the multiplier to 0.001, sorry about the mix up.
Thanks, I keep on testing today adding the shut down after loss feature 🙂
04/21/2016 at 5:27 PM #5761So for todays update of the real market testing, I changed the 2nd line as above but kept (positionprice*0.01) thinking it’s best to make one change at the time but the system still placed new entry orders after SL with this code;
1234567891011121314151617// first trade whatever conditionif NOT ONMARKET AND close>close[1] AND STRATEGYPROFIT=0 thenBUY 1 LOT AT MARKETendif// case BUY - add orders on the same trendif close-tradeprice(1)>20*pipsize thenBUY 1 LOT AT MARKETendif// stoploss at 1% from the average price of the whole positions on marketif longonmarket thennewSL = positionprice - (positionprice*0.01)if close<=newSL thenSELL AT MARKETendifendifNo I have changed to 0.99 running it along with the change of the second line, let’t se it it works 🙂
04/21/2016 at 7:22 PM #5766Hmmm I think i know why, change this lines too :
1234// case BUY - add orders on the same trendif longonmarket and close-tradeprice(1)>20*pipsize thenBUY 1 LOT AT MARKETendifBecause it will open a new trade even if the previous one is closed already … miss that thing sorry 🙂
04/24/2016 at 10:51 AM #5879Thanks once again Nicolas. Unfortunately I have not been able to test your latest addition yet since my PRT demo with IG expired a couple of days ago and I’m waiting for IG to allocate my deposit to my account so I should be back on track soon enough, I’ll give a new update in the days to come…
04/30/2016 at 11:43 AM #625405/01/2016 at 6:57 PM #6303Hello Nicolas,
Yes finally I got an update! IG had a major delay in allocating my deposit to my account, partly my own fault though, but I got it sorted a couple of days ago and today I set up my demo account again. I have been doing some backtesting this evening with the latest modified code you provided and things look very promising!
I ran it on a Dax 3 minute chart (hence some entries are not exactly 20 pips when the market moved fast) and all entries were triggered properly and so was the SL. In addition no new entry orders were placed after the SL was triggered 🙂
This is the code I used;
1234567891011121314151617// first trade whatever conditionif NOT ONMARKET AND close>close[1] AND STRATEGYPROFIT=0 thenBUY 1 LOT AT MARKETendif// case BUY - add orders on the same trendif longonmarket and close-tradeprice(1)>20*pipsize thenBUY 1 LOT AT MARKETendif// stoploss at 1% from the average price of the whole positions on marketif longonmarket thennewSL = positionprice - (positionprice*0.99)if close<=newSL thenSELL AT MARKETendifendifTomorrow I will start the forward testing in real time demo and if looking good I might even try it on my real account though I will watch it very closely if I do.
So if the current code keep on working as intended there are two additions that I hope we can make;
- A limit function for taking profit at a given percentage level with a default level of 10 %.
- A function to bring the SL to break even once a given profit is reached, perhaps 3 %.
Another general question due to my lack of PRT and coding experience, is it possible to modify a system while it is running in real market conditions? The point would be to manually change SL or limit levels.
I’ll be back with a new update tomorrow after some forward testing.
05/01/2016 at 7:50 PM #6307Hmm when testing the same code on GBPCAD the SL is not triggered which it should have been at around 1.8300 or a bit lower due to the lower pip value of this pair. Makes no sense to me…
Please ignore the first pic, I uploaded the wrong one but don’t know how to remove it.
05/01/2016 at 7:58 PM #631205/02/2016 at 12:29 AM #6318Another general question due to my lack of PRT and coding experience, is it possible to modify a system while it is running in real market conditions? The point would be to manually change SL or limit levels.
- As an IG client you cannot modify a system once it’s running in PRT.
- You can only Stop it and there are options in the general settings if you Stop a system should it close positions or leave them open.
- If you manually modify a position on the IG platform it will Stop the system but your position will stay open if you only changed the PT/Limit or Stop Loss and then you have to Restart the system in PRT it will state user intervention stopped the system.
I assume the reason for this is if there’s a bug that’s not in your system but a bug with PRT, PRT can test for it as they did for one of my systems that started opening positions until it hit the PRT 50 positions per day per system limit.
05/02/2016 at 8:08 AM #632205/02/2016 at 7:15 PM #6355Thanks guys, that makes perfect sense, I figured it’s not possible but doesn’t hurt to ask. Being able to modify the positions on IG and maintain them open even if the system is stopped it a great benefit to change the SL to lock in profit or raise the limit after building up large positions and price takes off in the right direction after news announcements.
Today I have been testing in real market conditions on demo and things look very good, entry orders are taken is intended with small differences which can probably be adjusted by changing to a second or tick chart from the 1 minute chart. I started the system on Dax, EURJPY and GBPCAD this morning taking 3, 4 and 3 entries accordingly, I’m hoping Dax will turn down during the evening or tomorrow to see if the SL works properly.
Nicolas, could you possibly provide a code for short positions too please? I tried reversing one of the long codes earlier on but never managed to make it work properly I’m afraid.
New updates to come tomorrow or the next day.
05/02/2016 at 7:42 PM #635805/03/2016 at 10:00 PM #6423Hi fellows it’s been a long day and getting late so I’ll keep this update bried but I will tell you more about my strategy and trading plan tomorrow 🙂
Today’s performance has been bad news since Dax dropped as expected but the SL was not triggerd and drawdown went over -5 %. This is the code currently running;
1234567891011121314151617// first trade whatever conditionif NOT ONMARKET AND close>close[1] AND STRATEGYPROFIT=0 thenBUY 1 LOT AT MARKETendif// case BUY - add orders on the same trendif longonmarket and close-tradeprice(1)>20*pipsize thenBUY 1 LOT AT MARKETendif// stoploss at 1% from the average price of the whole positions on marketif longonmarket thennewSL = positionprice - (positionprice*0.99)if close<=newSL thenSELL AT MARKETendifendifNicolas, do you have any idea why the SL was not triggered?
05/04/2016 at 10:40 AM #6438Before I change anything on code. You are talking about drawdown, but drawdown about what precisely? In the current code, we are not testing money account at all, only the spread between the average open price of the whole positions and the current close of the instrument.
Since I don’t have informations about your 3 still opened trades, I don’t have any idea about where is the price stoploss computed by the program itself 🙂
-
AuthorPosts
Find exclusive trading pro-tools on