ProRealCode - Trading & Coding with ProRealTime™
Shorts again
I think the shorts version was the same code reversed with a supertrend of 12,3 it restricted th elongs as well but if you just write it for the shorts and keep longs the same likely it will work better, only a few trades mind but no losses… I’ll look to refine that on weekends, so maybe something popping up after I’ve had time to peruse it by Monday..
Here’s a mod for increasing and decreasing the trade amount based on profit and losses, comments welcomed. I put up the code for the trade amount managment here:
https://www.prorealcode.com/topic/increase-and-decrease-trade-amount-with-profit-and-loss/
And here is the code mod for longs with trade amount management and absolute loss shutdown (think I go tthat bit correct) let me know if not.
// Main code : Makside 1 min test code timed modified by Philip Penny https://philstrading.uk
//-------------------------------------------------------------------------
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
//-------------------------------------------------------------------------
Mystartamount = 1 //your risk tolerance start amount based on stoploss
SL=300// your stoploss
tp=28 //your take profit level
mydiv=2 //factor by which ot increase the trade amount by to limit stoploss but increase it with profits safely which will depend on stopout factors
Myabsloss=0
x=strategyprofit/(SL*mystartamount)
If strategyprofit<=(SL*mystartamount) then
Myamount=mystartamount
Endif
If x>=2 then //x=the factor to increase risk calculation by when the profit has reached the stoploss multiple of x
myamount=(x*((mystartamount/mydiv)))//(x*mystartamount/2) is exponential growth and keeps stoploss at less than profits when profits above SL*2.
endif
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 Myamount contracts at market
set stop ploss SL
Set target pprofit tp
ENDIF
If strategyprofit<myabsloss then
quit
endif
Just to note for a £1 value I put -150 for absloss but can be any tolerance and the timezone is for UK
Hello,
could we imagine a short version on the 1s system?
everythink is possible… we should already make a long version that works… currently, it’s not the case.. few trades (one or two trades) can lose all gains
Idea is to have a cash machine with some small gains quickly and very little on the market. It was the first idea of this bot
I’m currently working on another version of 1s system based on half pivots
everythink is possible… we should already make a long version that works… currently, it’s not the case.. few trades (one or two trades) can lose all gains
Idea is to have a cash machine with some small gains quickly and very little on the market. It was the first idea of this bot
I’m currently working on another version of 1s system based on half pivots
I’m currently running a number of combinations of filters but will need around 3 months at least to test those with any degree of usefulness at all.. I’ll post them in an excell file or something each month. Below is a code I’m runing live with minimal risk of £100 or so. whilst it doesnt make a fortune if you risk manage the code for the max loss you want to tolerate, so if you have £20K say you could risk £200 or £400 for a 1 or 2 % overall risk of the program, that would be “myamount=0.66 or 1.32” then you can put your quit amount in accordingly. The code below has a 100% result over 7 months or so, data is limiting at the moment, So I’ve stuck it up live with an overall risk of £100 fo rth eprogram in total, and the amount traded will increase once the profit is sufficient and then reset itself to its start amount. Yes this could stop you out more, but then the risk is reduced again. Based on the 100% gains this did as well as the orignal trail give or take, and simply has a TP of 28.. Currently the others are doing OK for at least 2 of them, however the loger term picture may be different as you say due to the risk management of 300 pips being excessive if stopped out. If you get some good programs making smaller amounts and have more of them, your yearly profit will likely increase..
3 posts above I put up an attachment of the backtest – Currently its traded twice in a week, so if it does OK I will likely increase overallrisk to £200 once up to £100 profit and that will increase duration of the risk but double the profits and then just leave run and see how it goes. Have that live at the mo as its risk managed and a marginal amount for me.
Hope that helps
// Main code : Makside 1 min test code timed modified by Philip Penny https://philstrading.uk
//-------------------------------------------------------------------------
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
//-------------------------------------------------------------------------
Mystartamount = 0.33 //your risk tolerance start amount based on stoploss
SL=300// your stoploss
tp=28 //your take profit level
mydiv=2 //factor by which ot increase the trade amount by to limit stoploss but increase it with profits safely which will depend on stopout factors
Myabsloss=-99
x=strategyprofit/(SL*mystartamount)
If strategyprofit<=(SL*mystartamount) then
Myamount=mystartamount
Endif
If x>=2 then //x=the factor to increase risk calculation by when the profit has reached the stoploss multiple of x
myamount=(x*((mystartamount/mydiv)))//(x*mystartamount/2) is exponential growth and keeps stoploss at less than profits when profits above SL*2.
endif
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 Myamount contracts at market
set stop ploss SL
Set target pprofit tp
ENDIF
If strategyprofit<myabsloss then
quit
endif
you could do the same for 1s version? I’m not good enough to code it correctly…thanks
No the 1 second version cant be backtested because of data limitation, so you don’t know its reliability without forward testing on demo. So minimum of 3 months testing, probably have better idea after 6 months of testing.. Sometimes you just gotta play the long game…
We need to get the Shorts working without reducing profit on Longs??
Anybody done any work on a Short Version of this Algo please?
I’ll have another look on weekend, original version was with excessive losses, I’ll have to backtest on minute only due to data though, I recall I had a brief look and whils tit remained 100% I think it took all traades out bar 3.. hmm.. I just reversed the coding for hsorts I think found it with excessive losses and started looking at filters, to reduce liklihood of losses..
Maybe look at my reversal code, may have got it wrong, have to dig it out.. Haven’t been back to it to be honest.. here the code is reversed I think, and the supertrend values changes, tweaking them can amend losses, but I haven’t looked at this enough yet and this is just for the reversed code to look at filters to reduce liklihood of losing trades..
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 = 0.33
timeframe(15 minute,updateonclose)
c160m = open > open[1] and close > close[1] and close > open
//short
c160b = 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
//short
c11b = open < open[1] and close < close[1]
c21b = abs(open-close) >= 2
c31b = abs(open[1]-close[1])
c41b = c31b < c21b
timeframe(default)
c1def = open > open[1] and close > close[1]
c2def = abs(close-open) >= 1
//short
c1defb = open < open[1] and close < close[1]
c2defb = abs(open-close) >= 1
IF not longonmarket and c1def and c11m and c21m and c41m and c2def and c1def and c160m and Close crosses over Supertrend[12,3] and tdcond then
BUY N contracts at market
set stop ploss 300
ENDIF
//short
IF not shortonmarket and c1defb and c11b and c21b and c41b and c2defb and c1defb and c160b and Close crosses under Supertrend[12,3] and tdcond then
sellshort N contracts at market
set stop ploss 300
ENDIF
tp=28
Set target pprofit tp
You will see on th eattachment that my chaos addition is soaring ahead, those 2 are both teh 1 minute, but the one doing well is ran on the 1 second chart adding some chaos into the mix cos the program reacts differently when ran on LTFs believe it or not… so Chaos works.. 🙂 maybe cos the programmers working against you cant foretell it.. hmmm. who knows
Just added that out of interest really.. thats the original 1 minute code ran on a 1 second chart, they both the same code, the 1 second code nowhere near that..
So not much changed, but when I was looking at a simple way to get rid of losses I noted that changing the c21b to 5 and changing supertrend to 12,2 changed the in-trade drawdown characteristics, you could use something like 10 and 12,3 for the same amount of trades but drawdown was significantly more – in essence it meant the trades taken had reduced drawdown and removed drawdown to around only 1/4 risk max and mainly minimal with the code here, so essentially its entering on direction is improved greatly. Only 2 of the 7 trades drew down at all really. I may take a peak at this for longs as it goes in relation to drawdown in-trade, though the longs doing ok, I’ve added code on my longs to start at 0.5% risk and progress to 1% then 2% risk ongoing once the profits acrue sufficiently and doing that in 3 increments of 0.5%, 1% and 2% risk accordingly, that way the program will risk manage itself and I’ve put a quit level of 1% loss to review if failing. So the shorts here are not many, an average of a little over 1 a month, but only trading in 3 of the 6 months I can currently backtest :- oh how I yearn for that extra data that’s forthcoming!!
I’m tempted to stick it in the long code, but think due to the minimal amount of trades I’ll have to test this longer unless I can do for a couple of years, which may be possible this year some time, it won’t be going live short at any time soon due to my risk management practices.
On the basis of the code criteria for entry, the only way to modify further would change the code to a different program probably, though I am monitoring how the volume effects it.. but as I said probably do this more comprehensively once the data is available which should allow a 2 year backtest once it comes – on the 1 minute chart.. So if that proves to have good results I’ll probably stick it up live once twekaked and there’s more substantive data.
Forward testing is continuing but I think further refinement is now limited until data arrival – from my perspective anyway, but I’ll certainly rekindle it the minute I get the data. The longs are already live for me with my amended code.
Hope that helps
// Main code : Makside 1 min test code timed shorts only modified by Philip Penny https://philtrading.uk
//-------------------------------------------------------------------------
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.33
//timeframe(15 minute,updateonclose)
//c160m = open > open[1] and close > close[1] and close > open
//short
c160b = 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
//short
c11b = open < open[1] and close < close[1]
c21b = abs(open-close) >= 5
c31b = abs(open[1]-close[1])
c41b = c31b < c21b
timeframe(default)
//c1def = open > open[1] and close > close[1]
//c2def = abs(close-open) >= 1
//short
c1defb = open < open[1] and close < close[1]
c2defb = abs(open-close) >= 1
//IF not longonmarket and c1def and c11m and c21m and c41m and c2def and c1def and c160m and Close crosses over Supertrend[12,3] and tdcond then
//BUY N contracts at market
//set stop ploss 300
//ENDIF
//short
IF not shortonmarket and c1defb and c11b and c21b and c41b and c2defb and c1defb and c160b and Close crosses under Supertrend[12,2] and tdcond then
sellshort N contracts at market
set stop ploss 300
ENDIF
tp=28
Set target pprofit tp
oh #i made an error there in the code timeframe..
Looking at the code, surely there a few lines that (IMO) are preventing more profitable trades?
Do we really want C41m = 1 > 0 (or is it -1 for boolean logic??)?
//c11m = open > open[1] and close > close[1]
//c21m = abs(close-open) >= 16
//c31m = abs(close[1]-open[1])
//c41m = c31m > c21m
Also substitute values for Close and Open for Longs and Shorts and you will see that we don’t need the abs(…)??
Using, for example, abs(close-open) >= 16 could derive from price action where Close -Open >= – / minus 16 and yet with abs( …) the absolute value of 16 ( – / minus ignored) would be used … is that what we want??
Just a few thoughts anyway.
Hope that make sense, wife calling me to go for a walk now! 🙂
That’s interesting.
So 1 minute all timeframes with same code improves the program, no 15 minutes timeframe improves results significantly on the 1 minuteprogram.
On the longs it basically trebled profits removing 15 mins whilst increasing trades and went to 1 stopout in 86 trades, so I’ll look at that again later..
On th eshorts it goes from 1 trade to 7.
That was with my trade amount management in mind, so more trades increased the profit more quickly, however program would have succeeded with the 1% risk tolerance for quit on th elongs with oly one stopout.
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.