End Of Day – YEN M15 Strategy
Forums › ProRealTime English forum › ProOrder support › End Of Day – YEN M15 Strategy
- This topic has 95 replies, 8 voices, and was last updated 1 year ago by ZeroCafeine.
-
-
03/27/2023 at 2:43 PM #212213
I think you know all that it takes a 67% increase on our capital to recover the 40% drop, Even if the strategy with 40% draw down and positive it’s still a shame to lose the 40% you had won
03/27/2023 at 2:49 PM #212215The next step would be to use stop followers and maybe also to improve the Take profit with this thread
If you have other ideas or other contributions I’m interested, the goal is to improve the code a bit and especially for me and to improve myself in programming and why not for some beginners and the community
03/28/2023 at 4:27 PM #212316Let’s go with a first improvement that is not really an improvement, the Hit & Run, as you can see on the original code the setting value of TP and SL is :
123// STOP LOSS & TAKE PROFIT (%)SL = 1TP = 0.8with this value we are from 100K to 204K JPY
but with just reduce the SL from 1 to 0,5% of the trade and increasing the profit from 0,8 to 1% we are from 100K to 245K JPY
03/28/2023 at 6:40 PM #212326Let’s go with the second improvement :
– I reduced the code and remove some code (maybe stupid condtion for try to ride the position, I will come back to this next time)
– at this time I use only Long position, because if I’m not wrong it’s not possible to be Long and Short in he same time with the same code (I on’t know if it’s possible to be long and shot in the same time with 2 different algo on the same stoks with IG ?)
– I add some trule even it’s not perfect for magane the SLMy question is : Why the algorithm takes me out of position at 9pm ?, You can see on the screenshot the output is represented by a red triangle
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778// Strategy Name : END OF DAY - YEN// Version : 2.0// Information : I don't know what is this Strategie means ;-)// Stroks : USD/JPY Mini// Initial Capital : 100 000 JPY// Test on : 50K Candles// Spread : 2// ============================================================Defparam cumulateorders = falseOnce Capital = 100000// SIZE OF THE POSITIONSN = 1Ratio = 0.5// TIMETABLEStartTime = 210000EndTime = 231500// STOP LOSS & TAKE PROFIT (%)SL = 12Period = 12Spread = 2// CANDLE REFERENCE to StartTimeIF Time = StartTime THENAmplitude = Highest[Period](High) - Lowest[Period](Low)Opening = CloseENDIF// LONGS & SHORTSIF Not LongOnMarket AND Time >= StartTime AND Time <= EndTime AND DayOfWeek < 5 THENBuy N Shares AT (Opening - Amplitude * Ratio) LimitENDIFIF LongOnMarket ThenSet Stop pLoss SLENDIFtrailingstart = 140 //trailing will start @trailinstart points profittrailingstep = 80 //trailing step to move the "stoploss"points2BE = SL //points to keep at breakeven = Set Stop pLoss 12startBreakeven = 30PointsToKeep = 5IF NOT ONMARKET THEN //resetnewSL=0breakevenLevel=0ENDIF//manage long positionsIF LONGONMARKET THEN//first move (breakeven)IF newSL=0 AND close-tradeprice(1) >= trailingstart * pipsize THENnewSL = tradeprice(1) + Spread * pipsize // BE + 2 x SpreadENDIF//next movesIF newSL>0 AND Close - newSL >= trailingstep * pipsize THENnewSL = newSL + trailingstep * pipsizeENDIFENDIFIF newSL>0 THENSELL AT newSL STOPENDIF// STOP STRATEGIE DrawDownMaxDrawDownPercentage = 40 // Max DrawDown of x%Equity = Capital + StrategyProfitHighestEquity = Max (HighestEquity,Equity) // Save the Maximum Equity we gotMaxDrawdown = HighestEquity * (MaxDrawDownPercentage/100)ExitFromMarket = Equity <= HighestEquity - MaxDrawdownIF ExitFromMarket ThenQuitENDIF03/28/2023 at 6:55 PM #212329it’s not possible to be Long and Short in he same time with the same code
Above is correct.
Why the algorithm takes me out of position at 9pm ?, You can see on the screenshot the output is represented by a red triangle?
How you know the red triangle is a 9pm? You are not using crosshairs on your cursor and the x axis shows 16:00 and 13 and 14?
Or am I missing something?
1 user thanked author for this post.
03/28/2023 at 7:57 PM #21233003/28/2023 at 10:10 PM #212333You are right I made a mistake, I had an exit by chance at 9pm and I thought it was an error in my code but indeed I see on the screenshot and on my test right now that I exited around 7:45pm,
So the problem comes from my management of stops and trailing stops
03/28/2023 at 10:14 PM #212334It does put long and short positions at the same time.
I don’t undertand what you do mean, it’s possible to be both of Long and Short with the same algorithme or Not ?
03/28/2023 at 10:52 PM #212335Here I think I have understood Nicolas’ reasoning on the stop follower, it’s not perfect yet but I think it’s already better than the post just before :
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374// Strategy Name : END OF DAY - YEN// Version : 2.0// Information : I don't know what is this Strategie means ;-)// Stroks : USD/JPY Mini// Initial Capital : 100 000 JPY// Test on : 50K Candles// Spread : 2// ============================================================Defparam cumulateorders = falseOnce Capital = 100000// SIZE OF THE POSITIONSN = 1Ratio = 0.5// TIMETABLEStartTime = 210000EndTime = 231500// STOP LOSS & TAKE PROFIT (%)SL = 12Period = 12Spread = 2// CANDLE REFERENCE to StartTimeIF Time = StartTime THENAmplitude = Highest[Period](High) - Lowest[Period](Low)Opening = CloseENDIF// LONGS & SHORTSIF Not LongOnMarket AND Time >= StartTime AND Time <= EndTime AND DayOfWeek < 5 THENBuy N Shares AT (Opening - Amplitude * Ratio) LimitENDIFIF LongOnMarket ThenSet Stop pLoss SLENDIFpoints2BE = 140 //trailing will start @trailinstart points profittrailingstep = 80 //trailing step to move the "stoploss"IF NOT ONMARKET THEN //resetnewSL=0breakevenLevel=0ENDIF//manage long positionsIF LONGONMARKET THEN//first move to BreakEvenIF newSL=0 AND close-tradeprice(1) >= points2BE * pipsize THENnewSL = tradeprice(1) + Spread * 2 * pipsize // BE + 2 x Spread feesENDIF//next movesIF newSL>0 AND Close - newSL >= trailingstep * pipsize THENnewSL = High - trailingstep * pipsizeENDIFENDIFIF newSL>0 THENSELL AT newSL STOPENDIF// STOP STRATEGIE DrawDownMaxDrawDownPercentage = 40 // Max DrawDown of x%Equity = Capital + StrategyProfitHighestEquity = Max (HighestEquity,Equity) // Save the Maximum Equity we gotMaxDrawdown = HighestEquity * (MaxDrawDownPercentage/100)ExitFromMarket = Equity <= HighestEquity - MaxDrawdownIF ExitFromMarket ThenQuitENDIFWe can see that in the position just before the exit was around 140 pips (red frame), while now for the same trade the trailing stop makes us exit with a gain of 509 pips, Of course the code is not perfect, it tends to go the other way
For the first movement of the StopLoss to the breakeven with the variable Points2BE, I voluntarily left the number 140 in order to let the position breathe, On the other hand, if you have any other ideas or proposals on this point, I’d be happy to hear them.
We should also not forget the disastrous performance at the beginning of the backtest 😅
03/29/2023 at 10:53 AM #212400Hi
some one can tell me how to draw my newSL Variable in my graphic price pls ?, I add this line but as you can see the graphic is on a frame alone, but I want to draw if with candles price together :
1GRAPH newSL coloured(255,0,0) AS "My SL Tralling"even my variable going from 0 to a big value, that is not a problem now, but if you also have a solution for this ?
03/29/2023 at 10:56 AM #212403Instruction GRAPHONPRICE
https://www.prorealcode.com/documentation/graphonprice/
1 user thanked author for this post.
03/29/2023 at 11:19 AM #212408@JC_Bywan
tks you, I will read it in the end of day and come back with a solution for my problem 😄, maybe if I find a solution for the 0 value 😅03/29/2023 at 12:19 PM #212418I found this solution for draw the traling stop (tks you @JC_Bywan), but how to don’t draw it when we don’t have a trade open :
12345678// Drawing Trailing StopIF newSL > 0 ThenTrailingSL = newSLELSETrailingSL = UndefinedENDIFGraphOnPrice TrailingSL coloured(255,0,0) AS "My Tralling Stop"I also tryed this but not working :
1234567// Drawing Trailing StopIF newSL > 0 ThenTrailingSL = newSLGraphOnPrice TrailingSL coloured(255,0,0) AS "My Tralling Stop"ELSETrailingSL = UndefinedENDIF03/29/2023 at 1:01 PM #212423Try …
1234567IF onmarket AND newSL > 0 ThenTrailingSL = newSLELSETrailingSL = UndefinedENDIFGraphOnPrice TrailingSL coloured(255,0,0) AS "My Tralling Stop"1 user thanked author for this post.
03/29/2023 at 1:08 PM #212424but how to don’t draw it when we don’t have a trade open :
123456789// Drawing Trailing StopIF newSL > 0 ThenTrailingSL = newSLIf OnMarket thenGraphOnPrice TrailingSL coloured(255,0,0) AS "My Tralling Stop"endifELSETrailingSL = UndefinedENDIFNote that really “don’t draw” does not exist. Here you see the exit from this morning (in the coffee-spoiling topic 😉 ) and it is depicted by the green line. So this line changes position because I tell it to, but when the position is exited I stop drawing that green line (and more). Now this line keeps on drawing automatically, but while this seems strange, it is even convenient. See 2nd screenshot. You can easily see where this green line was in action, and can zoom in to it when you want. In my case these are the trailing stop exits (the darker green line). Just learn a bit to utilize this feature. You will see it is quite handy.
-
AuthorPosts
Find exclusive trading pro-tools on