System being inconsistant

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #10180 quote
    jbyrne
    Participant
    Average

    Hi, if re-written my system but it’s very inconsistent since the code seems to be fine but when I backtest it, it doesn’t always go long/short when its mean’t to please help. Please check links for photos of the problem I’m having.

    Photo link: https://gyazo.com/e844d6b20ad1b5dbc3afc38d2d19ba4f

    Also I’m using spreadbetting and all the units seems to be in cents in instead of full numbers, anyway to change that? thanks

    // Definition of code parameters
    DEFPARAM CumulateOrders = false // Cumulating positions deactivated
    
    // Conditions to enter long positions
    indicator1 = Average[9](close)
    c1 = (indicator1 CROSSES OVER open)
    
    indicator2 = Average[9](close)
    c2 = (indicator2 CROSSES UNDER close)
    
    IF c1 AND c2 THEN
    BUY 3 PERPOINT AT MARKET
    ENDIF
    
    // Conditions to exit long positions
    indicator3 = Average[9](close)
    c3 = (indicator3 CROSSES UNDER open)
    
    indicator4 = Average[9](close)
    c4 = (indicator4 CROSSES OVER close)
    
    IF c3 AND c4 THEN
    SELL  AT MARKET
    ENDIF
    
    // Conditions to enter short positions
    indicator5 = Average[9](close)
    c5 = (indicator5 CROSSES UNDER open)
    
    indicator6 = Average[9](close)
    c6 = (indicator6 CROSSES OVER close)
    
    IF c5 AND c6 THEN
    SELLSHORt 3 PERPOINT AT MARKET
    ENDIF
    
    // Conditions to exit short positions
    indicator7 = Average[9](close)
    c7 = (indicator7 CROSSES OVER close)
    
    indicator8 = Average[9](close)
    c8 = (indicator8 CROSSES UNDER close)
    
    IF c7 AND c8 THEN
    EXITSHORT  AT MARKET
    ENDIF
    
    // Stops and targets
    
    #10181 quote
    Nicolas
    Keymaster
    Master

    You have some conditions that do not suit the crosses over/under at the same time, that’s why there are some problems obviously.

    If you want to test a simple cross of the price with a moving average, you should only code it like this:

    indicator1 = Average[9](close)
    
    //buy condition
    cBuy = (close CROSSES OVER indicator1)
    
    sell condition 
    cSell = (close CROSSES UNDER indicator1)

    That’s all you need.

    #10184 quote
    jbyrne
    Participant
    Average

    Hi, thank you for your help it’s helped me a lot. I have realized that the problem i was having is that I use heiken ashi candles but ProOrder uses regular candlesticks. How can I get my code to buy/sell according to Heiken Ashi candles instead of regular candlesticks? thank you

    #10186 quote
    Nicolas
    Keymaster
    Master

    Here is Heiken Ashi candlestick Close code you need:

    haclose=(open+close+low+high)/4
    
    #10187 quote
    jbyrne
    Participant
    Average

    thank you you have been very helpful, but can you direct me where to put that code in order to make my system work? thank you

    #10190 quote
    Nicolas
    Keymaster
    Master

    Add it at the beginning of your code and then replace of the “close” with “haclose”, that’s all.

    #10191 quote
    jbyrne
    Participant
    Average

    thank you it works great apart from the it opens the new position at the close of the candle instead of the open. How can this be changed? thank you

    spreadbetting.png spreadbetting.png
    #10200 quote
    Nicolas
    Keymaster
    Master

    Conditions are tested at the bar close and positions are next open candle. So I think what you observed here is the spread.

    #10203 quote
    jbyrne
    Participant
    Average

    I don’t know if its the spread or not because spreads surely aren’t this big? https://gyazo.com/06c9d8fd6754e2460e60b97147677546

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

System being inconsistant


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
jbyrne @jbyrne Participant
Summary

This topic contains 8 replies,
has 2 voices, and was last updated by jbyrne
9 years, 7 months ago.

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