Strange buy level and Stop loss doesn't work
Forums › ProRealTime English forum › ProOrder support › Strange buy level and Stop loss doesn't work
- This topic has 3 replies, 2 voices, and was last updated 5 years ago by
teapot2002.
-
-
04/23/2020 at 6:56 PM #127675
Please could you help me with this? I’ve attached a screenshot that shows two things that I don’t understand. Here is the code:
Buy after a Heikin Ashi dojo candle and set a stop loss1234567891011121314151617181920212223242526272829303132333435363738394041424344// HB Doji trade 1hr// Enter on break after a Doji signal. Stop currently is trailing, optimised to 198 with Doji definitions (in the indicator) 14.5 long and 14.8 short. Currently 35.1%// Definition of code parametersDEFPARAM CumulateOrders = False // Cumulating positions deactivated// Prevents the system from creating new orders to enter the market or increase position size before the specified timenoEntryBeforeTime = 050000timeEnterBefore = time >= noEntryBeforeTime// Prevents the system from placing new orders to enter the market or increase position size after the specified timenoEntryAfterTime = 163000timeEnterAfter = time < noEntryAfterTime// Prevents the system from placing new orders on specified days of the weekdaysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0if barindex>1 thenhaclose=(open+close+low+high)/4haopen=(haopen[1]+haclose[1])/2xHigh = Max(haOpen, haClose)//xLow = Min(haOpen, haClose)hahigh = Max(High,xHigh)//halow = Min(Low,xLow)endif// Conditions to enter long positionsindicator1 = CALL "Heikin Ashi doji entry"[9] //[14.5]dojiL = (indicator1 >= 0.5)If hahigh[1]<hahigh[2] and hahigh[2]<hahigh[3] THENdowntrend = 1ENDIF// if you're in a downtrend and get a doji, and break the close of that doji, it's a long entry.IF dojiL AND downtrend AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry THENBUY 1 PERPOINT AT hahigh[1] STOPENDIFhsl = haopen[1]SET STOP LOSS hslgraph hslgraph dojiLI use an indicator, shown in the screenshot, to indicate a doji bar.
Then I enter long if we have been in downtrend, the theory being that after a downtrend, a doji signals a change of direction.
The first thing that I don’t understand is why the buy is at 5108, when I’ve asked it to buy at hahigh, which is my calculation of the heikin ashi high. 5108 is the open of that candle, not even the candlestick high.
The second thing is why a stop is never placed. This trade is never closed, despite my setting a stop loss at hsl, which is shown in the screenshot as 4925.
I’d very much appreciate your help with this – it has been driving me mad all day.
Many thanks.
04/23/2020 at 7:28 PM #127681The first thing that I don’t understand is why the buy is at 5108, when I’ve asked it to buy at hahigh, which is my calculation of the heikin ashi high. 5108 is the open of that candle, not even the candlestick high.
it’s because you are using STOP, while you should use a LIMIT pending order, since your entry price (hahigh[1]) is lower than the current one
The second thing is why a stop is never placed. This trade is never closed, despite my setting a stop loss at hsl, which is shown in the screenshot as 4925.
because you did set such a huge SL, over 5000 pips/points; that’s because LOSS requires a difference in price (such as high – low[1]), while you used a price (haopen[1])
I’d very much appreciate your help with this – it has been driving me mad all day.
Many thanks.
04/24/2020 at 10:24 AM #127745Hi Roberto – many thanks for your reply.
Perhaps there’s something even more fundamental that I don’t understand, which is when things take place.
I’ve changed my doji indicator so that it takes the trend into account, signalling 1 for a downtrend plus doji, signalling the start of an uptrend, and vice versa. This happens at 06:00 in the attached screenshot. I think that this signal is returned at 05:59:59, so is active 06:00, so that a trade should enter at during the 06:00 bar. However, it doesn’t.
Could you please explain the mistake I’m making here?
Again, many thanks.
This is the new code:
Set an order long after a downtrend and a doji12345678910111213141516171819202122232425262728293031323334353637383940// HB Doji trade 1hr// Enter on break after a Doji signal.// Definition of code parametersDEFPARAM CumulateOrders = False // Cumulating positions deactivated// Prevents the system from creating new orders to enter the market or increase position size before the specified timenoEntryBeforeTime = 050000timeEnterBefore = time >= noEntryBeforeTime// Prevents the system from placing new orders to enter the market or increase position size after the specified timenoEntryAfterTime = 163000timeEnterAfter = time < noEntryAfterTime// Prevents the system from placing new orders on specified days of the weekdaysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0if barindex>1 then // Don't do this on the first bar of the timeframehaclose=(open+close+low+high)/4haopen=(haopen[1]+haclose[1])/2xHigh = Max(haOpen, haClose)//xLow = Min(haOpen, haClose)hahigh = Max(High,xHigh)//halow = Min(Low,xLow)endif// Conditions to enter long positionsindicator1 = CALL "Heikin Ashi doji entry"[9] //[14.5]dojiL = (indicator1 = 1) // If this returns +1, it's a signal to go long// if you're in a downtrend and get a doji, and break the high of that doji, it's a long entry.IF dojiL AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry THENBUY 1 PERPOINT AT hahigh[1] STOPhsl = haopen[1]ENDIFSET STOP LOSS hslgraph hslgraph dojiL04/24/2020 at 3:55 PM #127848Sorry, cancel that last post. I had two doji indicators, one of which flags the doji and the other flags the next candle as an entry. I confused the two. Sorry!
-
AuthorPosts
Find exclusive trading pro-tools on