RC2 - Multi-Symbol strategy generation uses illogical comparisons.

Hi Team,



Using RC2 I have now been able to generate some multi-symbol strategies.


However, the generated rules are comparing the main chart data against the sub-chart data.  Below is some MQ4 generated for such generated strategies.


The main chart in this example was EURUSD and the sub-chart 1 was USDJPY.  It makes no logical sense to take the Close price of EURUSD and compare that to the moving-average price of USDJPY.


   //------------------------
   // Rule: Trading signals
   //------------------------
   if (sqIsBarOpen()) {
     // init signals only on bar open 
     LongEntrySignal = (((Close[1] > sqBands(NULL,0, 50, 2.1, 0, PRICE_CLOSE, 1, 1))
      && (Close[1] < sqMA(NULL,0, 50, 0, 3, PRICE_CLOSE, 1)))
      && (Close[1] < sqMA(Subchart1Symbol, Subchart1Timeframe, 12, 0, 2, PRICE_HIGH, 1)));


     ShortEntrySignal = (((Close[1] < sqBands(NULL,0, 50, 2.1, 0, PRICE_CLOSE, 0, 1))
      && (Close[1] > sqMA(NULL,0, 50, 0, 3, PRICE_CLOSE, 1)))
      && (Close[1] > sqMA(Subchart1Symbol, Subchart1Timeframe, 12, 0, 2, PRICE_HIGH, 1)));


When making any comparisons, it is safest in the simplest case to only compare main-chart values with main-chart values and sub-chart1 values with other sub-chart1 values and sub-chart2 values with other sub-chart2 values.  In a more complex sense, building blocks that return values in a fixed range, such a percentages or RSI could be compared across symbols.


Clearly the closing price of one currency should not be compared against some price of a different currency pair.  In the example above, the MQ4 should be:


   //------------------------
   // Rule: Trading signals
   //------------------------
   if (sqIsBarOpen()) {
     // init signals only on bar open 
     LongEntrySignal = (((Close[1] > sqBands(NULL,0, 50, 2.1, 0, PRICE_CLOSE, 1, 1))
      && (Close[1] < sqMA(NULL,0, 50, 0, 3, PRICE_CLOSE, 1)))
      && (iClose(Subchart1Symbol, Subchart1Timeframe, 1) < sqMA(Subchart1Symbol, Subchart1Timeframe, 12, 0, 2, PRICE_HIGH, 1)));


     ShortEntrySignal = (((Close[1] < sqBands(NULL,0, 50, 2.1, 0, PRICE_CLOSE, 0, 1))
      && (Close[1] > sqMA(NULL,0, 50, 0, 3, PRICE_CLOSE, 1)))
      && (iClose(Subchart1Symbol, Subchart1Timeframe, 1) > sqMA(Subchart1Symbol, Subchart1Timeframe, 12, 0, 2, PRICE_HIGH, 1)));


https://docs.mql4.com/series/iclose

And the pseudocode should be:


//--------------------------------------------------------------------
// Trading rule: Trading signals (On Bar Open)
//--------------------------------------------------------------------                   
LongEntrySignal = ((Close above BollingerBands(Main chart,50, 2.1).LowerBand
   and (Bar closes below LinearWeighted Moving Average(Main chart,50)))
   and (Bar(Subchart1) closes below Smoothed Moving Average(Subchart1, D1,12)));


ShortEntrySignal = ((Close below BollingerBands(Main chart,50, 2.1).UpperBand
   and (Bar closes above LinearWeighted Moving Average(Main chart,50)))
   and (Bar(Subchart1) closes above Smoothed Moving Average(Subchart1, D1,12)));


instead of just Bar

Please fix this.


Thanks & Regards,


Mike

Attachments
No attachments
  • Votes 0
  • Project StrategyQuant X
  • Type Bug
  • Status Fixed
  • Priority Normal

History

m
#1

mikeyc

20.05.2018 10:54

Task created

m
#2

mikeyc

20.05.2018 11:09

Description changed:

Hi Team,



Using RC2 I have now been able to generate some multi-symbol strategies.


However, the generated rules are comparing the main chart data against the sub-chart data.  Below is some MQ4 generated for such generated strategies.


The main chart in this example was EURUSD and the sub-chart 1 was USDJPY.  It makes no logical sense to take the Close price of EURUSD and compare that to the moving-average price of USDJPY.


   //------------------------
   // Rule: Trading signals
   //------------------------
   if (sqIsBarOpen()) {
     // init signals only on bar open 
     LongEntrySignal = (((Close[1] > sqBands(NULL,0, 50, 2.1, 0, PRICE_CLOSE, 1, 1))
      && (Close[1] < sqMA(NULL,0, 50, 0, 3, PRICE_CLOSE, 1)))
      && (Close[1] < sqMA(Subchart1Symbol, Subchart1Timeframe, 12, 0, 2, PRICE_HIGH, 1)));


     ShortEntrySignal = (((Close[1] < sqBands(NULL,0, 50, 2.1, 0, PRICE_CLOSE, 0, 1))
      && (Close[1] > sqMA(NULL,0, 50, 0, 3, PRICE_CLOSE, 1)))
      && (Close[1] > sqMA(Subchart1Symbol, Subchart1Timeframe, 12, 0, 2, PRICE_HIGH, 1)));


When making any comparisons, it is safest in the simplest case to only compare main-chart values with main-chart values and sub-chart1 values with other sub-chart1 values and sub-chart2 values with other sub-chart2 values.  In a more complex sense, building blocks that return values in a fixed range, such a percentages or RSI could be compared across symbols.


Clearly the closing price of one currency should not be compared against some price of a different currency pair.  In the example above, the MQ4 should be:


   //------------------------
   // Rule: Trading signals
   //------------------------
   if (sqIsBarOpen()) {
     // init signals only on bar open 
     LongEntrySignal = (((Close[1] > sqBands(NULL,0, 50, 2.1, 0, PRICE_CLOSE, 1, 1))
      && (Close[1] < sqMA(NULL,0, 50, 0, 3, PRICE_CLOSE, 1)))
      && (iClose(Subchart1Symbol, Subchart1Timeframe, 1) < sqMA(Subchart1Symbol, Subchart1Timeframe, 12, 0, 2, PRICE_HIGH, 1)));


     ShortEntrySignal = (((Close[1] < sqBands(NULL,0, 50, 2.1, 0, PRICE_CLOSE, 0, 1))
      && (Close[1] > sqMA(NULL,0, 50, 0, 3, PRICE_CLOSE, 1)))
      && (iClose(Subchart1Symbol, Subchart1Timeframe, 1) > sqMA(Subchart1Symbol, Subchart1Timeframe, 12, 0, 2, PRICE_HIGH, 1)));


https://docs.mql4.com/series/iclose

And the pseudocode should be:


//--------------------------------------------------------------------

// Trading rule: Trading signals (On Bar Open)

//--------------------------------------------------------------------                   

LongEntrySignal = ((Close above BollingerBands(Main chart,50, 2.1).LowerBand

   and (Bar closes below LinearWeighted Moving Average(Main chart,50)))

   and (Bar(Subchart1) closes below Smoothed Moving Average(Subchart1, D1,12)));


ShortEntrySignal = ((Close below BollingerBands(Main chart,50, 2.1).UpperBand

   and (Bar closes above LinearWeighted Moving Average(Main chart,50)))

   and (Bar(Subchart1) closes above Smoothed Moving Average(Subchart1, D1,12)));


instead of just Bar


Please fix this.


Thanks & Regards,


Mike

m
#3

mikeyc

21.05.2018 19:45
This is related to the same issue that has plagued the beta versions too.  See https://roadmap.strategyquant.com/tasks/sq4_0264
MF
#4

Mark Fric

27.05.2018 10:56

Status changed from New to Fixed

fixed in RC3

Votes: 0

Drop files to upload

or

choose files

Max size: 5MB

Not allowed: exe, msi, application, reg, php, js, htaccess, htpasswd, gitignore

...
Wait please