10.3 upgrade from 10.2 STOPS

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #26116 quote
    Dymjohn
    Participant
    Senior

    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 ?

    // 5. BRENT 5 MIN MY MONEY MGMT AND MODIFIED TRAIL
    // Definition of code parameters
    DEFPARAM 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 market
    if not onmarket then
    MAXPRICE = 0
    MINPRICE = close
    priceexit = 0
    endif
    // Money Management
    Capital = 4153  //at 17/2/17
    Risk = 0.015
    StopLoss = 40 // VARY TO DETERMINE RISK
    //Calculate contracts
    equity = Capital + StrategyProfit
    maxrisk = round(equity*Risk)
    PositionSize = abs(round((maxrisk/StopLoss)/PointValue)*pipsize)
    if PositionSize >= 10 Then
    PositionSize = 10
    endif
    
    //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 positions
    
    indicator1 = 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 THEN
    BUY PositionSize CONTRACT AT MARKET
    ENDIF
    
    // Conditions to enter short positions
    indicator4 = TimeSeriesAverage[28](close)
    indicator5 = WilderAverage[88](close)
    c3 = (indicator4 <= indicator5)
    
    indicator6 = SMI[8,1,16](close)
    c4 = (indicator6 >= 45)
    
    IF c3 AND c4 THEN
    SELLSHORT PositionSize CONTRACT AT MARKET
    ENDIF
    
    
    //trailing stop
    trailingstop = 45
    //case SHORT order
    trailshort = 40
    
    if shortonmarket then
    MINPRICE = MIN(MINPRICE,Low) //saving the MFE of the current trade
    if tradeprice(1)-MINPRICE> 0 then //if the MFE is higher than the trailingstop then
    priceexit = MINPRICE+trailshort*pointsize //set the exit price at the MFE + trailing stop price level
    endif
    if tradeprice(1)-MINPRICE<= 0 then
    priceexit = tradeprice(1)+trailshort*pointsize
    endif
    endif
    
    //case LONG order
    if longonmarket then
    MAXPRICE = MAX(MAXPRICE,High) //saving the MFE of the current trade
    if MAXPRICE-tradeprice(1)>= 0 then //if the MFE is higher than the trailingstop then
    priceexit = MAXPRICE-trailingstop*pointsize //set the exit price at the MFE - trailing stop price level
    endif
    if MAXPRICE-tradeprice(1)<= 0 then
    priceexit = tradeprice-trailingstop*pointsize// ensures trailing stop is in place mJAP improvement
    endif
    endif
    
    //exit on trailing stop price levels
    if onmarket and priceexit>0 then
    EXITSHORT AT priceexit STOP
    
    SELL AT priceexit STOP
    endif
    graph priceexit
    
    #26117 quote
    Dymjohn
    Participant
    Senior

    Sorry ignore first problem above that is a correct adjustment but second problem remains.

    #26123 quote
    Dymjohn
    Participant
    Senior

    Have tried changing the code for exiting a trade to the attached to avoid trade bar exits still not working properly

    if shortonmarket and TradeIndex <> BarIndex then
    MINPRICE = MIN(MINPRICE,Low) //saving the MFE of the current trade
    if tradeprice(1)-MINPRICE> 0 then //if the MFE is higher than the trailingstop then
    priceexit = MINPRICE+trailshort*pointsize //set the exit price at the MFE + trailing stop price level
    endif
    if tradeprice(1)-MINPRICE<= 0 then
    priceexit = tradeprice(1)+trailshort*pointsize
    endif
    endif
    
    //case LONG order
    if longonmarket and TradeIndex <> BarIndex then
    MAXPRICE = MAX(MAXPRICE,High) //saving the MFE of the current trade
    if MAXPRICE-tradeprice(1)>= 0 then //if the MFE is higher than the trailingstop then
    priceexit = MAXPRICE-trailingstop*pointsize //set the exit price at the MFE - trailing stop price level
    endif
    if MAXPRICE-tradeprice(1)<= 0 then
    priceexit = tradeprice-trailingstop*pointsize// ensures trailing stop is in place mJAP improvement
    endif
    endif
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.

10.3 upgrade from 10.2 STOPS


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Dymjohn @dymjohn Participant
Summary

This topic contains 2 replies,
has 1 voice, and was last updated by Dymjohn
8 years, 11 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 02/23/2017
Status: Active
Attachments: No files
Logo Logo
Loading...