Jump to content

Most Liked Content

#9335 [How To] Tune SQ for max performance and reduce memory usage by 4 to 5 times

Posted by geektrader on 22 March 2015 - 08:27 PM

Updated 10. April 2016 to reflect the default garbage collector change in Java 9:


Hi Guys,


throughout the last year I have been fine-tuning SQ by the various Java (which SQ runs on) options that you can pass on to it during start-up. I am now satisfied with the performance and on the same side heavy reduction in memory usage that I´ve achieved through fine-tuning the Java options.


Just use this line to launch SQ with max performance and as low as possible memory usage:


StrategyQuant64.exe -J-server -J-Xmx13g -J-XX:+DisableExplicitGC -J-XX:+AggressiveOpts -J-XX:+UseSerialGC


                                                    ^^ please adjust the "-J-Xmx13g" to the memory you want to assign to SQ (and which you really have free!) as max allowed amount. E.g. if you want to allow it 6GB max, use "-J-Xmx6g" instead.


Additionally to this launch-line, I´d also recommend to replace the JVM from Oracle to the one from Zulu, you will get even more speed and less RAM usage with this one as it is a straight build of the OpenJDK sources (the original Java) without Oracles branding and other things added to it. You can get it here: http://www.azulsyste.../zulu/downloads . There also currently is a dedicated page for the new Java 9 beta which also works fine and is even faster than Java 8, but only up to version since changes in Java 9 that have been adapted in later builds won´t work anymore with SQ 3.8.1, you can download it here: http://cdn.azul.com/...0.0-win_x64.zip .


Just install it and afterwards rename the directory "j64" in your StrategyQuant directory to "j64.old". Create a new "j64" directory and copy the complete Zulu installation (usually from C:\Program Files\Java.....) into the newly created "j64" directory.


Please compare on your own how SQ runs without any parameters and with my command line and the JVM replaced. You´ll see that when starting to build strategies that alone in the first 2 minutes of building RAM usage will be half with my command line than SQ without my command line. Then have fun building strategies even faster and with less RAM than before now and make some money hopefully:)

#22324 SQ4 early preview

Posted by Mark Fric on 01 April 2017 - 08:07 AM

Hello, I'm bringing news of the Beta version. I really wanted to publish it this week as promised, we worked 10 hours a day for the last two weeks to get it done.


Beta is almost ready, all the features are working, but with all the development we had no time for proper testing. It is not yet made "foolproof" so that it could be used by "normal' users.


In the current state it is very unstable, and it would make no sense to give it out when there are bugs or configuration checks that we know have to be fixed.


So we have to will finalize and test it thoroughly, smooth the edges, and then present a version that can be really used. I expect we'll have it ready by the next week, we are really very close.


I'm at least publishing a few screenshots from the new SQ4 below. You'll notice we use new updated UI that should be more intuitive and simple to use.

Click on the images to get bigger version.

















#18235 Video Tutorial SQ Max Speed & Performance CPU,Ram,Disk & Extra 6k Str...

Posted by gentmat on 09 July 2016 - 09:45 PM

// This is the link of the video , Check it out hopefully you will like it . YES i am arabic and the accent follows
me to death so if you have a problem with it "I am verry Sorry but i have to KILL YOU"

A big credit goes to "GeekTrader" , This Video tutorial is to teach you how to max speed of SQ 3 .
Tweaking CPU,rams and hard drives / SSD 's

The original post is like 10 pages + which seems bit complicated for beginners here so i explained it
step by step in this video + added more tweaks of my own (Hope it helps out beginners and even pro users of SQ).

End of the video is a quest for people to contribute more by filtering some good strategies and show us the procedure .. I am sure each pro will choose a different strategy(ies) we got to learn from the contributes.

Links of the video:

* Strategies : https://drive.google...iew?usp=sharing

* Java Version 9 : http://cdn.azul.com/...pre/bin/zulu...

* The scipt To use for the batch opening of SQ, Create new .bat file and add these line of codes and press
save . Watch the video to learn how to tweak the parameters.




