Tester produces results but live falls over

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

    Hi Nicolas,

    The attached code produces results with modest profit on the DAX but if I run in live mode on IG it fails to raise an order and stops running. It says to view reason for rejection but cannot see any failed orders on the report. Any suggestions please?

    John

    <br>// Definition of code parameters
    DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    DEFPARAM FLATBEFORE = 070000 // Flat before this time
    DEFPARAM FLATAFTER = 205000 // Flat after this time
    
    //reset a at start of day
    once a = 0
    
    
    
    //resetting variables when no trades are on market
    if not onmarket then
    MAXPRICE = 0
    MINPRICE = close
    priceexit = 0
    endif
    
    
    //prices to enter trades
    BuyPrice = High[0]+2*PointSize
    SellPrice = Low[0]-2*PointSize
    
    // Conditions to enter long positions
    indicator1 = Stochastic[14,5](close)
    c1 = (indicator1 < 25)
    
    indicator2 = Average[20](close)
    indicator3 = Average[50](close)
    c2 = (indicator2 > indicator3)
    c6 = (a<=0)
    
    IF NOT ONMARKET AND c1 AND c2 AND c6 THEN
    BUY 1 PERPOINT AT BuyPrice STOP
    a=1//trade is a buy order
    ENDIF
    
    
    // Conditions to enter short positions
    indicator5 = Stochastic[14,5](close)
    c4 = (indicator5 > 75)
    
    indicator6 = Average[50](close)
    indicator7 = Average[20](close)
    c5 = (indicator6 > indicator7)
    c7 = (a>=0)
    IF NOT ONMARKET AND c4 AND c5 AND c7 THEN
    SELLSHORT 1 PERPOINT AT SellPrice STOP
    a=-1//trade is a sell order
    ENDIF
    trailingstop = 20
    
    //resetting variables when no trades are on market
    if not onmarket then
    MAXPRICE = 0
    MINPRICE = close
    priceexit = 0
    endif
    //case SHORT order
    if shortonmarket then
    MINPRICE = MIN(MINPRICE,low) //saving the MFE of the current trade
    if tradeprice(1)-MINPRICE>=trailingstop*pointsize then //if the MFE is higher than the trailingstop then
    priceexit = MINPRICE+trailingstop*pointsize //set the exit price at the MFE + trailing stop price level
    endif
    endif
    
    //case LONG order
    if longonmarket then
    MAXPRICE = MAX(MAXPRICE,high) //saving the MFE of the current trade
    if MAXPRICE-tradeprice(1)>=trailingstop*pointsize 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
    endif
    
    //exit on trailing stop price levels
    if onmarket and priceexit>0 then
    EXITSHORT AT priceexit STOP
    SELL AT priceexit STOP
    endif
    // stop and target
    SET STOP PLOSS 25
    SET TARGET PPROFIT 80
    
    #10566 quote
    Elsborgtrading
    Participant
    Veteran

    Hi. If you look in the Order list, under Cancelled/Rejected tab- find the order you ask about, and hover the mouse pointer over the yellow ! mark. it should give some more information.

    \Elsborgtrading

    #10583 quote
    Dymjohn
    Participant
    Senior

    Hi Elsborgtrading

    The Cancelled/Rejected list is empty in fact the whole report is empty. When it fell over and having found no transactions I deleted the strategy from auto trading. I’m just going to reload and wait for it to fall over again. The pity was it tried to place the trade when I expected it to.

    Thanks for your consideration of this problem.

    #10589 quote
    Elsborgtrading
    Participant
    Veteran

    Strange. My guess is that you didn’t have enough margin in you account to cover the trade- I ofcause could be wrong, but I know that happened for me a couple of times- or your code tried to enter the market at 1 position when you needed at least 2 for that instrument or something like that.There is a setting for Pro Order that is should stop or continue when encounter an error. hope that helps 🙂

    I didn’t find anywhere in PRT to dispay the INFO of the instrument where you can see these settings, so I use the web trader instead to see this. see scrndump. Perhaps someone else knows where to see INFO in PRT?

    Screenshot_97.png Screenshot_97.png
    #10595 quote
    Dymjohn
    Participant
    Senior

    Hi Elsborgtrading

    I’m trading a spreadbet account but have more than enough in my account to open 3 points. My only question mark on this have I written the code correctly. On ititiation of the strategy I entered 3 as the quantity, is this consistent with the way I wrote the code i.e.
    <pre class=”line-numbers language-prorealtime”><code class=” language-prorealtime”><span class=”token keyword”>SELLSHORT</span> <span class=”token number”>1</span> PERPOINT <span class=”token keyword”>AT</span> SellPrice <span class=”token keyword”>STOP
    </span>or
    <pre class=”line-numbers language-prorealtime”><code class=” language-prorealtime”><span class=”token keyword”>BUY</span> <span class=”token number”>1</span> PERPOINT <span class=”token keyword”>AT</span> BuyPrice <span class=”token keyword”>STOP
    </span>The minimum bet on DAX is 2 points.
    Regards
    dymjohn

    #10602 quote
    Elsborgtrading
    Participant
    Veteran

    Hi again. I’m not that experienced in coding, so I actually don’t know the one you just posted? Is that PRT code? anyway the first code you put in the initial post here, I tried to enter in Pro order and it backtest with no error, but I guess that you already knew that 🙂 But what DAX time frame are you using? I can’t back test any that actually makes a profit with the code?

    Br. Elsborgtrading

    #10604 quote
    Dymjohn
    Participant
    Senior

    Hi Elsborgtrading

    You need to use the 5 minute timeframe and test over say 10000 bars.

    Regards

    dymjohn

    #10630 quote
    Elsborgtrading
    Participant
    Veteran

    Hi. Maybe I’m doing something wrong here, because I don’t see any profit- even with no spread setting?

    Screenshot_101.png Screenshot_101.png
    #10634 quote
    Eric
    Participant
    Master

    In the code you have 1 per point and minimum spreadbetting is 2 per point?

    try with 2 in the code (in backtest it works with 1)

    #10668 quote
    Dymjohn
    Participant
    Senior

    Hi Elsborgtrading

    The problem was quantity so now looking to improve. I did say it was only a modest profit but thanks for your attention.

    regards

    dymjohn

    #10669 quote
    Dymjohn
    Participant
    Senior

    Hi Eric

    Yes it was a quantity problem they always confuse me.

    Thanks

    dymjohn

Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.

Tester produces results but live falls over


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Dymjohn @dymjohn Participant
Summary

This topic contains 10 replies,
has 3 voices, and was last updated by Dymjohn
9 years, 7 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 07/18/2016
Status: Active
Attachments: No files
Logo Logo
Loading...