Entry on fib retracement?
Forums › ProRealTime English forum › ProOrder support › Entry on fib retracement?
- This topic has 25 replies, 4 voices, and was last updated 7 years ago by GraHal.
-
-
12/09/2016 at 12:14 AM #18115
Hi, I was wondering if someone could help me with writing how to enter a position on a fib extension.
I am trying to code for price breaking out of a range, and then reaching a high. I have gotten that far, but once price has reached that high, I want to set an order to enter the market at the 62.8% fib retracement of that high.
I was wondering if anyone else has coded fib retracements before?
12/09/2016 at 10:16 AM #18134There is a nice example of Fibonacci extension calculation from a recent high here in this stock screener: Fibonacci 61.8% retracement screener
12/09/2016 at 10:30 AM #18135Hi Nicolas, thanks for the reply!
I was looking at that when I was writing my code, So far I have this:
123456IF Close > hh AND MakeTrade = 1 THENIF TurnDown THENfib = (highest[16](high) - ll) * 0.382Entry = ll + fibENDIFENDIFWhere MakeTrade refers to the time of day, ll is the lowest low of the period I want to measure from and hh is the breakout.
What I’m struggling is setting the order for entry, I thought that by defining Entry as the fib + ll and placing an order there would work but my code completely ignores it?
12/09/2016 at 11:10 AM #1813812/09/2016 at 11:24 AM #18144Hmm I don’t think that is the case, I want to set a between 5pm and 7am the next day, so when I code that I do it by saying
1234IF Time = 070000 THENhh = highest[n](high)ll = lowest[n](low)ENDIFWhen n is the number of bars going back to 5 pm the previous day. Then once that is recorded for that day, I want to check for a breakout between two times later the next day. if price breaks out between these times, wait for a turning point (as in a highest high) and then use that to work out the fib retracement from the previous low.
I know it sounds really complicated to type, but any help would be really appreciated!
I know its quite complicated to type, but any help would be really appreciated!
12/09/2016 at 11:33 AM #1814512/09/2016 at 11:43 AM #18151Ok sure, here it is:
1234567891011121314151617181920212223242526272829DEFPARAM CumulateOrders = FalseDEFPARAM FlatAfter = 214500StartTime = 070000FinalTime = 100000// Set Breakout box for between 5pm and 7amIf Time = 070000 THENhh = highest[n](high)ll = lowest[n](low)ENDIF//Only make trade between 7am and 10amIf Time >= StartTime AND Time <= FinalTime THENMakeTrade = 1ELSEMakeTrade = 0ENDIFIF MakeTrade = 1 AND highest[y](high) > hh THENfib = (highest[y](high) - ll) * 0.382Entry = ll + fibENDIFIF MakeTrade = 1 AND highest[y](high) > hh THENSELLSHORT 1 SHARE AT Entry LIMITENDIFSET TARGET pPROFIT 50SET STOP pLOSS 50Its still a very rough version but its what I have so far, n = number of bars from 5pm to 7am, and y = number of bars from 7 to 10am
It would find the significant turning point (or the closest thing to that) between 7 and 10 and calculate the fib from there. Ultimately I want to code it to work both ways, but for now while I’m still getting to grip with coding I’m just doing the break to the upside.
I was also wondering, since it should only technically make one trade a day if conditions are met, do I have to tell it to restart every day? or will it automatically start doing that at 5pm anyway?
Thanks 🙂
12/09/2016 at 9:30 PM #1819401/20/2017 at 11:58 PM #21926Hi KJ
Did you get any further with this one please? Maybe it slipped through a crack in Nicolas busy schedule? He might catch sight of it again now.
I manual trade using Fib levels and so I’ve run your code on Demo since 11 Dec and results look very promising – see attached. I made a few very minor changes … I’ll put them on here tomorrow.
Thanks
GraHal01/21/2017 at 12:59 PM #21953Here’s my few changes, main change is Buy (Sell in original code??) in Line 25.
Results attached for DAX 5M @ £1 per point.
(Why cant I see ‘Insert PRT Code’ again Mods?)
1234567891011121314151617181920212223242526272829DEFPARAM CumulateOrders = FalseDEFPARAM FlatAfter = 214500StartTime = 065000FinalTime = 113000// Set Breakout box for between 5pm and 7amIf Time = 065000 THENhh = highest[80](high)ll = lowest[80](low)ENDIF//Only make trade between 7am and 10amIf Time >= StartTime AND Time <= FinalTime THENMakeTrade = 1ELSEMakeTrade = 0ENDIFIF MakeTrade = 1 AND highest[20](high) > hh THENfib = (highest[20](high) - ll) * 0.382Entry = ll + fibENDIFIF MakeTrade = 1 AND highest[20](high) > hh AND close > ExponentialAverage[15](close) THENBuy 1 SHARE AT Entry LIMITENDIFSET TARGET pPROFIT 150SET STOP pLOSS 24001/21/2017 at 4:43 PM #2196401/21/2017 at 5:23 PM #21970The text editor of forums have 2 tabs, you’ll find them on its upper right side, choose “Visual” one to get the rich text capabilities and the “insert PRT code” button.
About this topic, I’m sorry, because I’m involved in many ones, this one came out of my head.. Thanks GraHal about the help you give to kg6450. Let him answer to your code fix and see if you were correct about the BUY order instead of the SELLSHORT one.
Results seems decent, did you test any further in the past data?
01/21/2017 at 5:52 PM #21977I tried both tabs, even Visual Tab did not have insert PRT Code available; also same for me a day or two back. No big deal for me, but I didn’t want you / mods thinking I’m causing you work 🙂
I’ve got qty 4 PRT Platforms open (I’m rationalising my 200 Demo Algos! :)) if I can’t see PRT code button again, I’ll close platforms one by one to see if it makes any difference. Maybe this is why I’ve had a few other odd ‘platform scenarios’ this week!?
The results above are over 100,000 units @ 5M as this is the most history I get with IG.
Cheers
Graham01/21/2017 at 6:09 PM #21978If only we could ‘edit out our crap’ 🙂 … I’m mixing up PRT Platform snags and PRC Website snags now … apologies, disregard the 2nd paragraph above please!! I must slow down my brain & fingers, I must slow down my ………. ! haha
GraHal
01/21/2017 at 7:30 PM #21983 -
AuthorPosts
Find exclusive trading pro-tools on