@echo off
set NumberOfSQInstances=10
set MainSQLocation=C:/StrategyQuant
set TempSQLocation=C:/temp
set SQParameters=-J-server -J-Xmx1g -J-XX:+DisableExplicitGC -J-XX:+AggressiveOpts -J-XX:+UseSerialGC 
rmdir "%MainSQLocation%/temp" /S /Q
rmdir "%MainSQLocation%/log" /S /Q
rmdir "%TempSQLocation%/strategyquant-temp" /S /Q
mkdir "%TempSQLocation%/strategyquant-temp"
FOR /L %%A IN (1,1,%NumberOfSQInstances%) DO (
mkdir "%TempSQLocation%/strategyquant-temp/%%A"
FOR /L %%A IN (1,1,%NumberOfSQInstances%) DO (
compact /c /s:"%TempSQLocation%/strategyquant-temp/%%A"
FOR /L %%A IN (1,1,%NumberOfSQInstances%) DO (
xcopy "%MainSQLocation%" "%TempSQLocation%/strategyquant-temp/%%A" /E /Y
CD "%TempSQLocation%/strategyquant-temp/%%A"
start /LOW StrategyQuant64.exe %SQParameters%

This is a new Script if you want to rename each instance so you can know each instance job . ( if you do not need this option use the above code )
1- NumberOfSQInstances= "to whatever number of instance you want to run" Lets say "X" instances
2- set arrayline[1]=CrossMaStrategyInstance
set arrayline[2]=RSIStrategyInstance
.... Continue declaring more to fit your X instances
lets say we want 3 instances so i ll add one more

The code is :


@echo off
setlocal enabledelayedexpansion
set NumberOfSQInstances=2
set arrayline[1]=CrossMaStrategyInstance
set arrayline[2]=RSIStrategyInstance
set MainSQLocation=C:/StrategyQuant
set TempSQLocation=C:/temp
set SQParameters=-J-server -J-Xmx1g -J-XX:+DisableExplicitGC -J-XX:+AggressiveOpts -J-XX:+UseSerialGC
rmdir "%MainSQLocation%/temp" /S /Q
rmdir "%MainSQLocation%/log" /S /Q
rmdir "%TempSQLocation%/strategyquant-temp" /S /Q
mkdir "%TempSQLocation%/strategyquant-temp"
FOR /L %%A IN (1,1,%NumberOfSQInstances%) DO (
mkdir "%TempSQLocation%/strategyquant-temp/!arrayline[%%A]!"
FOR /L %%A IN (1,1,%NumberOfSQInstances%) DO (
compact /c /s:"%TempSQLocation%/strategyquant-temp/!arrayline[%%A]!"
FOR /L %%A IN (1,1,%NumberOfSQInstances%) DO (
xcopy "%MainSQLocation%" "%TempSQLocation%/strategyquant-temp/!arrayline[%%A]!" /E /Y
CD "%TempSQLocation%/strategyquant-temp/!arrayline[%%A]!"
rename StrategyQuant64.exe !arrayline[%%A]!.exe
start /LOW !arrayline[%%A]!.exe %SQParameters%

#10485 [How To] Don´t forget the point value!

Posted by geektrader on 23 May 2015 - 02:12 AM

I´ve noticed many times that when people post their strategy results here that they are not taking into the account the actual point value SQ allows to set. The point value (a multiple of the tick value) needs to be set correct in relation to your account base currency.


For example: your account is USD based and you trade the EURUSD. EURUSD is nominated in USD, so any profit / loss coming from it is already in USD by nature and if your account is USD based, the conversion of the profit from this pair to your account base currency would be "1". However, the fun begins if you start trading the EURAUD on your USD based account. On EURAUD, any profit / loss is given in AUD and that needs to be converted to your account base currency into USD. As of right now this would mean that for your USD based account:


EURUSD 1 lot, 1 pip movement = 10 USD

EURAUD 1 lot, 1 pip movement = ~8 USD


Your broker does this automatically in realtime when you trade and showing your profits, but when you backtest in SQ and create strategies, this is a whole different story and is NOT taken into account if you don´t account for it in SQ in the Data Manager.


So how do we address this problem in SQ? Via the "Point Value in $" field of each pair in the Data Manager!


As an example, here is a screenshot of my current setup for USD based accounts, using rates from May 2015:




Remember that this is for a USD based account. For EUR based accounts, these values are completely different, as for example if EURUSD is being traded on a EUR based account, the profit / loss of that pair that is expressed in USD, needs to be converted to your account base currency EUR.


Again, your broker does this all in realtime with the current rates, SQ does not, and you need to adjust it steadily (I update the point values once a month) as they are just as fluctuating like any currency pair, since it is nothing else than a steady currency conversion from the currency each pair is nominated in to your account base currency.


So how do you obtain these point values for your account base currency? It´s easy, go to http://www.xe.com/currencyconverter/#and in the first row you selected the currency the pair you want to trade is denominated in. For EURUSD that = USD. For GBPAUD = AUD. For EURAUD = AUD. For USDCHF = CHF, for GBPCHF = CHF. I think you get the idea. In the second row simply select your account base currency. Now press the "Play" button and you will get the current exchange rate. Multiply that by 100000 and enter it into the "Point Value in $" field in the SQ Data Manager.


Let´s go through setting up the point value for EURAUD for a USD based trading account:


1) Go to: http://www.xe.com/cu...From=AUD&To=USD

2) Current rate is 

1.00 AUD = 0.782890 USD

3) Multiply 0.782890 by 100.000

4) = 78289 which is the point value you enter for EURAUD in the SQ Data Manager!


Voila, now your backtests will reflect the reality a lot better. As you see using the correct point value can make a HUGE difference in your backtests as some pairs like EURAUD like in the example above, which is traded on a USD based trading account, has a tick value of just 0.78, which means your backtests that possibly are using a tick value of 1 (or a Point Value of 100.000 in that case) will in reality just have 78% of the values in terms of Net Profit and Drawdown if the corrent point value for your account base currency is used. This is ESPECIALLY important if you create portfolios as the relations between the pairs, Net Profit and total portfolio Drawdown can change a lot if you use the correct point value.


Good luck:)

#20859 My workflow

Posted by GACKT on 07 January 2017 - 03:38 PM

Good day all,


Happy new year 2017!

I wish you a new year full of health, wealth, love and happiness.


First of all, I would like to express deep gratitude for this amazing beautiful software.


After 6 months of usage I am now fully familiarized with every part of it, so I thought I'd share my current workflow.


Feel free to share thoughts and input.



SQ Workflow

- Correct and appropriate data & strategy settings for market before generation, such as:
    - Data Manager data import & settings
    - Performance settings: many cores + don't store orders
    - As long dataset as possible, longer OOS preferable,
      although generation can be done on shorter dataset for the sake of speed,
      however always verify on maximum data, the longer viability the better robustness
    - For M15 and lower, generation on tick data is preferable, otherwise M1
    - Trading times
    - Pip ranges
    - Strategy rules symmetry,
      my current is full symmetry to avoid overfitting
    - Genetic (with/without Training/Validation) vs. Random,
      my current is Genetic with Training/Validation
    - Fixed lot size for comparability, usually 0.1 per trade
    - 50 Databank entries
    - Loose dismissal conditions (pf 1.3, win rate 45%, number of trades)
    - Weighted fitness
- Sort Databank results on OOS Weighted Fitness. Check top to bottom.
  Analyze strategies' metrics and characteristics to get a full understanding, such as:
    - Net profit
    - Win rate
    - Drawdown
    - SQN
    - # of trades
    - Average trade
    - Return/DD
    - Profit factor
    - Equity curve shape
    - Stagnation
    - List of trades (see if one single trade takes up a big portion etc.)
    - Average/max win
    - Average/max loss
    - Average trade time all/win/loss
    - Symmetry
    - Performance year-on-year/times/days/months
    - Check logic of pseudo code
- Tick all appealing strategies (duplicates unnecessary) and send to Retest.
- Go to Retest, make all of it IS and verify any strategy on tick data.
- Check strategies' performance with higher spread and slippage.
- Run robustness test Randomize strategy parameters 20/20 with 200 MC.
  Preferably at least 50% of original performance at 95% confidence level, but at least
  profitable at 100% confidence level. Also study shape of curves, preferably bundled
  together with as little digression as possible. Be strict but not overly perfectionist.
  The goal is a complementary portfolio.
- Run robustness test Randomize trades order Exact, same analysis as above.
- Run robustness test Randomize trades order Resampling, at least profitable at
  100% confidence.
- If any strategy clears these steps, save str-file (copy from StrategyQuant>temp for smaller size),
  pseudo code-file and mq4-file with values to parameters.
- Test, analyze and verify strategy in Metatrader StrategyTester. Save report.
- If qualified, run Walk Forward Matrix:
    - Simulated, OOS 10-40-10, runs 5-30-5, preset parameters 20%, multiply step
      value by 3
    - Robustness score components:
        - 3x3 cells with at least 7 combinations
        - WF Net Profit Stability >= 50% (most important)
        - Max % Drawdown in one run <= 25%
        - Max Stagnation in % <= 35%
        - Net Profit in % of orig. strategy >= 50%
        - WF Sharpe Ratio Stability >= 50%
        - System Quality Number >= 2.8
        - WF Return/DD Stability >= 50%
    - Analyze 3D charts, in particular Bar Chart to double-check stability of
      WF runs with different values such as Net Profit, WF Net Profit Stability,
      Profit factor, Max DD %, SQN etc.
- If failed, strategy might be too lacking in robustness. Analyze, evaluate further and make
  overall judgment of tradeability thereafter. In any case, keep strategy files for future
  reference and inspiration.
- If succeeded, analyze how much performance gain by optimization and if extraordinarily
  appealing, analyze & log parameter values in "WF results & parameters" and recommended
  reoptimization guidelines. Possibly re-run WFM with only trade management parameters
  and only optimize those to avoid overfitting.
- Optional research: Improve strategy.

Attached Files

#15962 SQ4 early preview

Posted by Mark Fric on 24 March 2016 - 11:25 AM

Hello all, 


I'm publishing a screenshot of new StrategyQuant 4 UI. First of all, let me say that this is not a screenshot of real application, but the design how the user interface will look like.

We are currently in the process of implementing this new design.


We started working on new UI just recently. SQ4 engine (testing/trading and genetic) are 80% finished, and UI will be an "interface" to this engine.


What is worth mentioning:

  • It will be possible to start multiple tasks (Build, Testing, Optimizing) in parallel in the new SQ 4.
  • The new UI is made in HTML/JS. It will be installed and will behave like a standard desktop application, but it will also allow you to access and control SQ running remotely for example on VPS using your normal web browser (if you'll allow it in settings). There are some challenges making UI like this, but the benefits overweight the cons.
  • The testing engine in SQ4 already supports multi-symbol and multi-timeframe strategies
  • SQ4 will allow you to create your own building blocks / indicators
  • SQ4 is plugin-based, so it will be possible to extend it with new functionality
  • new Wizard will be an integral part of SQ4, and it will enable to create more complex strategies


Please give us some time to finish the things to the Alpha version, we will publish real testable application as soon as we'll have it.

The things are still in the heavy development, and we are still finding the best way to implement some of them.

The user interface of SQ4 will be little bit different than SQ3, but our aim is to make it more intuitive and simple, while allowing better configurability and flexibility,


New UI

Attached File  sq4_preview.png   198.49KB   147 downloads


Something for programmers - example MACD implementation source code in SQ4

Attached File  code_example.png   36.72KB   117 downloads



#19081 SQ4 early preview

Posted by Mark Fric on 05 September 2016 - 07:03 PM

Hello all,


preview of SQ4 is here and ready to download:




Let me know your opinions, I'm really interested in your impression :-)


As for bug tracker, we use one, but I think at this state it is better to discuss the issues and ideas on the forum. We'll start using bug system when the system will be in Beta version.

#18626 Workflow plan

Posted by Karish on 01 August 2016 - 02:06 PM

Right now i quit use SQ3, waiting for SQ4,


my workflow was:

#1 Random generation on M1/Tick (depends if searching for scalping or swing strategies),

[DATES IF M1: (IS)=Asirikuy From the beginning Till 2003 + OOS From 2003~Today]

[DATES IF TICK: (IS)=Ducascopy Tick From 2003 Till 2010 + OOS From 2010/2012~Today]

#2 Retest again on M1 + MonteCarlo, [SAME IS&OOS]

#3 Filter,

#4 Retest again on Tick + MonteCarlo, [SAME IS&OOS]

#5 Filter,

#6 personally i dont use WFM, i just run more then 2000 MonteCarlo with huge randomization of the data theoretically gives me the same thing (thats just my opinion i trust the MonteCarlo more),

     and i filter those strategies that are do not perform well after those MonteCarlo tests,

#7 Then i try the strategies that have passed the tests until now inside the Improver with M1 with different pair this time and try to get different results with slightly different parameters that i let it to randomize and i lock some parameters if needed, and then i will retest again on M1 + MonteCarlo,

#8 then retest again + MonteCarlo on Tick, [SAME IS&OOS]

#9 if some strategy passed the same testes on 2~3 pairs you got a robust strategy,

#10 forward test it immediately on demo account, after sometime restest it again with new data on SQ with the same settings, check if it fits the demo forward test,


[IF YES=Great open small live account and keep on going]

[IF NOT=Might wanna check your broker OR strategy's settings might be the time that is differs or daily open/close etc.. Try to find the problem.]


i will recommend as always to watch Threshold's videos about how to NOT over optimize the strategies and etc..

i will recommend as always the M1 data from Asirikuy also



I DO NOT use RealTicks testing, i prefer FIXED spread.

I DO NOT use WFA/WFM, takes time.., i rather prefer using 1000 MonteCarlo couple of times to randomize the results of it, 2 times minimum i can reach up to 10 times (10,000 MonteCarlo).

I DO NOT use OPTIMIZATION tab EVER!, you will break the strategy!, i rather use IMPROVER tab.

i DO NOT use OpenPrices when testing, i use SelectedTF.

i DO NOT use Time depended indicators (Pivots/Daily OHLC/Hour/Minute/Day) better that way, do not use any time indicators/parameters.

ALWAYS ALWAYS ALWAYS retest your strategy from SQ3 in MT4 backtester with the same settings/parameters/spread/data, BEFORE going realtime DEMO/LIVE, SQ3 can give different results then MT4, and after all you will be trading thru MT4 so you MUST retest and see if it gives you the same results!, MT4 backtester results are the results you must pay attention to and not SQ3 in case of different results in between them! (hopefully the new SQ4 backtester will fix some or all of the bugs in this part).

#23798 SQ4 early preview

Posted by Mark Fric on 22 May 2017 - 06:54 AM

we are doing our best to release it in May as I promised, which means it should be released next week by Wednesday.

#19516 SQ4 early preview

Posted by Mark Fric on 07 October 2016 - 01:07 PM

Hello all,


I'd like to announce that we just released a new SQ4 Alpha 2 version.


It is available from the preview page: http://www.strategyq....com/sq4preview


Please note that it is still only a preview version, not everything is working yet. There are perhaps not so many new things visible on the front, but many things have been done in the background.

I expect to release maybe one more Alpha version some time by the end of the month, and then later a Beta version with almost complete functionality.

#19027 SQ4 early preview

Posted by Mark Fric on 30 August 2016 - 01:53 PM

The plan is to release Alpha version next Monday (5th September), so stay tuned for a few more days :-)

#17311 SQ Video Guides

Posted by tomas262 on 29 May 2016 - 10:20 PM



yes, these bonus videos mentioned are now being prepared. Once they are ready they can be accessed by owners of SQ Pro license. Send me an email to support@strategyquant.com. I can let you know once its ready

#17245 Monte Carlo simulations seem to conclude nothing about future performance of...

Posted by geektrader on 26 May 2016 - 09:25 PM

@Treshold: that strategy you mention there, I run it exactly like that for 1,5 years already :) Think everyone of us has found it exactly like that, it´s one of the most common ones (break out). Anyhow, this one is liked by MC for the reason that it´s based on break outs. It also passes all tests here, even with distorted data (70% chance, 30% ATR variation, 400 tests). The reason though is this: it´s a breakout strategy based on rather big breakouts and big trailing values, it also refers to the last 300 highs or lows, so some distortion in the data, even heavy ones or variation of the parameters still lets it pass the MC fine because the breakouts anyway occur even in heavily distorted data. These type of strategies are favored by MC too.


However, I have a strategy which I´ve created about 6 years ago (not in SQ of course) which indeed refers to Open[85] and other very specific values in time. It also uses nice amount of parameters, quite a lot actually that we all would call curve-fitted. Yet this strategy performs well since 6 years! I did code it in SQ a while ago and run MC, any kind of test (apart from spread and slippage) made it look TERRIBLE - that kind of strategy that you would right away put to the bin. Yet it did better than most strategies I´ve ever created and that had a great MC. So yes, as I already mentioned in the initial post, strategies that don´t pass MC can as well be very profitable going forward, hence MC doesn´t say anything about future performance or stability, otherwise this 6 years old strategy should have failed already. That´s also what Daniel concludes and why I´ve posted this because I wanted to hear what others have found about this.


Actually it is also not to hard to simulate this. We can do it this way:


1) Create a strategy on data from 1989 to 2000

