10.3 upgrade from 10.2 STOPS
Forums › ProRealTime English forum › ProBuilder support › 10.3 upgrade from 10.2 STOPS
- This topic has 2 replies, 1 voice, and was last updated 7 years ago by Dymjohn.
-
-
02/23/2017 at 10:26 AM #26116
Hi
I attach an EA which is one I have put together from other posts on the website.
On 10.3 the EA is not working the same as before the upgrade and I think it is to do with the stops.
Firstly, having graphed the stop it places the correct stop where there are no previous trades running but appears to change this by 0.5 points on the next bar.
Secondly, where a trade is closed and another is opened on the same bar it closes the second trade at the end of the opening bar. There is no problem with the new stop being hit and I think its because the old stop must still be in place from the first trade but not sure.
Can anyone help please ?
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697// 5. BRENT 5 MIN MY MONEY MGMT AND MODIFIED TRAIL// Definition of code parametersDEFPARAM CumulateOrders = False // Cumulating positions deactivated//DEFPARAM FLATBEFORE = 001000//DEFPARAM FLATAFTER = 160000//DEFPARAM PRELOADBARS = 2000//LastEntryTime = 130000//ignore saturday and Sunday trading TD=Trading Day//resetting variables when no trades are on marketif not onmarket thenMAXPRICE = 0MINPRICE = closepriceexit = 0endif// Money ManagementCapital = 4153 //at 17/2/17Risk = 0.015StopLoss = 40 // VARY TO DETERMINE RISK//Calculate contractsequity = Capital + StrategyProfitmaxrisk = round(equity*Risk)PositionSize = abs(round((maxrisk/StopLoss)/PointValue)*pipsize)if PositionSize >= 10 ThenPositionSize = 10endif//prices to enter trades//if DayOfWeek = 1 Then//BuyPrice = (DHigh(2)+3*PointSize)//SellPrice = (DLow(2)-3*PointSize)//else//BuyPrice = (DHigh(1)+3*PointSize)//SellPrice = (DLow(1)-3*PointSize)//endif// Conditions to enter long positionsindicator1 = TimeSeriesAverage[12](close)indicator2 = WilderAverage[60](close)c1 = (indicator1 >= indicator2)indicator3 = SMI[14,2,16](close)c2 = (indicator3 CROSSES OVER -44)IF c1 AND c2 THENBUY PositionSize CONTRACT AT MARKETENDIF// Conditions to enter short positionsindicator4 = TimeSeriesAverage[28](close)indicator5 = WilderAverage[88](close)c3 = (indicator4 <= indicator5)indicator6 = SMI[8,1,16](close)c4 = (indicator6 >= 45)IF c3 AND c4 THENSELLSHORT PositionSize CONTRACT AT MARKETENDIF//trailing stoptrailingstop = 45//case SHORT ordertrailshort = 40if shortonmarket thenMINPRICE = MIN(MINPRICE,Low) //saving the MFE of the current tradeif tradeprice(1)-MINPRICE> 0 then //if the MFE is higher than the trailingstop thenpriceexit = MINPRICE+trailshort*pointsize //set the exit price at the MFE + trailing stop price levelendifif tradeprice(1)-MINPRICE<= 0 thenpriceexit = tradeprice(1)+trailshort*pointsizeendifendif//case LONG orderif longonmarket thenMAXPRICE = MAX(MAXPRICE,High) //saving the MFE of the current tradeif MAXPRICE-tradeprice(1)>= 0 then //if the MFE is higher than the trailingstop thenpriceexit = MAXPRICE-trailingstop*pointsize //set the exit price at the MFE - trailing stop price levelendifif MAXPRICE-tradeprice(1)<= 0 thenpriceexit = tradeprice-trailingstop*pointsize// ensures trailing stop is in place mJAP improvementendifendif//exit on trailing stop price levelsif onmarket and priceexit>0 thenEXITSHORT AT priceexit STOPSELL AT priceexit STOPendifgraph priceexit02/23/2017 at 10:36 AM #2611702/23/2017 at 11:40 AM #26123Have tried changing the code for exiting a trade to the attached to avoid trade bar exits still not working properly
1234567891011121314151617181920if shortonmarket and TradeIndex <> BarIndex thenMINPRICE = MIN(MINPRICE,Low) //saving the MFE of the current tradeif tradeprice(1)-MINPRICE> 0 then //if the MFE is higher than the trailingstop thenpriceexit = MINPRICE+trailshort*pointsize //set the exit price at the MFE + trailing stop price levelendifif tradeprice(1)-MINPRICE<= 0 thenpriceexit = tradeprice(1)+trailshort*pointsizeendifendif//case LONG orderif longonmarket and TradeIndex <> BarIndex thenMAXPRICE = MAX(MAXPRICE,High) //saving the MFE of the current tradeif MAXPRICE-tradeprice(1)>= 0 then //if the MFE is higher than the trailingstop thenpriceexit = MAXPRICE-trailingstop*pointsize //set the exit price at the MFE - trailing stop price levelendifif MAXPRICE-tradeprice(1)<= 0 thenpriceexit = tradeprice-trailingstop*pointsize// ensures trailing stop is in place mJAP improvementendifendif -
AuthorPosts