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.
-
-
06/08/2016 at 8:09 PM #9101
I’m still working on the screener I mentioned in my last post but I havn’t been able to devote as much time as I would like to it. So far my parameters for a screener are;
Triggers:
- MACD Zero lag to cross the zero line and for candle to close, or;
- Divergence MACD open source to give signal for divergence and close.
Filters for the candle giving the trigger must close with;
- Heiken Ashi candle in the same color as the trigger, green for buy and red for sell.
- Envelopes ADX (10) to be above 25 and rising, the most recently closed candle must have a higher value than the previous one.
An additional filter may be added and I’m somewhat uncertain about the ADX since it also filter out a few good entries, the point is to filter out ranging periods with entries which will not lead to substancial moves. ATR may work better but I don’t have much experience from using it so I’m uncertain about how to implement it.
CCI divergence may also be an additional trigger.
As Nicolas mentioned please share your ideas for developement or if any existing screeners would be useful 🙂
06/08/2016 at 8:17 PM #910206/08/2016 at 8:30 PM #9103@ davidp13
Yeah mainly entry signals for the time being but also experimenting a bit with different uses of the system such as scalping small to medium market moves with smaller grid steps and more contracts at each entry, it can yield large gains very fast but also requires very well timed entries and virtually watching your screen for quite a while to find an entry and then keep on watching as the trade progresses.
I have not done anything regarding the dynamic grid step since I’m almost clueless about the coding I leave that to Nicolas…
06/08/2016 at 8:42 PM #9104Personally I think the effort should go into managing the trade rather than finding the perfect entry. Tape readers don’t care about perfect all the care about is take profit off the table when the time is right. I have messed around with the money management code trying to find the best balance of when to close out or stay in across multiple systems and it seems very promising. Think we should work on the management aspect. Just my 2c
06/09/2016 at 7:07 PM #9131This money management strategy is only reliable if the market don’t retrace too much.. So entries IMO are very important and must be made before the market ‘explode’. Use of many different periods Bollinger bands could be helpful, or Keltner/…any other band into Bbands.. I have don’t came across something very relevant for the moment. I need to spend time on it.
What are you calling money management aspect? Since it’s already built-in? You mean: exit trades at the right moment? A big problem here is the no possibility to manage trades individually, so it’s kind of rough to find the best exit.. 🙂
06/10/2016 at 9:06 AM #9179Hi friends!
Maybe a Squeeze for entry?
All the best!
3 users thanked author for this post.
06/14/2016 at 11:25 AM #9377At least, I had time to finish the dynamic grid step function. This is only an indicator for the moment, but it would be easy to integrate it into the whole function later, or if anyone got time to test, I would be grateful!
As discussed this dynamic grid step has an inverted scale to the recent ATR volatility. So if the instant volatility increase, the grid step is dynamically reduced and vice-versa.
I implemented lower and higher boundaries to the grid (minSTEP and maxSTEP), so we can limit the effect of the dynamic step to not go too much high or low (a grid step of only 1 point would mean nothing for example).
The other parameter that can be changed at will is the ATRcurrentPeriod one, which represent the instant volatility of the instrument: understand that if this variable is low, the dynamic step would be quick to change its value or if this variable is higher, the dynamic step would be smoother.
I attach a picture of the indicator for comprehension purpose 🙂
Here is the code:
123456789101112131415//dynamic step gridminSTEP = 5 //minimal step of the gridmaxSTEP = 20 //maximal step of the gridATRcurrentPeriod = 5 //recent volatility 'instant' periodATRhistoPeriod = 100 //historical volatility periodATR = averagetruerange[ATRcurrentPeriod]histoATR= highest[ATRhistoPeriod](ATR)resultMAX = MAX(minSTEP*pipsize,histoATR - ATR)resultMIN = MIN(resultMAX,maxSTEP*pipsize)step = ROUND(resultMIN)RETURN ATR, step coloured(10,20,255)(edit: add a picture of the strategy with the dynamic grid step built-in, seems ok).
06/14/2016 at 7:51 PM #9404Great work Nicolas, I will start testing asap! Judging by the second picture above I guess you managed to integrate the dynamig step grid into the system? Can the function be pasted anywhere in the code or does it need to be added at any specific line? Since I’m so eager to try it I have tried integrating it myself but not quite managed…
@ Simon, excellent suggestion with the Squeeze indicator, it’s new to me and I’m trying it with different settings to optimize it. I have also been trying Nicolas’s indicator Choppiness index but the Squeeze seem more suitable. In fact I have never noticed Keltner before but put the regular bands on my chart since those are a good substitut for Heiken Ashi Smoothed which I’m used to trade with have not managed to find for PRT yet.
@ davidp13, I appreciate your input and two cents however since we have a fairly aggresive money management entries must be selected very carefully when the market conditions are right otherwise we will be stopped out very quick and there will be no trade to manage left 🙂
So testing goes on and I will come back with updates however progress will be slower since I’m very distracted by the Euro football 🙂
2 users thanked author for this post.
06/15/2016 at 9:57 AM #940706/15/2016 at 6:56 PM #942906/24/2016 at 8:08 PM #9820Hello friends!
Here is Squeeze screener, from a friend. I have not tested it.
@cfta How is the testing going? 🙂06/25/2016 at 7:38 AM #983306/25/2016 at 10:46 AM #983712345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788defparam preloadbars = 200once RRreached = 0//parametersaccountbalance = 10000 //account balance in money at strategy startriskpercent = 2 //whole account risk in percent%amount = 1 //lot amount to open each traderr = 4 //risk reward ratio (set to 0 disable this function)//dynamic step gridminSTEP = 5 //minimal step of the gridmaxSTEP = 20 //maximal step of the gridATRcurrentPeriod = 5 //recent volatility 'instant' periodATRhistoPeriod = 100 //historical volatility periodATR = averagetruerange[ATRcurrentPeriod]histoATR= highest[ATRhistoPeriod](ATR)resultMAX = MAX(minSTEP*pipsize,histoATR - ATR)resultMIN = MIN(resultMAX,maxSTEP*pipsize)gridstep = ROUND(resultMIN)//first trade whatever condition//if NOT ONMARKET AND close>close[1] AND STRATEGYPROFIT=0 then//BUY amount LOT AT MARKET//endifif NOT ONMARKET AND close<close[1] AND STRATEGYPROFIT=0 thenSELLSHORT amount LOT AT MARKETendif// case BUY - add orders on the same trendif longonmarket and close-tradeprice(1)>=gridstep*pipsize thenBUY amount LOT AT MARKETendif// case SELL - add orders on the same trendif shortonmarket and tradeprice(1)-close>=gridstep*pipsize thenSELLSHORT amount LOT AT MARKETendif//money managementliveaccountbalance = accountbalance+strategyprofitmoneyrisk = (liveaccountbalance*(riskpercent/100))if onmarket thenonepointvaluebasket = pointvalue*countofpositionmindistancetoclose =(moneyrisk/onepointvaluebasket)*pipsizeendif//floating profitfloatingprofit = (((close-positionprice)*pointvalue)*countofposition)/pipsize //actual trade gainsMAfloatingprofit = average[20](floatingprofit)BBfloatingprofit = MAfloatingprofit - std[20](MAfloatingprofit)*2//floating profit risk reward checkif rr>0 and floatingprofit>moneyrisk*rr thenRRreached=1endif//GRAPH floatingprofit as "float"//GRAPH RRreached as "rr"//GRAPH floatingprofit as "floating profit"//GRAPH BBfloatingprofit as "deviation of floating profit"//GRAPH positionprice-mindistancetoclose//GRAPH moneyrisk//GRAPH onepointvaluebasketGRAPH gridstep//stoploss trigger when risk reward ratio is not met alreadyif onmarket and RRreached=0 thenSELL AT positionprice-mindistancetoclose STOPEXITSHORT AT positionprice-mindistancetoclose STOPendif//stoploss trigger when risj reward ratio has been reachedif onmarket and RRreached=1 thenif floatingprofit crosses under BBfloatingprofit thenSELL AT MARKETEXITSHORT AT MARKETendifSELL AT positionprice-mindistancetoclose STOPEXITSHORT AT positionprice-mindistancetoclose STOPendif//resetting the risk reward reached variableif not onmarket thenRRreached = 0endif06/26/2016 at 11:34 AM #9859Hi fellows,
@ Simon, thanks for sharing the screener but would you care to explain what it screens for? Judging by the name one might think it screens for Squeeze On but we want to detect when Squeeze changes from on to off right? 🙂
As for the testing I have been very buys the last two weeks and have not had time for any real time testing at all, however next week I think I will manage and the backtests look good. I hope some more traders around here test it too in order to find the best parameters for ATR period along with min and max grid distance. There has been a general delay for a while now but more progress is to come!
06/28/2016 at 6:04 PM #9975Hi all,
Firstly, I want to say a big thank you to cfta for bringing up this idea to ProRealCode, and also a massive thanks to Nicolas for spending so much time getting it to the state it’s currently in. I’ve been following this since the beginning and am amazed at how well it’s been developed, so big thanks to everyone.
I’ve been testing this on a demo account (IG) while also forward-testing it at the same time. I’ve noticed that the .itf provided by Nicolas has the below code commented out. Was there a reason why it was commented out? Anyways, I realise the code is also used to initiate long trades so I’ve uncommented it and results seem quite good in back-testing.
1234//first trade whatever condition//if NOT ONMARKET AND close>close[1] AND STRATEGYPROFIT=0 then//BUY amount LOT AT MARKET//endifHowever, I am encountering an issue when running it as a system. Somehow the system does not initiate a new trade when the first one either TP or SL. Therefore, if the system goes SHORT to start, then commences building up the grid and suddenly gets SL, the system will then just idle without creating a new trade to go LONG. Are others also experiencing this?
I’ll paste my code below in case anyone wants to see it. I’ve added in 2 extra lines of code to; 1) Close all trades after a specific time, and 2) Only allow the system to open trades during a specified time (with start and end time).
I’m also running this system on the 1second timeframe.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293defparam preloadbars = 2000DEFPARAM FLATAFTER = 232959 //NOTE: Added in to close all trades after this timeonce RRreached = 0//parametersaccountbalance = 12000 //account balance in money at strategy startriskpercent = 1 //whole account risk in percent%amount = 2 //lot amount to open each traderr = 2 //risk reward ratio (set to 0 disable this function)//dynamic step gridminSTEP = 5 //minimal step of the gridmaxSTEP = 20 //maximal step of the gridATRcurrentPeriod = 5 //recent volatility 'instant' periodATRhistoPeriod = 100 //historical volatility periodATR = averagetruerange[ATRcurrentPeriod]histoATR= highest[ATRhistoPeriod](ATR)resultMAX = MAX(minSTEP*pipsize,histoATR - ATR)resultMIN = MIN(resultMAX,maxSTEP*pipsize)gridstep = ROUND(resultMIN)IF OPENTIME >= 150000 AND OPENTIME <= 232959 THEN //NOTE: Added to only allow the system to trade during this time period//first trade whatever conditionif NOT ONMARKET AND close>close[1] then //AND STRATEGYPROFIT=0 thenBUY amount LOT AT MARKETendifif NOT ONMARKET AND close<close[1] then //AND STRATEGYPROFIT=0 thenSELLSHORT amount LOT AT MARKETendif// case BUY - add orders on the same trendif longonmarket and close-tradeprice(1)>=gridstep*pipsize thenBUY amount LOT AT MARKETendif// case SELL - add orders on the same trendif shortonmarket and tradeprice(1)-close>=gridstep*pipsize thenSELLSHORT amount LOT AT MARKETendif//money managementliveaccountbalance = accountbalance+strategyprofitmoneyrisk = (liveaccountbalance*(riskpercent/100))if onmarket thenonepointvaluebasket = pointvalue*countofpositionmindistancetoclose =(moneyrisk/onepointvaluebasket)*pipsizeendif//floating profitfloatingprofit = (((close-positionprice)*pointvalue)*countofposition)/pipsize //actual trade gainsMAfloatingprofit = average[20](floatingprofit)BBfloatingprofit = MAfloatingprofit - std[20](MAfloatingprofit)*2//floating profit risk reward checkif rr>0 and floatingprofit>moneyrisk*rr thenRRreached=1endif//GRAPH floatingprofit as "float"//GRAPH RRreached as "rr"//GRAPH floatingprofit as "floating profit"//GRAPH BBfloatingprofit as "deviation of floating profit"//GRAPH positionprice-mindistancetoclose//GRAPH moneyrisk//GRAPH onepointvaluebasket//GRAPH gridstep//stoploss trigger when risk reward ratio is not met alreadyif onmarket and RRreached=0 thenSELL AT positionprice-mindistancetoclose STOPEXITSHORT AT positionprice-mindistancetoclose STOPendif//stoploss trigger when risj reward ratio has been reachedif onmarket and RRreached=1 thenif floatingprofit crosses under BBfloatingprofit thenSELL AT MARKETEXITSHORT AT MARKETendifSELL AT positionprice-mindistancetoclose STOPEXITSHORT AT positionprice-mindistancetoclose STOPendif//resetting the risk reward reached variableif not onmarket thenRRreached = 0endifendif -
AuthorPosts
Find exclusive trading pro-tools on