2) Run MC on that strategy also from 1989 to 2000 and note the results (good or bad MC?)

3) Now run the strategy on data from 2000 to 2016, note the results too (performed well or not?)

4) Note these results in Excel and do it for at least 100 strategies to get a meaningful statistical relevance.

5) See if any relation can be drawn between a good (pseudo) OOS performance from 2000 to 2016 and the MC simulation results on data from 1989 to 2000 (good MC = good pseudo OOS results in >50% of the cases?)


I think it´s indeed best to not start such topics here anymore. And actually I´ve kept most of the stuff I´ve found lately about creating more successful strategies and how to speed up SQ even further out of here already  since it´s not the first time that there is flaming instead of a good discussion evolving around such posts. It seems it´s just a minority here that wants to really discuss important topics about how to get profitable in automated trading apart from the usual "it should work like that but I have no evidence nor idea if it really does, I put it live and fail again, damn..." stuff and instead go in circles forever without making any money. Now I totally understand the value of a closed community where everyone paid to be part of it - you get great quality discussions instead of stupid flaming because everyone did put money on the table for it and really wants to succeed and learn something there. It´s a community free of time-wasters like we have many here unfortunately.


P.S.: Just got Daniels (unfortunately understandable) reply. Thanks to some of the users here that are not interested in a meaningful discussion but prefer to insult and flame in this thread:


