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/30/2023 at 10:33 AM #212521
Have you tried …
12345678910111213IF LongTriggered OR ShortTriggered AND newSL > 0 ThenTrailingSL = newSLELSETrailingSL = UndefinedENDIFGraphOnPrice TrailingSL coloured(255,0,0) AS “My Tralling Stop”1 user thanked author for this post.
03/30/2023 at 10:37 AM #212524When you say that you can put both functions in the same algorithm, I will answer yes because it is just lines of code, however if the long market function is executed first then the short market function will not be executed as a short but as a sale of the first long position,
Try to understand what is happening;
Nothing prevents you from putting a PENDING Limit and Stop order at the same time. If this is not understood, then go to the manual once more and look up how an order like
Buy x Contracts at PriceY Limit
and
SellShort x Contracts at PriceY Stop
works, and while you’re at it, how that would work with manual trading.
If I’d like, I could place 100 (and more) Limit and Stop orders all at the same time. And they would really all be there in Live (or Demo), including their order labels. Whether this is useful, is something else.
It is totally unrelated to having two opposite positions (!) in the system at the same time.
🙂
I completely agree with you that two orders can be put on hold at the same time in the same algorithm, this is not a problem,
On the other hand, here is what could happen in a very simple case with some round numbers to explain the example :
12345678IF Conditons ThenBuy 1 Shares AT 10 LimitSellShort 1 Shares AT 8 LimitENDIF// Stop Loss & Take ProfitSet Stop %Loss 50 // in case of Long the SL = 5 in case of Short the SL = 12Set Target %Profit 50In this example we assume that the first order that could be executed was the Long order at a price of 10, In this case our SL will be calculated automatically and will be 50% of the entry price so it will be worth 5, So in this case we will be taken out of the market if the price reaches 5, Now if our market entry conditions are still valid, it means that the Short order at a price of 8 is still waiting to be executed,
In this case (and correct me if I’m wrong), if I understood the documentation correctly: the short sell order will turn into a normal sell order and it will take us out of our position at the price of 8 even if our SL is still pending at 5
Or will the program understand and make the difference between the SellShort order and the SL order and because it has a SL at 5 then it will ignore the SellShort 8 (the SellShort that could turn into a normal Sell in our case)?
I hope to be clear in what I am saying
03/30/2023 at 11:36 AM #212529Have you tried …
12345678910111213IF LongTriggered OR ShortTriggered AND newSL > 0 ThenTrailingSL = newSLELSETrailingSL = UndefinedENDIFGraphOnPrice TrailingSL coloured(255,0,0) AS “My Tralling Stop”tks for your answers, Not working too, but think it’s a limitation of the GraphOnPrice fonction, So now I will not spend more time on this think, I will ask other time if we need it, Now let’s focus on good stop and trailing stop management 🙂
03/30/2023 at 12:34 PM #212537Set Stop %Loss 50
Above means 50% of your Trade(s) Contract Value .. could result in a very big loss!
03/30/2023 at 1:17 PM #212539yes yes, Tks you GraHal , but the answers is for @PeterSt, and the 50% it’s just an exemple 😅
03/30/2023 at 1:31 PM #212541Here I am correcting my code at the level of the trailing stops,
they have 2 variable :– the first one is Points2BE, with this vaiable we change the entry price to BE so to trade price entry and we add 2 time the spread of 2 in this code,
– the second one is trailinstart, with this variable we calculate every candle when we are OnMarket the difference between the hiest candle with the trailling stop and if we get more the trailinstart point we change the trailing stop to this differnce12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788// Strategy Name : END OF DAY - YEN// Version : 4.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 = 30 // Posiotion will go to BE + spread fees after Points2BEtrailinstart = 80 //trailing will start @trailinstart points profitIF NOT ONMARKET THEN //resetnewSL=0//breakevenLevel=0ENDIF//manage long positionsIF LONGONMARKET THEN//first move to BreakEvenIF newSL=0 AND Close - TradePrice >= Points2BE * pipsize THENnewSL = TradePrice + Spread * 2 * pipsize // BE + 2 x Spread feesENDIF//next movesIF newSL>0 AND High - newSL >= trailinstart * pipsize THENnewSL = High - trailinstart * 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 ThenQuitENDIF// Drawing Trailing StopIF OnMarket AND newSL > 0 ThenTrailingSL = newSLFirstSL = TradePrice - SL * pipsizeELSETrailingSL = UndefinedFirstSL = UndefinedENDIF//GraphOnPrice newSL coloured(255,0,0) AS "My Tralling Stop"GraphOnPrice TrailingSL coloured(230,0,0) AS "My Tralling Stop"GraphOnPrice TradePrice coloured(0,220,0) AS "Long Trade Price"GraphOnPrice FirstSL coloured(0,0,0) AS "First Stop Loss"and tks to @JC_Bywan for GraphOnPrice and to @PeterSt for the tips
04/03/2023 at 11:46 AM #212717In this example we assume that the first order that could be executed was the Long order at a price of 10, In this case our SL will be calculated automatically and will be 50% of the entry price so it will be worth 5, So in this case we will be taken out of the market if the price reaches 5, Now if our market entry conditions are still valid, it means that the Short order at a price of 8 is still waiting to be executed,
In this case (and correct me if I’m wrong), if I understood the documentation correctly: the short sell order will turn into a normal sell order and it will take us out of our position at the price of 8 even if our SL is still pending at 5
Or will the program understand and make the difference between the SellShort order and the SL order and because it has a SL at 5 then it will ignore the SellShort 8 (the SellShort that could turn into a normal Sell in our case)?
I hope to be clear in what I am saying
just to answer my self, there is a good exemple where Proorder open a long position at limite price but they close it for execute the SellShort, in this case it executes the SellShort as et Normal Sell for the last Long posiion, and also they use the Buy order for close the SellShort position Instead the ExitShort :
123456789101112Defparam cumulateorders = false// LONGS & SHORTS USD/JPY - M15if date > 20230330 thenIF IntraDayBarIndex >= 5 THENBuy 1 Shares AT 132.800 LimitSellShort 1 Shares AT 133.250 LimitENDIFIF LongOnMarket ThenSet Stop Loss 132ENDIFendif04/03/2023 at 12:17 PM #212719TIP / friendly nudge 😉
When we Quote we highlight a phrase (a few words) in the text of a post and then click on Quote. This makes it much more user friendly (than Quoting 4 paragraphs of text). If folks want to read the 4 paragraphs / source of the Quote they only have to click on the Quote. 🙂
What you say in your post above (in answer to yourself) is normal behaviour for PRT. It happens the same for all of us.
1 user thanked author for this post.
04/03/2023 at 5:08 PM #212741tks for tip, I try it with out succes, I will try next time,
@GraHal @All if you know a good link explaining this methde of catching breakout or catching liquidity I will be happy to read or watch it and understand it for more comprenssion for this algo 😊
04/03/2023 at 6:47 PM #212750Have a look at this
https://www.youtube.com/watch?v=nVNSAoFKKOk
1 user thanked author for this post.
04/03/2023 at 9:16 PM #212753Have a look at this
I also found this one :
https://youtu.be/bov9W02ZR_0if do find other where they explain why and the mening of the strategry it will be great, I will try to undrtsnad every one to get the max of informaion and see wht I can do with tht for this algo 😊
1 user thanked author for this post.
04/07/2023 at 5:28 PM #213022I also found this one :
https://youtu.be/bov9W02ZR_0@GraHal I will try to do this video in the code , I think it’s realy simple, even I don’t understand what he use for chose the value of Stop loss, if sme one have some idea pls ?
04/07/2023 at 5:55 PM #213023also that is the Version 8 of this code, Not much exceptional even if the result in M 15 is 10070% (50K history), with 200K we have only 18% before the stratery qquit because of the huge drowdawn from 190K to 120k after only 3 trade with sure the very bad entry of this algorithme and also the bad manage of the number of share, but it’s intreseting,
Also I add the Tralling MFE with some different setting, it’s not the best but maybe can helpful to find somethink new
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190// Strategy Name : END OF DAY - YEN// Version : 8.0// Information : Adding MFE// Stroks : USD/JPY Mini// Initial Capital : 100 000 JPY// Test on : 50K Candles// Spread : 2// ########################################################################Defparam cumulateorders = falseOnce Capital = 100000Once Equity = CapitalONCE MFE=0SL = 12Period = 12Spread = 2// ########################################################################// ______ _ __//| ____| | | / \//| |__ ___ _ __ ___| || () |//| __/ _ \| '_ \ / __| __\__///| | | (_) | | | | (__| |_//|_| \___/|_| |_|\___|\__|// CANDLE REFERENCE to 210000IF Time = 210000 THENAmplitude = Highest[Period](High) - Lowest[Period](Low)Opening = CloseENDIF// LONGS & SHORTSIF Not LongOnMarket AND Time >= 210000 AND Time <= 231500 AND DayOfWeek < 5 THENBuy N Shares AT (Opening - Amplitude * 0.5) LimitENDIFIF LongOnMarket ThenSet Stop pLoss SLENDIF// ########################################################################// _______ _ _ _ _//|__ __| (_) | (_)// | |_ __ __ _ _| | |_ _ __ __ _// | | '__/ _<code>| | | | | '_ \ / _</code> |// | | | | (_| | | | | | | | | (_| |// |_|_| \__,_|_|_|_|_|_| |_|\__, |// __/ |// |___/once trailinstop= 0 //1 on - 0 offtrailingstart = 140 //trailing will start @trailinstart points profittrailingstep = 10 //trailing step to move the "stoploss"///2 BREAKEAVEN///////////once breakeaven = 0 //1 on - 0 offstartBreakeven = 30 //how much pips/points in gain to activate the breakeven function?PointsToKeep = 5 //how much pips/points to keep in profit above of below our entry price when the breakeven is activated (beware of spread)//reset the stoploss valueIF NOT ONMARKET THENnewSL=0breakevenLevel=0// MFEMAXPRICEMFE = 0priceexitMFE = 0Maxfloatingprofit = 0ENDIF//manage long positionsIF LONGONMARKET THEN//first move (breakeven)IF newSL=0 AND close-tradeprice(1)>=trailingstart*pipsize THENnewSL = tradeprice(1)+trailingstep*pipsizeENDIF//next movesIF newSL>0 AND close-newSL>=trailingstep*pipsize THENnewSL = newSL+trailingstep*pipsizeENDIFENDIF//stop order to exit the positionsIF newSL>0 THENSELL AT newSL STOPENDIF//test if the price have moved favourably of "startBreakeven" points alreadyIF LONGONMARKET AND close-tradeprice(1)>=startBreakeven*pipsize THEN//calculate the breakevenLevelbreakevenLevel = tradeprice(1)+PointsToKeep*pipsizeENDIF//place the new stop orders on market at breakevenLevelIF breakevenLevel>0 THENSELL AT breakevenLevel STOPENDIFIF Equity < 100000 ThenTRAILINGMFE = 10MFE = 1N = 3ELSIF Equity >= 100000 AND Equity < 120000 ThenTRAILINGMFE = 20MFE = 1N = 5ELSIF Equity >= 120000 AND Equity < 150000 ThenTRAILINGMFE = 30MFE = 1N = 8ELSIF Equity >= 150000 AND Equity < 180000 ThenTRAILINGMFE = 40MFE = 1N = 10ELSIF Equity >= 180000 ThenMFE = 0N = 15ENDIFif MFE>0 thenif longonmarket thenMAXPRICEMFE = MAX(MAXPRICEMFE,close) //saving the MFE of the current tradeif MAXPRICEMFE-tradeprice(1)>=TRAILINGMFE*pointsize then //if the MFE is higher than the trailingstop thenpriceexitMFE = MAXPRICEMFE-TRAILINGMFE*pointsize //set the exit price at the MFE - trailing stop price levelendifendifif onmarket and priceexitMFE>0 thenSELL AT priceexitMFE STOPendifendiffloatingprofit = (((close-positionprice)*pointvalue)*countofposition)/pipsize //actual trade gainsMaxfloatingprofit = Max(Maxfloatingprofit,floatingprofit)IF LongOnMarket ThenIF COUNTOFLONGSHARES > 3 AND floatingprofit < floatingprofit[1] ThenSell 1 Share AT MarketENDIFENDIF//IF LongOnMarket Then//IF COUNTOFLONGSHARES > 1 AND Maxfloatingprofit > Maxfloatingprofit[1] Then//Sell 1 Share AT Market//ENDIF//ENDIF// ########################################################################// _____ _// / ____| | |// | | __ _ __ __ _ _ __ | |__// | | |_ | '__/ _` | '_ \| '_ \// | |__| | | | (_| | |_) | | | |// \_____|_| \__,_| .__/|_| |_|// | |// |_|// Drawing Trailing StopIF OnMarket AND newSL > 0 ThenTrailingSL = newSLFirstSL = TradePrice - SL * pipsize//EntryPrice = TradePriceELSETrailingSL = Undefined//FirstSL = Undefined//EntryPrice = UndefinedENDIFGraph PositionPerf * 100 AS "PositionPerf"//Graph PositionPerf(1) * 100 AS "PositionPerf[1]"//Graph floatingprofit AS "floatingprofit"//GraphOnPrice TradePricecoloured(0,220,0) AS "Long Trade Price"//// Draw Equity//Graph Equity AS "Equity"//Graph Capital AS "Capital"// ########################################################################// _____ _ _____ _// / ____| | / ____| | |// | (___ | |_ ___ _ __ | (___ _ __ __ _| |_ ___ __ _ _ _// \___ \| __/ _ \| '_ \ \___ \| '__/ _<code>| __/ _ \/ _</code> | | | |// ____) | || (_) | |_) | ____) | | | (_| | || __/ (_| | |_| |// |_____/ \__\___/| .__/ |_____/|_| \__,_|\__\___|\__, |\__, |// | | __/ | __/ |// |_| |___/ |___/MaxDrawDownPercentage = 40 // Max DrawDown of x%Equity = Capital + StrategyProfitHighestEquity = Max (HighestEquity,Equity) // Save the Maximum Equity we gotMaxDrawdown = HighestEquity * (MaxDrawDownPercentage/100)ExitFromMarketCond = Equity <= HighestEquity - MaxDrawdownIF ExitFromMarketCond ThenQuitENDIFif some one have some good idea or strategy to control the drawdown and the exposition it will be welcom ?
04/08/2023 at 5:44 PM #213035In the continuity of the improvement of this algorithm of which I see many subjects now on the forum, I made a copy of this code from this topic with a very small modification on the code so that it is a little more clear,
there is the original code :
1234567891011121314if time = 061000 then //x1= barindex[0] //x2 = barindex[86] //yh = highest[86](high)yL=lowest[86](low)drawsegment(x1,yh,x2,yh) coloured (0,0,255)drawsegment(x1,yL,x2,yL) coloured (255,0,0)// set text offset from lineos = 4*pipsizedrawtext("#yh#",barindex,yh+os,SansSerif,bold,20) coloured(0,0,0)drawtext("#yL#",barindex,yL-os,SansSerif,bold,20) coloured(0,0,0)endifreturn yh as "hi" ,yL as "Lo"to this code :
123456789101112131415161718if time = 061000 then //x1= barindex[0] //x2 = barindex[86] //yh = highest[86](high)yL=lowest[86](low)DRAWRECTANGLE(x1, yh, x2,yL ) COLOURED(0,0,0)os = 4*pipsizedrawtext("#yh#",x2,yh+os,SansSerif,bold,10) coloured(0,0,0)drawtext("#yL#",x2,yL-os,SansSerif,bold,10) coloured(0,0,0)endifif time >= 061000 AND time <= 230000 thendrawsegment(x1,yh,barindex,yh) coloured (0,0,255) STYLE(DOTTEDLINE3,1)drawsegment(x1,yL,barindex,yL) coloured (0,0,255) STYLE(DOTTEDLINE3,1)endifreturnNext messag eI will post some picture and GTM problem with France for be sure to adjust the time to Tokyo session there is only from 9AM to 3 PM in tokyo if I’m not wrong
04/08/2023 at 10:43 PM #213037Let’s start by correcting the timetable, the Japanese market is open from 9am until 11:30am and then from 12:30pm to 3pm Tokyo time, we can summarise that the market is open from 6 a.m. to 3 p.m., So 6 hours of opening time
so in GTM (UTC) time the Japanese market is open from 0 to 6 a.m GTM, so for france trader like me they have 2 situation :
– in the summer France is +2 GTM, so this tokyo box is from 2am to 8am
– in the winter France is +1 GTM, so this tokyo box is from 1am to 7amso now we e in the summer, the code about it’s like this :
123456789101112131415161718if time = 081000 thenx1= barindex[0]x2 = barindex[74] // 74 - 2 = 72 ==> 72 x 5 = 360min ==> 360min / 60 = 6hyh = highest[74](high)yL=lowest[74](low)DRAWRECTANGLE(x1, yh, x2,yL ) COLOURED(0,0,0)os = 4*pipsizedrawtext("#yh#",x2,yh+os,SansSerif,bold,10) coloured(0,0,0)drawtext("#yL#",x2,yL-os,SansSerif,bold,10) coloured(0,0,0)endifif (time >= 081000 AND time <= 240000) thendrawsegment(x1,yh,barindex,yh) coloured (0,0,255) STYLE(DOTTEDLINE3,1)drawsegment(x1,yL,barindex,yL) coloured (0,0,255) STYLE(DOTTEDLINE3,1)endifreturn -
AuthorPosts
Find exclusive trading pro-tools on