need some insights on my newb system
Forums › ProRealTime English forum › ProOrder support › need some insights on my newb system
- This topic has 23 replies, 6 voices, and was last updated 3 years ago by migelrack.
-
-
03/05/2021 at 11:55 AM #163196
Hello everyone!
iv recently started to learn how to use simpel code and trying to creat some algos based on what i use when im daytrading.
this is one of my scripts (very very simpel) that iv tried on dax 2 min backtesting 200k bars
can i backtest it longer somehow? tryed not to curvefit it but it seems that it cant be helped to curvefit it abit.
rn the stoploss and take profit are the same 1:1 but copied the rolling stopploss from this forum, can i make it better somehow? i wanna minimize the drawdowns even if it draw down the gains (not to much i hope hehe)
here is the code:
my simpel system123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0// Conditions to enter long positionsindicator1 = Momentum[1000](close)c1 = (indicator1 CROSSES OVER 270)IF c1 AND not daysForbiddenEntry THENBUY 1 CONTRACT AT MARKETENDIF// Conditions to exit long positionsindicator2 = Momentum[1000](close)c2 = (indicator2 CROSSES UNDER 0)IF c2 THENSELL AT MARKETENDIF// Stops and targetsSET STOP pLOSS 100SET TARGET pPROFIT 100//%trailing stop functiontrailingPercent = .35stepPercent = .01if onmarket thentrailingstart = tradeprice(1)*(trailingpercent/100) //trailing will start @trailingstart points profittrailingstep = tradeprice(1)*(stepPercent/100) //% step to move the stoplossendif//reset the stoploss valueIF NOT ONMARKET THENnewSL=0ENDIF//manage long positionsIF LONGONMARKET THEN//first move (breakeven)IF newSL=0 AND close-tradeprice(1)>=trailingstart THENnewSL = tradeprice(1)+trailingstepENDIF//next movesIF newSL>0 AND close-newSL>trailingstep THENnewSL = newSL+trailingstepENDIFENDIF//manage short positionsIF SHORTONMARKET THEN//first move (breakeven)IF newSL=0 AND tradeprice(1)-close>=trailingstart THENnewSL = tradeprice(1)-trailingstepENDIF//next movesIF newSL>0 AND newSL-close>trailingstep THENnewSL = newSL-trailingstepENDIFENDIF//stop order to exit the positionsIF newSL>0 THENSELL AT newSL STOPEXITSHORT AT newSL STOPENDIF//************************************************************************03/05/2021 at 3:05 PM #16320403/05/2021 at 3:12 PM #16320703/05/2021 at 3:29 PM #163208Below doesn’t look right?
Substitute DJI Price in and check it out.
123456trailingPercent = .35stepPercent = .01if onmarket thentrailingstart = tradeprice(1)*(trailingpercent/100) //trailing will start @trailingstart points profittrailingstep = tradeprice(1)*(stepPercent/100) //% step to move the stoplossendif03/05/2021 at 7:26 PM #163235Below doesn’t look right?
I checked … it does look right after all! 🙂
03/05/2021 at 10:11 PM #163247im to afraid to curvefit it cus its all i read about hehe,
I agree! 🙂
I try and keep the curve fitting in step with the current curve / market action!
I’m going to see how attached works out on Demo Forward Test next week.
03/06/2021 at 8:43 PM #16332303/07/2021 at 12:04 AM #163330i wanna minimize the drawdowns even if it draw down the gains (not to much i hope hehe)
Well, one way to get lower the draw-down would be to check if the momentum is coming from below and not just going down and below your 270-level and up again. For example 5 periods
1c1b = (indicator1[5] < 270)Of course, this is not a guarantee to avoid the mentioned idea above, and it will make fewer trades and less gain. And also – another variable could mean bigger chance for curve fit. But in the backtest I did (did not optimize the variable, just tested with the 5-period), it cut the drawdown in half.
03/07/2021 at 9:38 AM #163354Mattias – Please be more careful when using the ‘Quote’ facility. You included all your own text within the quote which made your post very difficult to understand. I have edited your post to tidy it up. You have five minutes after pressing submit to delete or edit your posts if they do not look correct. Please double check your future posts and correct any errors before leaving the page.
1 user thanked author for this post.
03/09/2021 at 10:41 AM #163577thx for all your insights! trying them all out. rn i run 10 versions of the system.
i have some questen for one of my other system, rn im building a HF algo (over 300 trades per day) i wanna limit it to the swedish open of omx 09-1730 gmt+1
is this code right for it? cus it doesent seem to work right for me
1234567891011DEFPARAM FLATBEFORE = 090000// Cancel all pending orders and close all positions at the "FLATAFTER" timeDEFPARAM FLATAFTER = 173000// Prevents the system from creating new orders to enter the market or increase position size before the specified timenoEntryBeforeTime = 090000timeEnterBefore = time >= noEntryBeforeTime// Prevents the system from placing new orders to enter the market or increase position size after the specified timenoEntryAfterTime = 173000timeEnterAfter = time < noEntryAfterTime03/09/2021 at 10:56 AM #163582Sounds like all you need is FlatBefore and FlatAfter and not the rest of the code you show above?
03/09/2021 at 11:14 AM #163585Personally I prefer to use something like
1CTime = Time >= 090000 and Time < 173000(with CTime as an entry condition, obviously)
This way new trades can only be opened during market hours, but can stay open after the close.
This also allows you to optimize the Time variables, which you can’t do when using DEFPARAM FLATBEFORE / FLATAFTER
1 user thanked author for this post.
03/09/2021 at 12:30 PM #163594thx grahal and nonetheless!
nonetheless code was what i was after and it worked great. the only problem i have left now is that the code is very sensetive so sometimes the broker dont allow some of the orders so it turns of the bot, i dont wanna change the code so is there any adds that prevent that from happening
03/09/2021 at 12:55 PM #163598What kind of rejection are you getting?
(go Trading > Order List > Cancelled/Rejected then click in the Status column)
03/09/2021 at 1:24 PM #163607 -
AuthorPosts
Find exclusive trading pro-tools on