"Hi Geektrader,

Thanks for letting me know, I’ll keep an eye on it! However I am not a big fan of flaming so I will refrain from getting into the aforementioned discussion. Thanks again for commenting,

Best Regards,


#22476 [TOOL] Find the "Point Value in $" in just 1-Click :)

Posted by Karish on 12 April 2017 - 12:55 AM

Just updated the accountdetails.ex4 script to give us the SQ's "Point Value in $" that we need when we import history data into SQ,




[10/05/2017]• Version 2 of the script is here!, now you can see the Point Value in ($) + Pip/Tick STEP + Pip/Tick SIZE, Basicaly all your "Symbol Info" settings in one place! :)







Enjoy!  :)

#18220 SQ4 early preview

Posted by Mark Fric on 08 July 2016 - 06:51 AM

our plan is to release Alpha version by the end of August, Beta and final version in autumn this year.

#17236 Monte Carlo simulations seem to conclude nothing about future performance of...

Posted by geektrader on 26 May 2016 - 07:46 PM

Pending live stats....
I try to stick close to what I've read from traders who been successful for 20+ years. Is Daniel successful in building systems? It seems he writes articles about what's not successful (and only data mines them?). Seems like hes still on the journey like many of us.


Yes indeed, but most of the time these are manual traders.... Daniel´s systems are picking up lately it seems, his approach is different, they data-mine on GPUs in the community, hence can test millions of combinations within a few minutes / hours. They explore the whole possible space of combinations by brute forcing it on this network of GPUs. Once a profitable system is found, they right away boot-strap the underlying data for a few million times and the system has to do well on all those data-sets as well, which eliminates mining bias by ~98%. Only then a system is being traded live, so far they have a few hundred fullfilling these and are making money if looking at the MyFxBooks of a few of the users that publish their portfolios (which you can freely compile with different portfolio theory algos).

