ProRealCode - Trading & Coding with ProRealTime™
hello Philstrading or Grahal, can you make it work for eur/usd mini or gold? low spread for me….in all case thank you!
This is going to bed till weekend now. final punt for the day is to increase the c21m to 16 or 17, change the trail to 28 with a 7 step and lose all the stopouts… less trades but no stopouts in 6 months. It has some significant drawdowns during trade mind but retains good gains and no losses.,
Results are swings and roundabouts, but for me the same return with no stopouts is preferable, albeit you can increase the return with a dropout, lower value accounts can manage better.
For me looking at this you can risk 20p per pip, risk 6% on account and gain about 80% a year with 20p per pip per £1K…
Risking 1% of account gives abut 26% I assume, and 2% about 53% per £1K but with no stopouts in last 6 mnths being risk free it could soon be built up without risking capital….
// Main code : Grahal 1 min test code timed
//-------------------------------------------------------------------------
Defparam cumulateorders = false
td1 = 1 AND OpenDayOfWeek = 1 AND OpenTime >= 070000 AND OpenTime <= 205500 //Monday
td2 = 1 AND OpenDayOfWeek = 2 AND OpenTime >= 070000 AND OpenTime <= 205500 //Tuesday
td3 = 1 AND OpenDayOfWeek = 3 AND OpenTime >= 070000 AND OpenTime <= 205500 //Wednesday
td4 = 1 AND OpenDayOfWeek = 4 AND OpenTime >= 070000 AND OpenTime <= 205500 //Thursday
td5 = 1 AND OpenDayOfWeek = 5 AND OpenTime >= 070000 AND OpenTime <= 205500 //Friday
tdCond = td1 OR td2 OR td3 OR td4 OR td5
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
// Code principal : CANDLE
//-------------------------------------------------------------------------
n = 1
timeframe(15 minute,updateonclose)
c160m = open > open[1] and close > close[1] and close > open
timeframe(1 minute,updateonclose)
c11m = open > open[1] and close > close[1]
c21m = abs(close-open) >=16
c31m = abs(close[1]-open[1])
c41m = c31m > c21m
timeframe(default)
c1def = open > open[1] and close > close[1]
c2def = abs(close-open) >= 1
IF not longonmarket and c1def and c11m and c21m and c41m and c2def and c1def and c160m and Close crosses over Supertrend[12,4] and tdcond then
BUY N contracts at market
set stop ploss 300
ENDIF
//if Summation[A29](Open - Close) > B29 then
//sell at market
//endif
//************************************************************************
//trailing stop function
trailingstart = 28 //A35 //19 //trailing will start @trailinstart points profit
trailingstep = 7 //A36 // 7 //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
hello Philstrading or Grahal, can you make it work for eur/usd mini or gold? low spread for me….in all case thank you!
Your risk profile is paramount when deciding on strategy. What sort of risk profile do u have i.e max you wan tto risk stopin gout as that can vary from person to person based on emotional influences as well as capital. It can effect how a strategy is structured IMHO…
@Philstrading I note that you have changed Makside to GraHal on your System titles.
It’s only right that we keep / give Makside the credit in the title.
i’m in the process of reworking the strategy with half pivots points. It looks promising.
for example, between both daily pivot, from a certain percentage above pivot (different value following the pivots PP,Rx,Sx), in bullish/bearish profile, we are sure to get few points when price crosses over/under the half pivot.
i’m coming back as soon as my cash machine works 😉
here’s a try on eurusd
//-------------------------------------------------------------------------
// Main code : Makside DJI M1 v1
//-------------------------------------------------------------------------
// Adjusted to EURUSD , 0,9 pip spread, 1m, v1p
//-------------------------------------------------------------------------
// Code principal : CANDLE
//-------------------------------------------------------------------------
defparam cumulateorders = false
defparam preloadbars = 2000
once tradetype = 1 //1LS 2L 3S
once reenter = 0 //1ON
once positionperftype = 1 //0LG 1L 2G
once positionperfvalue = 0.05 //%
once positionsize = 1
once stochasticrsi = 1
once closetime=225500
once sl=1
once pt=0.5
once overnightposition = 1
once weekendposition = 0
ctime = 1 //hour>=8 and hour<22
timeframe(15 minute,updateonclose)
c160m = open > open[1] and close > close[1] and close > open
timeframe(default)
c11m = open > open[1] and close > close[1]
c21m = abs(close[0]-open[0])>(close/10000)*1.4
c31m = abs(close[1]-open[1])
c41m = c31m > (c21m/10000)
c3def = Supertrend[6,1]
condbuy = c11m and c21m and c41m and c160m
condbuy = condbuy and close > c3def
//Stochastic RSI | indicator
if stochasticrsi then
lengthRSI = 4 //RSI period
lengthStoch = 6 //Stochastic period
smoothK = 2 //Smooth signal of stochastic RSI
smoothD = 6 //Smooth signal of smoothed stochastic RSI
myRSI = RSI[lengthRSI](totalprice)
MinRSI = lowest[lengthStoch](myrsi)
MaxRSI = highest[lengthStoch](myrsi)
StochRSI = (myRSI-MinRSI) / (MaxRSI-MinRSI)
K = average[smoothK](stochrsi)*100
D = average[smoothD](K)
c13 = K>D
condbuy = condbuy and c13 and not c13[1]
endif
condsell=0
// entry criteria
if ctime then
if (tradetype=1 or tradetype=2) then
if condbuy and not longonmarket then
buy positionsize contract at market
if tradetype=1 then
set stop %loss sl
set target %profit pt
elsif tradetype=2 then
set stop %loss sl
set target %profit pt
endif
endif
endif
if (tradetype=1 or tradetype=3) then
if condsell and not shortonmarket then
sellshort positionsize contract at market
if tradetype=1 then
set stop %loss sl
set target %profit pt
elsif tradetype=3 then
set stop %loss sl
set target %profit pt
endif
endif
endif
if reenter then
if positionperftype=1 then
positionperformance=positionperf(0)*100<-positionperfvalue
elsif positionperftype=2 then
positionperformance=positionperf(0)*100>positionperfvalue
else
positionperformance=((positionperf(0)*100)<-positionperfvalue or (positionperf(0)*100)>positionperfvalue)
endif
if (tradetype=1 or tradetype=2) then
if condbuy and longonmarket and positionperformance then
sell at market
endif
if condbuy[1] and not longonmarket then
buy positionsize contract at market
if tradetype=1 then
set stop %loss sl
set target %profit pt
elsif tradetype=2 then
set stop %loss sl
set target %profit pt
endif
endif
endif
if (tradetype=1 or tradetype=3) then
if condsell and shortonmarket and positionperformance then
exitshort at market
endif
if condsell[1] and not shortonmarket then
sellshort positionsize contract at market
if tradetype=1 then
set stop %loss sl
set target %profit pt
elsif tradetype=3 then
set stop %loss sl
set target %profit pt
endif
endif
endif
endif
else
if longonmarket and condsell then
//sell at market
endif
if shortonmarket and condbuy then
//exitshort at market
endif
endif
/// trailing stop percentage
once trailingstoptype=1
if trailingstoptype then
once trailingpercent = 0.165
once steppercent = (trailingpercent/10)*1
if onmarket then
trailingstart = tradeprice(1)*(trailingpercent/100)
trailingstep = tradeprice(1)*(steppercent/100)
endif
if not onmarket or ((longonmarket and shortonmarket[1]) or (longonmarket[1] and shortonmarket)) then
newsl=0
endif
if longonmarket then
if newsl=0 and low-tradeprice(1)>=trailingstart then
newsl = tradeprice(1)+trailingstep
endif
if newsl>0 and low-newsl>trailingstep then
newsl = newsl+trailingstep
endif
endif
if shortonmarket then
if newsl=0 and tradeprice(1)-high>=trailingstart then
newsl = tradeprice(1)-trailingstep
endif
if newsl>0 and newsl-high>trailingstep then
newsl = newsl-trailingstep
endif
endif
if longonmarket then
if newsl>0 then
sell at newsl stop
endif
if newsl>0 then
if low crosses under newsl then
sell at market
endif
endif
endif
if shortonmarket then
if newsl>0 then
exitshort at newsl stop
endif
if newsl>0 then
if high crosses over newsl then
exitshort at market
endif
endif
endif
endif
if not overnightposition then
if time>=closetime then
sell at market
exitshort at market
endif
endif
if not weekendposition then
if (dayofweek=5 and time>=closetime) then
exitshort at market
sell at market
endif
endif
it’s created on 100k bars which look oke, but 200k bars it not good.
@Philstrading I note that you have changed Makside to GraHal on your System titles.
It’s only right that we keep / give Makside the credit in the title.
Fair point, I think it was because the itf file I thought came from you, so its just up on my system for reference, but yeh sure, I’ll be sure to retain the originator in future…
Just a brief observation of TP v Trail.
A TP of 28 gives a more averaged monthly/weekly return. Depends on preferences, TP here was set to 28 the original trail start. Something to look at for more averaged monthly /weekly returns rather than rely on disproportionate runs…
Pics attached
Noticed name not changed there, I’ll do now..
here’s a try on eurusd
it’s created on 100k bars which look oke, but 200k bars it not good.
€/$ had a long ride down and it found only in the last few months the way to go up. And this stragedy is only for long trades profitable, so in short trends it works not fine. Is it possible to create a version for short?
here’s both in one code
//-------------------------------------------------------------------------
// Main code : Makside DJI M1 v1
//-------------------------------------------------------------------------
// Adjusted to EURUSD , 0,9 pip spread, 1m, v2p
//-------------------------------------------------------------------------
// Code principal : CANDLE
//-------------------------------------------------------------------------
defparam cumulateorders = false
defparam preloadbars = 2000
once tradetype = 2 //1LS 2L 3S
once reenter = 1 //1ON
once positionperftype = 1 //0LG 1L 2G
once positionperfvalue = 0.05 //%
once positionsize = 1
once stochasticrsi = 1
once st = 1
once closetime=225500
once sl=1
once pt=0.5
once overnightposition = 1
once weekendposition = 0
ctime = 1 //hour>=8 and hour<22
timeframe(15 minute,updateonclose)
//long
c160m = open > open[1] and close > close[1] and close > open
//short
c160s = open < open[1] and close < close[1] and close < open
timeframe(default)
//long
c11m = open > open[1] and close > close[1]
c21m = abs(close[0]-open[0])>(close/10000)*2
c31m = abs(close[1]-open[1])
c41m = c31m > (c21m/10000)
//short
c11s = open < open[1] and close < close[1]
c21s = abs(close[0]-open[0])>(close/10000)*1.4
c31s = abs(close[1]-open[1])
c41s = c31s > (c21s/10000)
condbuy = c11m and c21m and c41m and c160m
condsell= c11s and c21s and c41s and c160s
if st=1 then
c3def = Supertrend[2,12]
condbuy = condbuy and close > c3def
condsell= condsell and close < c3def
endif
//Stochastic RSI | indicator
if stochasticrsi then
lengthRSI = 2 //RSI period
lengthStoch = 4 //Stochastic period
smoothK = 6 //Smooth signal of stochastic RSI
smoothD = 6 //Smooth signal of smoothed stochastic RSI
myRSI = RSI[lengthRSI](totalprice)
MinRSI = lowest[lengthStoch](myrsi)
MaxRSI = highest[lengthStoch](myrsi)
StochRSI = (myRSI-MinRSI) / (MaxRSI-MinRSI)
K = average[smoothK](stochrsi)*100
D = average[smoothD](K)
c13 = K>D
c14 = K<D
condbuy = condbuy and c13 and not c13[1]
condsell = condsell and c14 and not c14[1]
endif
// entry criteria
if ctime then
if (tradetype=1 or tradetype=2) then
if condbuy and not longonmarket then
buy positionsize contract at market
if tradetype=1 then
set stop %loss sl
set target %profit pt
elsif tradetype=2 then
set stop %loss sl
set target %profit pt
endif
endif
endif
if (tradetype=1 or tradetype=3) then
if condsell and not shortonmarket then
sellshort positionsize contract at market
if tradetype=1 then
set stop %loss sl
set target %profit pt
elsif tradetype=3 then
set stop %loss sl
set target %profit pt
endif
endif
endif
if reenter then
if positionperftype=1 then
positionperformance=positionperf(0)*100<-positionperfvalue
elsif positionperftype=2 then
positionperformance=positionperf(0)*100>positionperfvalue
else
positionperformance=((positionperf(0)*100)<-positionperfvalue or (positionperf(0)*100)>positionperfvalue)
endif
if (tradetype=1 or tradetype=2) then
if condbuy and longonmarket and positionperformance then
sell at market
endif
if condbuy[1] and not longonmarket then
buy positionsize contract at market
if tradetype=1 then
set stop %loss sl
set target %profit pt
elsif tradetype=2 then
set stop %loss sl
set target %profit pt
endif
endif
endif
if (tradetype=1 or tradetype=3) then
if condsell and shortonmarket and positionperformance then
exitshort at market
endif
if condsell[1] and not shortonmarket then
sellshort positionsize contract at market
if tradetype=1 then
set stop %loss sl
set target %profit pt
elsif tradetype=3 then
set stop %loss sl
set target %profit pt
endif
endif
endif
endif
else
if longonmarket and condsell then
//sell at market
endif
if shortonmarket and condbuy then
//exitshort at market
endif
endif
/// trailing stop percentage
once trailingstoptype=1
if trailingstoptype then
once trailingpercent = 0.165
once steppercent = (trailingpercent/10)*1
if onmarket then
trailingstart = tradeprice(1)*(trailingpercent/100)
trailingstep = tradeprice(1)*(steppercent/100)
endif
if not onmarket or ((longonmarket and shortonmarket[1]) or (longonmarket[1] and shortonmarket)) then
newsl=0
endif
if longonmarket then
if newsl=0 and low-tradeprice(1)>=trailingstart then
newsl = tradeprice(1)+trailingstep
endif
if newsl>0 and low-newsl>trailingstep then
newsl = newsl+trailingstep
endif
endif
if shortonmarket then
if newsl=0 and tradeprice(1)-high>=trailingstart then
newsl = tradeprice(1)-trailingstep
endif
if newsl>0 and newsl-high>trailingstep then
newsl = newsl-trailingstep
endif
endif
if longonmarket then
if newsl>0 then
sell at newsl stop
endif
if newsl>0 then
if low crosses under newsl then
sell at market
endif
endif
endif
if shortonmarket then
if newsl>0 then
exitshort at newsl stop
endif
if newsl>0 then
if high crosses over newsl then
exitshort at market
endif
endif
endif
endif
if not overnightposition then
if time>=closetime then
sell at market
exitshort at market
endif
endif
if not weekendposition then
if (dayofweek=5 and time>=closetime) then
exitshort at market
sell at market
endif
endif
Paul, your positionsize in your result seems to be 10 and not only 1, which is in yr screenshot shown. My result is a little bit smaller. 😀
Yeah on eurusd mini the results don’t look too impressive. I’am putting this on hold atm.
I find programs need a reasonable run for robustness, I’d probably say 3 months as in my experience an unproven program can do well in a month and lose everything the next month even if OK in backtesting, so 3 months I’m currently gauging as a rule stick. I’ll put up how its doing more frequently though, probably at end of month.
Shorts I currently found only worked with a lot of restriciton, haven’t put up the eurusd one yet though.. I put one up live on minimal trade which is well within my 1% tolerance for a few drops using th e100% gain version with no losses.. Due to program and server anomalies I also usually only start with partial risk an dincrease once profits allow a buffer, the nif it loses and proves unfruitful its easy to use discretionary trading to buffer lossses of unproven programs..
So I’ll put up monthly anyway…
Currently the 1 minutes code ran on the 1second timeframe (the chaos one) is well ahead, followed by the 1second one however the chaosprogram is currently trading so see how it pans out…. Monthly I think a reasonable update over a 3 month period
Shorts I currently found only worked with a lot of restriciton
Hello Phil!
Very interesting to follow the progress of this algo!
Do you mean that you have made a short version of this? It would be most appreciated if you could post it here! Unfortunatly i´m not capable of doing it myself (yet).
Re Shorts
I find the losses in the program a bit excessive and taking profit at 28 can yield as much as the runs with losses but yield no losses with a TP and altered parameters. The short version for the same code exactly was a bit excessive with losses, I think I altered some parameters and filters which yielded few but successful shorts with no losses. New coding for weekends really unless I need to side-track myself..
The no losses was the 1 minute version with a c21m of >=16 or 17 with a TP of 28 – stoploss as normal. Time limit of 0700 to 2055 if I recall correctly. I’ve got that on a minimal trade live with fractional percentage stoploss so iget some pennies if it runs ok an dcan start to build up the risk free trading..
Candlestick Scalper 1s discussion
This topic contains 171 replies,
has 16 voices, and was last updated by CMM
3 years, 6 months ago.
| Forum: | ProOrder: Automated Strategies & Backtesting |
| Language: | English |
| Started: | 04/07/2020 |
| Status: | Active |
| Attachments: | 62 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.