Help with basic strategy
Forums › ProRealTime English forum › General trading discussions › Help with basic strategy
- This topic has 7 replies, 3 voices, and was last updated 7 years ago by GraHal.
-
-
04/12/2017 at 6:25 AM #31813
Hi,
Was hoping someone could provide me with some code for a very simple strategy. I cant quite get the code to do what i want it to. below are the parameters;
Trading on the major FX pairs (usd/jpy, eur/usd, gbp/usd etc)
Daily bars
If previous days bar was an up bar (open < close) then I want to sell on the previous days low
If previous days bar was a down bar (open > close) then i want to buy on the previous days high
stop will be 10 points
limit/target will be 40
If the limit or stop hasnt been hit during the trading day I want to exit on the close of that same day.
Only want to trade from monday to friday, wary that there is a sunday bar on the FX due to it opening on sunday for a lot of the world (Im in Australia, opens 7am Monday)
Ideally would like the backtesting to ignore the sunday bar
Thanks for the help with this.
04/12/2017 at 5:05 PM #31872Please find below a rough code that should work for your query. I didn’t test it, please make your own and give feedbacks, thank you.
123456789101112131415161718192021bull = dclose(0)>dopen(0)bear = dclose(0)<dopen(0)if day<>day[1]=0 thenalreadytraded=0endifif dayofweek>0 thenif not onmarket and bull and alreadytraded=0 thensellshort 1 contract at dlow(0)alreadytraded=1endifif not onmarket and bear and alreadytraded=0 thenbuy 1 contract at dhigh(0)alreadytraded=1endifendifset stop ploss 10set target pprofit 4004/12/2017 at 9:17 PM #31890I played around with above and got attached results on DAX 100,000 bars @ 5 Min (cos I like 5 mins TF 🙂
Had to change code at Line 5, 10 and 15 to get it going … rightly or wrongly?
123456789101112131415161718192021bull = dclose(0)>dopen(0)bear = dclose(0)<dopen(0)if day<>day[1] thenalreadytraded=0endifif dayofweek>0 thenif not onmarket and bull and alreadytraded=0 thensellshort 1 contract at dlow(0)stopalreadytraded=1endifif not onmarket and bear and alreadytraded=0 thenbuy 1 contract at dhigh(0)limitalreadytraded=1endifendifset stop ploss 100set target pprofit 80GraHal
04/12/2017 at 9:33 PM #3189504/12/2017 at 9:47 PM #3189604/13/2017 at 9:10 AM #3191604/13/2017 at 11:18 AM #31924Nice one Nicolas! Shut phone and brain off, sit in sun, get whiskey … you’re on holiday??
WF Results for 1000 Daily bars,
Daily Code:
123456789101112131415161718192021222324//https://www.prorealcode.com/topic/help-with-basic-strategy///GH DCloseDOpen DAX 1Dbull = dclose(0)>dopen(0)bear = dclose(0)<dopen(0)if day<>day[1] thenalreadytraded=0endifif dayofweek>0 thenif not onmarket and bull and alreadytraded=0 thensellshort 1 contract at dlow(0)stopalreadytraded=1endifif not onmarket and bear and alreadytraded=0 thenbuy 1 contract at dhigh(0)stopalreadytraded=1endifendifset stop ploss 160set target pprofit 780GraHal
04/13/2017 at 12:04 PM #31928Attached overall result for above code in tick-tick mode with no WF.
Any ideas to increase % of winning trades?
I can’t BT more than 1000 x Daily due to that annoying error message … one or more candles are not available … etc.
GraHal
-
AuthorPosts
Find exclusive trading pro-tools on