#17014 Did anyone record the webinar of http://www.autotrading.academy/ ?

Posted by Threshold on 18 May 2016 - 09:26 PM

I am gona upload way better tutorials than them for FREE on youtube when SQ4 comes out just to spite these guys out of business ;)
I'll have to do more work on my portfolio and get it higher by the time SQ4 comes out (should have a lot of time if u kno what I mean) so I'll actually have real proof of work over them too. New server should be here before the weekend...
Free SQ resources and improved community performance is good for Marc... if its good for Marc he keeps updating which is good for us.

#15832 Lets share SQ's custom MQL4 functions here!

Posted by Karish on 15 March 2016 - 07:18 PM

Hi there fellow SQ users,

because few of us come from MQL4 programming prospective we have our own ideas how to improve the original SQ's MQL4 functionalities,

so.., i wanted to share some of mine "add-ons" that i've implemented into the original SQ's MQL4 files..

plus i want that everyone that had their SQ's MQL4 files somehow modified to share their modifications here with everyone also :)


ill start by sharing some of mine.. have fun!:






Open your "Main.tpl" file and insert the following code line somewhere under the "int start() {" and above the "drawStats();":

if(IsTesting()&&IsVisualMode()==false){ObjectsDeleteAll();} //Deletes all objects for faster MT4 backtesting..









