ProRealCode - Trading & Coding with ProRealTime™
Also is there a way to stay out of a market only while it has a high spread. So basically a code or setting that says don’t enter the market unless the spread is 3 for instance?
Yes code to not open a trade at the times shown on attached
Is there a way to make bulk changes to strategies so for example categorising long and short strategies into two separate groups and giving them a weighting so like 60% of your strategies 60% have to be long and 40% short for example.
I may not understand what you are asking, but only way I can think of is you would need to keep track and code accordingly for Long or Short strategies.
Hi thanks again for taking the time to respond. I actually do run each back test individually and then I hit the little black x button on the graph to close them but sometimes it behaves like i’ve hit the 10 limit. An regarding pausing the strategies I just submitted the request. It’s a long shot but fingers crossed lol. That google doc sheet is extremely helpful, didn’t even know it existed. Much appreciated 🙂
I know this is a bit of a vague question but is the strategy I posted earlier a simple strategy or am I more on the complexed side? So would a typical strategy or would the majority of people on the forum be using far more complexed algorithms or simpler ones? An by simple I’m primarily thinking of the parameters.
I’ve had some good returns at points but do most people on here have volatility checks, momentum checks on top of check after check or do most people tend to keep thing simple? Just kind of wondering if there’s a typical way to do build quant strategies?
Also is there any type of mentorship programmes for people I could e-mail or get on skype calls with or coaching etc? An that’s not something I would mind paying for.
Also looking at a the code I posted earlier is there any improvements you would make to it or anything people usually add that it’s just missing? Like something to keep it out of a sideways trading market etc.
Also thanks for letting me know about the DAX and DJI but do people typically just trade that and other indexes during the U.K 9-4;30, German 9-4;30 and the U.S 9-4:30? Or do people kind of follow the sun coming up around the world? So set their algorithms to the Australian index and then the Korean one at midnight and then the Indian one at whatever time of the morning that would start so they’re always in a active market?
An if so then could you let e know which world marries are popular on for this because I tried Australian shares and the BRL/JPY currency pair last night and came back with 0 transactions which was strange because there was plenty in the back testing.
I hit the little black x button on the graph to close them but sometimes it behaves like i’ve hit the 10 limit.
Do you also close the results Tables??
a simple strategy or am I more on the complexed side?
I can understand the code so I would consider it simple! 🙂
Some of the strategies on here, I doubt the Author understands them easily a few weeks late!!?? 🙂
Also is there any type of mentorship programmes for people I could e-mail or get on skype calls with or coaching etc?
Nicolas, the website owner, has the video training and he also does fee paid programming.
Soon there may be folks offering mentorship via Nicolas ‘Market Place’.
The links are from the menu at the top of this page.
Or do people kind of follow the sun coming up around the world? So set their algorithms to the Australian index and then the Korean one at midnight and then the Indian one at whatever time of the morning that would start so they’re always in a active market?
Sounds kinda utopian.
In reality … most of us are still trying to work up a strategy that makes consistent profits and therefore would allow us to sleep soundly while our money is going up and down on the Nikkei 225! 🙂
I have not found one and I have over 4,000 .itf ‘s on my PC … this will give you an idea as to how difficult it is!
Strategies work for a while then start losing and so you lose confidence in them all … that losing streak may start while you are asleep! 🙂
I personally prefer all my money to be back in me pot before I try and go to sleep!
Anyway you can trade markets ‘out of hours’ … e.g, the DJI is a 24 hour market.
Also looking at a the code I posted earlier is there any improvements you would make to it or anything people usually add that it’s just missing? Like something to keep it out of a sideways trading market etc.
To get folks interested enough to make improvements you would need to post a strategy on a separate Topic and post results that tempt them to spend their time.
If you ask a specific coding question then the moderators and / or a few others will help. You need to ask a specific question under a separate Topic and give your Topic a meaningful title … so others members can find the information and benefit etc.
What market(s) and timeframe is your strategy coded for?
I changed all Timeframes to default and flashed it over DJI TF’s from 10 sec to 4 hours and it does by far the best on 1 hour … results attached.
EDIT / PS
But you need to temper those results by looking at the Chart … if you had done Buy and Hold … does your strategy beat buy and hold??
I’d say maybe yes as during the recent 10k points shake out it lost only 1.2k, but overall the DJI is up about 8k points from the start of the attached chart and your strategy is up 9.2K points.
Problem for me would have been … that £1.8K drawdown / loss early on would have been out of my pocket … as the strategy had not made any profit at that point.
A drawdown is far more bearable if it is out of profit the strategy has made itself??
Thanks for the link to spread time table. It never even occurred to me that one would exist lol
Yes I do close the results tables. Sometimes I have to close every table and chart accept for the one I’m looking at a an dI can’t run a back test until I click the black x on the last strategy I run. Maybe there’s is some type of cache that takes time to be cleared or updates because it only happens after I’ve ran several back tests before and then deleted them.
Loool “I doubt the Author understands them easily a few weeks late!!?? 🙂”. That make me feel so much better. Some of the codes looked really complicated to me and I just assumed everyone understood them. So at least now I have some perspective 🙂
I’ve watched the free video training but I’ll definitely look into the fee paid programming and hopefully I can find someone offering mentorship. Thanks for the links.
Do most of your strategies go long and short inside one strategy? or do you have your long only strategies and short only strategies?
I seem to have created some fairly consistent strategies but I’m not sure if long and short strategies in general would experience more drawdown because you are making more trades or less because they should be more market neutral?
Also I’d suspect that long and short combined strategies are usually the most profitable because they make more trades or are they just less profitable because it’s harder to create a consistent long and short strategy?
Yep a utopia sounds nice. I have a friend who works managing a section fo a quant devision and he suggested the 24 hour strategy. It sounds like I’d have a lot of work cut for me.
I read this article https://www.prorealcode.com/blog/learning/how-to-improve-a-strategy-with-simulated-trades-1/ and this article https://www.prorealcode.com/blog/trading-strategy-profit-curve/
In the comments section it sounds like there was some issues with code in the comments section but it was years ago so maybe it’s been resolved but in theory wouldn’t it be easy to sleep if the Algo went into only simulated trades once the trades became unprofitable and then started back up only once the simulated trades were profitable?
That way you should wake up a profit or only a minimal loss. Do you think I could pay to have a cross between these techniques coded for me? So then I could trade overnight easier.
Well done coding 4,000 is an achievement in itself. I’ve done around 40 so far. 20 of them was from last year but with a few tweaks still work fine at the moment. I focus a lot on out of sample testing. An I’ve been using the optimisation engine on quantreex which seems to work well.
Is there any indicators that really seems to make a difference for you that is a recurring theme in the 4,000? Personally Aroon up/down seems to be pivotal and RSI overbought/oversold level cut offs really seem to help quite a few of my strategies over time.
With the strategies I coded for it’s displayed in the code so look for “TIMEFRAME 15 minutes” AND “TIMEFRAME 1 minute”. So some things have to happen on a 15 minute chart simultaneously with other things happening on a 1 minutes chart.
It’s been pretty consistent so far at least relative to the markets. So I’ve been chopping and changing a lot with the changes in market conditions lately but on average I run each strategy on 4-6 different instruments at once and all with an equal amount of pips on each one.
This is an effort to just diversify the portfolio and minimise the drawdown. Plus my friend said that’s how they programme the algorithms where he works. I’ve tried maybe 15-20 different instruments and settled on the most consistent 4-7 as France 40, FTSE 100, German DAX (Excluding overnight), EU Stocks 50, AUD/CHF, NZD/JPY and AUD/CHF
When you say “flashed it over DJI TF’s from 10 sec to 4 hours” is there a code to do that simultaneously or do you do that one by one?
Also yes I noticed during back testing DJI was the 4th best performer all month but in Pro Order you can’t do less then 1/pip so with diversifying with 4-6 instruments at all times the DJI has been too expensive to try so far.
I know you can use mini lots with manual trading but pro order does seem to go under 1/pip Is there any way around that?
Also with the drawdown I want to set a daily stop loss do you know how to do that? Some days the market conditions just don’t suit a strategy/ instrument pairing so just pausing it at a maximum drawdown and then starting back up the next day and repeating until the market conditions become more favourable will mitigate drawdown plus with 4-6 instruments at all times drawdown should be minimised already.
I need to code some of short sell strategies over from quantreex to make everything market nuetral as well.
That’s a really interesting test how long do you check the buy and hold period for? So what would’ve happened if you held a month or a fortnight or a day etc?
it only happens after I’ve ran several back tests before and then deleted them.
I find this also, it’s like a process is hanging … that’s why I close the Platform after a few heavy sessions and log back in … only take 30 seconds tops and saves loads issues and basktests seems faster for a while until rinse and repeat! 🙂
Do most of your strategies go long and short inside one strategy?
Yes, but it can be annoying as when I judge that on a losing trade that price is likely to reverse as it is at the top / bottom of a pullback and then bang the position reverses and so I have lost the chance to make the loss up and also the new trade is likely to lose also!
I guess above is a case for not having long reverse into short strategies, but some of my most profitable over long term are just these types! I guess because they are in the market 99% of the time so they only have to be correct 60% of the time and it can be a big winner!!
Algo went into only simulated trades once the trades became unprofitable and then started back up only once the simulated trades were profitable?
Trouble is that profitable trade, made during simulated trades, might be the biggest winner for weeks, but we missed it due to being in simulated trades mode!
Well worth more investigation though … please let us know your conclusions?
Well done coding 4,000 is an achievement in itself.
I counted (using folder properties! 🙂 ) after I said 4000 and it is actually 4877, but they are far from all my original work!
Loads off this website and I may then spawn 3 or 4 versions with various tweaks etc and so the number of files grow and grow!! 🙂
Also I never delete anything as I may throw the baby out with the bath water.
Hi @tradetrader101 – had a quick look at your code and my first thought was that you could do better than using the basic trailing stop. This one by Nicolas is v good and has a built in break even function:
//trailing stop function
trailingstart = tst //trailing will start @trailinstart points profit
trailingstep = st //trailing step to move the "stoploss"
//reset the stoploss value
IF NOT ONMARKET THEN
newSL=0
ENDIF
//manage long positions
IF LONGONMARKET THEN
//first move (breakeven)
IF newSL=0 AND close-tradeprice(1)>=trailingstart*pipsize THEN
newSL = tradeprice(1)+trailingstep*pipsize
ENDIF
//next moves
IF newSL>0 AND close-newSL>=trailingstep*pipsize THEN
newSL = newSL+trailingstep*pipsize
ENDIF
ENDIF
//manage short positions
IF SHORTONMARKET THEN
//first move (breakeven)
IF newSL=0 AND tradeprice(1)-close>=trailingstart*pipsize THEN
newSL = tradeprice(1)-trailingstep*pipsize
ENDIF
//next moves
IF newSL>0 AND newSL-close>=trailingstep*pipsize THEN
newSL = newSL-trailingstep*pipsize
ENDIF
ENDIF
//stop order to exit the positions
IF newSL>0 THEN
SELL AT newSL STOP
EXITSHORT AT newSL STOP
ENDIF
For a % version of the same, change the first 2 lines to
trailingPercent = tst
stepPercent = st
if onmarket then
trailingstart = tradeprice(1)*(trailingpercent/100) //trailing will start @trailingstart points profit
trailingstep = tradeprice(1)*(stepPercent/100) //% step to move the stoploss
endif
This one by Roberto is extremely clever and def worth trying, may require adjusting the initial values (BasePercent, TrailStart, StepSize, PerCentInc)
IF Not OnMarket THEN
//
// when NOT OnMarket reset values to default values
//
TrailStart = 30 //30 Start trailing profits from this point
BasePerCent = 0.200 //20.0% Profit percentage to keep when setting BerakEven
StepSize = 10 //10 Pip chunks to increase Percentage
PerCentInc = 0.100 //10.0% PerCent increment after each StepSize chunk
RoundTO = -0.5 //-0.5 rounds always to Lower integer, +0.4 rounds always to Higher integer, 0 defaults PRT behaviour
PriceDistance = 7 * pipsize //7 minimun distance from current price
y1 = 0 //reset to 0
y2 = 0 //reset to 0
ProfitPerCent = BasePerCent //reset to desired default value
ELSIF LongOnMarket AND close > (TradePrice + (y1 * pipsize)) THEN //LONG positions
//
// compute the value of the Percentage of profits, if any, to lock in for LONG trades
//
x1 = (close - tradeprice) / pipsize //convert price to pips
IF x1 >= TrailStart THEN // go ahead only if N+ pips
Diff1 = abs(TrailStart - x1) //difference from current profit and TrailStart
Chunks1 = max(0,round((Diff1 / StepSize) + RoundTO)) //number of STEPSIZE chunks
ProfitPerCent = BasePerCent + (BasePerCent * (Chunks1 * PerCentInc)) //compute new size of ProfitPerCent
ProfitPerCent = max(ProfitPerCent[1],min(100,ProfitPerCent)) //make sure ProfitPerCent doess not exceed 100%
y1 = max(x1 * ProfitPerCent, y1) //y1 = % of max profit
ENDIF
ELSIF ShortOnMarket AND close < (TradePrice - (y2 * pipsize)) THEN //SHORT positions
//
// compute the value of the Percentage of profits, if any, to lock in for SHORT trades
//
x2 = (tradeprice - close) / pipsize //convert price to pips
IF x2 >= TrailStart THEN // go ahead only if N+ pips
Diff2 = abs(TrailStart - x2) //difference from current profit and TrailStart
Chunks2 = max(0,round((Diff2 / StepSize) + RoundTO)) //number of STEPSIZE chunks
ProfitPerCent = BasePerCent + (BasePerCent * (Chunks2 * PerCentInc)) //compute new size of ProfitPerCent
ProfitPerCent = max(ProfitPerCent[1],min(100,ProfitPerCent)) //make sure ProfitPerCent doess not exceed 100%
y2 = max(x2 * ProfitPerCent, y2) //y2 = % of max profit
ENDIF
ENDIF
IF y1 THEN //Place pending STOP order when y1 > 0 (LONG positions)
SellPrice = Tradeprice + (y1 * pipsize) //convert pips to price
//
// check the minimun distance between ExitPrice and current price
//
IF abs(close - SellPrice) > PriceDistance THEN
//
// place either a LIMIT or STOP pending order according to current price positioning
//
IF close >= SellPrice THEN
SELL AT SellPrice STOP
ELSE
SELL AT SellPrice LIMIT
ENDIF
ELSE
//
//sell AT MARKET when EXITPRICE does not meet the broker's minimun distance from current price
//
SELL AT Market
ENDIF
ENDIF
IF y2 THEN //Place pending STOP order when y2 > 0 (SHORT positions)
ExitPrice = Tradeprice - (y2 * pipsize) //convert pips to price
//
// check the minimun distance between ExitPrice and current price
//
IF abs(close - ExitPrice) > PriceDistance THEN
//
// place either a LIMIT or STOP pending order according to current price positioning
//
IF close <= ExitPrice THEN
EXITSHORT AT ExitPrice STOP
ELSE
EXITSHORT AT ExitPrice LIMIT
ENDIF
ELSE
//
//ExitShort AT MARKET when EXITPRICE does not meet the broker's minimun distance from current price
//
EXITSHORT AT Market
ENDIF
ENDIF
I’ve been using the optimisation engine on quantreex which seems to work well.
Do strategies created on quantreex work on PRT??
I run each strategy on 4-6 different instruments at once and all with an equal amount of pips on each one.
When you say run do you mean backtest or forward test?
What you mean equal amount of pips? Pips are movement in price, so 4 strategies on 4 instruments cant make the same pips / profit??
When you say “flashed it over DJI TF’s from 10 sec to 4 hours” is there a code to do that simultaneously or do you do that one by one?
Also yes I noticed during back testing DJI was the 4th best performer all month but in Pro Order you can’t do less then 1/pip so with diversifying with 4-6 instruments at all times the DJI has been too expensive to try so far.
I know you can use mini lots with manual trading but pro order does seem to go under 1/pip Is there any way around that?
Flashed it over (imperfect term) … yeah backtest each TF manually … no code or easy way but its only 2 clicks of the mouse anyway. Your code backtested in seconds as I recall (?) hence why I said flashed I guess! 🙂
Yes we can use £0.2 per point / pip on UK spreadbet on DJI for example.
That’s a really interesting test how long do you check the buy and hold period for? So what would’ve happened if you held a month or a fortnight or a day etc?
Buy and hold for as long as the Chart went back … its just a case of lining up the horizontal cross hair at the start and reading price level then doing same at end of chart period and taking lower price from bigger … takes seconds.
then starting back up the next day
I stop all my Auto-Systems every night and start up them up again when I am eating my breakfast!! 🙂
I have yet to find a single System that consistently takes trades in what I consider to be the correct / logical places.
I hope you are doing all your testing / trials on a Demo Account for many months or at least 50 trades, preferable more?
PS
Are you using free Quantreex or are paying the min £75 per month??
For buy and hold you can also add this indicator that Nicolas wrote to the equity chart.
//capital = 10000
mylot = 1
//startdate = 19851125
once firstclose = 0
if date>=startdate then
if firstclose = 0 then
//save the current close once when the comparison start
firstclose = close
endif
//calculate buy and hold with pointvalue and pointsize of the current share
buyandhold = capital+(((((close-firstclose)*pointvalue)*mylot)/pointsize)*stake)
else
//if the displayed date is previous from the startdate, let's draw the buy and hold curve as the capital
buyandhold = capital
endif
RETURN buyandhold coloured(255,128,0)
Newbie type Questions & Answers
This topic contains 45 replies,
has 5 voices, and was last updated by tradetrader101
5 years, 9 months ago.
| Forum: | ProOrder: Automated Strategies & Backtesting |
| Language: | English |
| Started: | 04/09/2020 |
| Status: | Active |
| Attachments: | 6 files |
The information collected on this form is stored in a computer file by ProRealCode to create and access your ProRealCode profile. This data is kept in a secure database for the duration of the member's membership. They will be kept as long as you use our services and will be automatically deleted after 3 years of inactivity. Your personal data is used to create your private profile on ProRealCode. This data is maintained by SAS ProRealCode, 407 rue Freycinet, 59151 Arleux, France. If you subscribe to our newsletters, your email address is provided to our service provider "MailChimp" located in the United States, with whom we have signed a confidentiality agreement. This company is also compliant with the EU/Swiss Privacy Shield, and the GDPR. For any request for correction or deletion concerning your data, you can directly contact the ProRealCode team by email at privacy@prorealcode.com If you would like to lodge a complaint regarding the use of your personal data, you can contact your data protection supervisory authority.