Not logged in
Viewing 9 posts - 1 through 9 (of 9 total)

Forums>StrategyQuant>Application Support>StrategyQuant Strategies not profitable when coding them in C

  • #237334 |
    Customer
    7 Posts

    I have been re-coding strategyquant generated strategies in Zorro Trader which uses lite C and the results are night and day.

    SQ X shows huge profit whereas Zorro is showing a loss. The amount of trades aren’t even close and both systems are using the same data as I exported the candles directly from my broker through Zorro.

    The strategy was found using EURUSD 15 min bars and when I coded in Zorro for 15 min bars,  there are 29,568 trades vs SQs 3902. Even if I switch Zorro to use 1H bars, it still has 2x as many trades … resulting in 7154 trades. Both zorro 15 min and 60 min produce annual returns (losses) of -14% and -15%  respectively whereas SQ X is saying every year was a win and by huge profit factors.

    I can understand slight differences using the same data but these differences are huge. SQ is saying its a winning system year over year whereas Zorro is saying that it is losing -14% per year.

    Please advise.

     

     

    Attachments:
    You must be logged in to view attached files.
    #237338
    Customer
    7 Posts
    
    //--------------------------------------------------------------------
    // Pseudo Source Code of Strategy 0.850460
    //
    //   Generated by StrategyQuant X Build 115 for MetaTrader
    //   at 12/12/2018 01:03
    //--------------------------------------------------------------------
    
    //--------------------------------------------------------------------
    //  Strategy Parameters
    //--------------------------------------------------------------------
    int MagicNumber = 11111;
    
    Main chart = Current Symbol / Current TF
    
    //--------------------------------------------------------------------
    // Trading rule: Trading signals (On Bar Open)
    //--------------------------------------------------------------------                   
    LongEntrySignal = (CCI(Main chart,30)[2] is higher than 25.0);
    
    ShortEntrySignal = (CCI(Main chart,30)[2] is lower than -25)
    ;
    
    LongExitSignal = ((DeMarker(Main chart,40) changes direction upwards)
       and (Williams % R(Main chart,22) > -10.0));
    
    ShortExitSignal = ((DeMarker(Main chart,40) changes direction downwards)
       and (Williams % R(Main chart,22) < -90));
    
    //--------------------------------------------------------------------
    // Trading rule: Long entry (On Bar Open)
    //--------------------------------------------------------------------                   
    if LongEntrySignal
    {
        // Action #1
        Open Long order at Market;
            Stop Loss = 2.3 * ATR(20);
            Profit target = 2.9 * ATR(20);
    
            Exit After 18 bars;
    
    }
    
    //--------------------------------------------------------------------
    // Trading rule: Short entry (On Bar Open)
    //--------------------------------------------------------------------                   
    if (ShortEntrySignal
       and Not LongEntrySignal)
    {
        // Action #1
        Open Short order at Market;
            Stop Loss = 2.3 * ATR(20);
            Profit target = 2.9 * ATR(20);
    
            Exit After 18 bars;
    
    }
    
    //--------------------------------------------------------------------
    // Trading rule: Long exit (On Bar Open)
    //--------------------------------------------------------------------                   
    if ((LongExitSignal
       and Not LongEntrySignal)
       and (MarketPosition("Any", MagicNumber, "") is Long))
    {
        // Action #1
        Close Full position for Symbol = Any and Magic Number = MagicNumber;
    
    }
    
    //--------------------------------------------------------------------
    // Trading rule: Short exit (On Bar Open)
    //--------------------------------------------------------------------                   
    if ((ShortExitSignal
       and Not ShortEntrySignal)
       and (MarketPosition("Any", MagicNumber, "") is Short))
    {
        // Action #1
        Close Full position for Symbol = Any and Magic Number = MagicNumber;
    
    }
    
    
    #237340
    Customer
    430 Posts

    Yeah I wish this was so easy but it is not. I tried this using SQ3 and Ninjatrader it did not work either because of to many reasons. So stick with MT4 until they added support for Zorry or You will just waste Your time.

    #237341
    Customer
    7 Posts

    I re-coded many strategies over last few days and they all fail.

    Zorro is pretty straightforward in the coding as most of the nuts and bolts are done for you. So I don’t think it’s an issue with zorro, I am leaning towards that StrategyQuant is not generating false signals or is inaccurate.

    Would really like feedback from developers and work to resolve this!

    #237342
    Customer
    7 Posts

    I just spent the last hour re-coding a different strategy which has very simple rules and it fails as well.

    
    //--------------------------------------------------------------------
    // Pseudo Source Code of Strategy 0.899785
    //
    //   Generated by StrategyQuant X Build 115 for MetaTrader
    //   at 12/14/2018 01:23
    //--------------------------------------------------------------------
    
    //--------------------------------------------------------------------
    //  Strategy Parameters
    //--------------------------------------------------------------------
    int MagicNumber = 11111;
    
    Main chart = Current Symbol / Current TF
    
    //--------------------------------------------------------------------
    // Trading rule: Trading signals (On Bar Open)
    //--------------------------------------------------------------------                   
    LongEntrySignal = (ADX DI Minus(Main chart)[1] is rising);
    
    ShortEntrySignal = (ADX DI Minus(Main chart)[1] is falling);
    
    LongExitSignal = false;
    
    ShortExitSignal = false;
    
    //--------------------------------------------------------------------
    // Trading rule: Long entry (On Bar Open)
    //--------------------------------------------------------------------                   
    if LongEntrySignal
    {
        // Action #1
        Open Long order at (Close(Main chart)[3] + (2 * ATR(Main chart,40)[1])) Stop;
            Order valid for 1 bars;
            Stop Loss = 75.0 pips;
            Profit target = 195.0 pips;
    
            Move SL to BE = 135.0 pips;
    
            Exit After 7 bars;
    
    }
    
    //--------------------------------------------------------------------
    // Trading rule: Short entry (On Bar Open)
    //--------------------------------------------------------------------                   
    if (ShortEntrySignal
       and Not LongEntrySignal)
    {
        // Action #1
        Open Short order at (Close(Main chart)[3] - (2 * ATR(Main chart,40)[1])) Stop;
            Order valid for 1 bars;
            Stop Loss = 75 pips;
            Profit target = 195 pips;
    
            Move SL to BE = 135 pips;
    
            Exit After 7 bars;
    
    }
    
    //--------------------------------------------------------------------
    // Trading rule: Long exit (On Bar Open)
    //--------------------------------------------------------------------                   
    if ((LongExitSignal
       and Not LongEntrySignal)
       and (MarketPosition("Any", MagicNumber, "") is Long))
    {
        // Action #1
        Close Full position for Symbol = Any and Magic Number = MagicNumber;
    
    }
    
    //--------------------------------------------------------------------
    // Trading rule: Short exit (On Bar Open)
    //--------------------------------------------------------------------                   
    if ((ShortExitSignal
       and Not ShortEntrySignal)
       and (MarketPosition("Any", MagicNumber, "") is Short))
    {
        // Action #1
        Close Full position for Symbol = Any and Magic Number = MagicNumber;
    
    }
    
    
    #237343
    Customer
    7 Posts

    Here is the zorro code for anyone who wants to try it themselves, the SQ code is above. The SQ Strategy says Sharpe of 4.12, Profit factor of 3.82. No Losing years. Yet when I run in Zorro it has Annual Return of -18%   PF 0.02, and a Sharpe of -0.69.

     

    
    //--------------------------------------------------------------------
    // Zorro Source Code of Strategy 0.899785
    //
    //--------------------------------------------------------------------
    
    function run()
    {
    StartDate = 2010;
    EndDate = 2015; // fixed simulation period 2010-2015
    
    BarPeriod = 15; //
    LookBack = 200;
    MaxLong = MaxShort = 1;
    
    //--------------------------------------------------------------------
    // Trading rule: Trading signals (On Bar Open)
    //--------------------------------------------------------------------
    
    /*
    ADX(int TimePeriod): var
    Average Directional Movement Index. Moving average of the DX indicator (see below). Uses the current asset price series. Does not support TimeFrame. The returned values range from 0 to 100.
    */
    
    vars close = series ( priceClose() );
    vars mDI = series( MinusDI( 14 ) );
    var *atr = series( ATR( 40 ) );
    
    bool LongEntrySignal ;
    bool ShortEntrySignal;
    bool LongExitSignal = false;
    bool ShortExitSignal = false;
    
    LongEntrySignal = mDI[1] > mDI[2];
    ShortEntrySignal = mDI[1] < mDI[2];
    
    //--------------------------------------------------------------------
    // Trading rule: Long entry (On Bar Open)
    //--------------------------------------------------------------------
    if ( LongEntrySignal )
    {
    LifeTime = 7;
    EntryTime = 1;
    Stop = 75 * PIP;
    TakeProfit = 195 * PIP;
    Trail = 135 * PIP;
    TrailLock = 1 * PIP;
    Entry = close[3] + ( 2 * atr[1] );
    enterLong();
    
    }
    
    //--------------------------------------------------------------------
    // Trading rule: Short entry (On Bar Open)
    //--------------------------------------------------------------------
    if ((ShortEntrySignal
    and !LongEntrySignal))
    {
    // Action #1
    LifeTime = 7;
    EntryTime = 1;
    Stop = 75 * PIP;
    TakeProfit = 195 * PIP;
    Trail = 135 * PIP;
    TrailLock = 1 * PIP;
    Entry = close[3] - ( 2 * atr[1] );
    enterShort();
    
    }
    
    plot("mDI", mDI, NEW, RED );
    
    }
    
    
    #237349
    Customer
    248 Posts

    please attach *.sqx file

    So we can make a mt4 backtest and compare the trades.

    If the strategyquant 4.x have a problem than the metatrader backtest is different.

     

    thomas

    https://monitortool.jimdofree.com/

    #237351
    Customer
    7 Posts

    Hi Tomas, Attached is the last strategy posted above.

    Attachments:
    You must be logged in to view attached files.
    #237390
    Customer
    430 Posts

    This strategy totally fails when I test it in SQX.  Check your data Quality or settings.

    Attachments:
    You must be logged in to view attached files.
Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.