Search for "MaxSlippage = 3;" inside the "PrintParameters.inc" file, then under that line insert the following code line:

extern double MaxSpread = 1.5; // << enter your maximum spread in PIPs here

Search for "void openPosition" inside the "MT4Functions.inc" file, then under the "if(sqIsTradeAllowed() == 1) {" insert the following peace of code:

         string OrderTypeString;
         if(orderType==OP_BUY)       OrderTypeString="#BUY";
         if(orderType==OP_SELL)      OrderTypeString="#SELL";
         if(orderType==OP_BUYLIMIT)  OrderTypeString="#BUY_LIMIT";
         if(orderType==OP_SELLLIMIT) OrderTypeString="#SELL_LIMIT";
         if(orderType==OP_BUYSTOP)   OrderTypeString="#BUY_STOP";
         if(orderType==OP_SELLSTOP)  OrderTypeString="#SELL_STOP";
         int orderStartPointInTime = GetTickCount();
         if(orderType==OP_BUY||orderType==OP_SELL){if(DoubleToStr((Ask - Bid)*gPointPow, 1)>DoubleToStr(MaxSpread, 1)){Log("#ERROR!: Order's ("+OrderTypeString+") Spread was too high, - (Current Spread: ("+DoubleToStr((Ask - Bid)*gPointPow, 1)+")>("+DoubleToStr(MaxSpread, 1)+" Maximum), Delayed.");Sleep(500);return(0);}}







• Determine if order closed by Stoploss/Takeprofit LOG NOTIFIER:


Open your "Main.tpl" file and insert the following code line somewhere under the "int start() {" and above the "drawStats();":


Open your "CustomCodeMT4,mq4" file and insert the following peace of code somewhere under the rest of the existing code that is already there..:

void Order_Closure_OfSLTP_Notifier()
   for(int i=OrdersHistoryTotal()-1;i>=0;i--){
   if(TimeCurrent()-OrderCloseTime()==0) //<< (ANTI LOOP FLOOD!)
      //#Determine if order closed by Stoploss/Takeprofit:
         string OrderTypeString;
         if(OrderType()==OP_BUY)       OrderTypeString="#BUY";
         if(OrderType()==OP_SELL)      OrderTypeString="#SELL";
         if(OrderType()==OP_BUYLIMIT)  OrderTypeString="#BUY_LIMIT";
         if(OrderType()==OP_SELLLIMIT) OrderTypeString="#SELL_LIMIT";
         if(OrderType()==OP_BUYSTOP)   OrderTypeString="#BUY_STOP";
         if(OrderType()==OP_SELLSTOP)  OrderTypeString="#SELL_STOP";
            if(OrderType()==OP_BUY&&OrderClosePrice()>=OrderTakeProfit()){Log("#Order: ("+OrderTypeString+" [Ticket: "+OrderTicket()+"]) was Closed By TP.");}
            if(OrderType()==OP_BUY&&OrderClosePrice()<=OrderStopLoss()){Log("#Order: ("+OrderTypeString+" [Ticket: "+OrderTicket()+"]) was Closed By SL.");}
            if(OrderType()==OP_SELL&&OrderClosePrice()<=OrderTakeProfit()){Log("#Order: ("+OrderTypeString+" [Ticket: "+OrderTicket()+"]) was Closed By TP.");}
            if(OrderType()==OP_SELL&&OrderClosePrice()>=OrderStopLoss()){Log("#Order: ("+OrderTypeString+" [Ticket: "+OrderTicket()+"]) was Closed By SL.");}




#14768 Fuzzy Logic - Alternative Genetic Programming approach

Posted by mikeyc on 02 February 2016 - 01:17 PM

Hi busy SQ dev team,


After spending many months using SQ3, one thing I have noticed is how brittle strategies can be.  I think this comes from strict binary rules which form the basis of the strategies.  For example RSI(n) > 50 and the output being place a trade or not place a trade.  This is great, but why trade at RSI(n) > 50 and not RSI(n) > 49.5?  And why place trade / not place trade?  Why not place large trade or place small trade? 


I've been thinking in many ways a trading strategy/robot is like a control system. Inputs are sensors (usualy based on price/past prices), the goal is to make money/place profitable trades.I am wondering if more robust and profitable strategies could be found by SQ if it used fuzzy logic instead of boolean logic?


Perhaps RSI(n) could be fuzzified into extreme oversold, oversold, slight oversold, neutral, slight overbought, overbought and extreme overbought fuzzy sets.  SQ could then use GP to find the fuzzy rules and the output would be a lot size to place as the order, so instead of buy and sell it might be buy small lot, buy medium lot, buy large lot. 


Some background that got me thinking along these lines:






The strict and abrupt boolean rules in the trading algorithms we have now and the noise and differences in broker data mean we have systems that don't cope well with noise and missing data in the real world.


Just some thoughts,





#14686 [Hack] Symmetric Genetic Optimization in SQ 3.8!

Posted by geektrader on 23 January 2016 - 07:59 AM

Hi Guys,


I had one of these "lightbulb" moments today after again having found a good strategy that though needed some SYMMETRIC optimization, which SQ 3.8 simply can´t perform right now. So I thought of a workaround and indeed have found one. You can "abuse" the "Build Strategies" function to run a symmetric genetic optimization the following way:




1) Chose the strategy that you want to optimize. Then create a extra directory for it and copy it there under X (replace with number of population size that you want to use) different filenames. In my case I did chose 576 for a test. It´s important that the STR files are ALL the same strategy, just have different file names. Speed Commanders "rename files automatically"-function for the copy command (F5) comes in handy when doing that and you can easily create thousand copies of the STR file in a few seconds (just recopy the already copied files again and again, you don´t have to press copy X hundred times;) ). The result should then look like this:




2) Load up SQ and go to the "Build Strategies" section. You first want to check "Genetic Evolution". Then you go to "Settings" -> "Genetic Options" and set it like in this screenshot (download the file to get it to full size):



P.S.: Forgot to add that to the screenshot, but I set "Max # of Generations" to 8000 to produce an "endless" run that goes until I stop it when I notice that fitness stagnates for a long time (half a day or something). 


3) You then set your other parameters (data, fitness goal, test precision etc) as usually and Start! If you did everything right and as described above, you will get a endless running (not limited to 15000 steps like in the optimizer and runs until you stop it, which you should do if the "best result" isn´t improving for hours) symmetric genetic optimization :) The results will pop-up in the "Databank" tab and if you´ve set everything right, they will ALL have the exact same setup as your initial strategy in terms of indicators and entry logic etc., but with symmetrically varied parameters for each indicator / stop loss / trailing stop, etc etc etc. Just sort the results the way you sort them in the optimizer, it works exactly the same.


4) Have fun:)