MQL5 Code doesn't do multi time frame

Unless I am missing something, I don't think MQL 5 code is doing multi time frames. I have attached configs, mql5 code, pseudo code and mql4 code for multi time frame strategy generated. mql4 seems to have subchart included, mt5 does not, which results in "indicators not loaded" errors when trying to run in mt5. 



The entry signal on mt4 is 

     // init signals only on bar open

     LongEntrySignal = ((((sqGetValue("NULL",0, PRICE_OPEN, 1) > sqBands(NULL,0, BBBarOpensPeriod, 2, 0, PRICE_CLOSE, 1, 1))&&(sqGetValue("NULL",0, PRICE_OPEN, 0) < sqBands(NULL,0, BBBarOpensPeriod, 2, 0, PRICE_CLOSE, 1, 1)))

      && (sqCCI(NULL,0, CCIPeriod, PRICE_CLOSE, 2)>-55))

      && (sqKeltnerChannel(Subchart1Symbol, Subchart1Timeframe, KCerPeriod, 2, 1, 4+1)>sqKeltnerChannel(Subchart1Symbol, Subchart1Timeframe, KCerPeriod, 2, 1, 4)));


On mt5, it is



     // init signals only on bar open

     LongEntrySignal = (((sqOpen("NULL",0, 1) > sqGetIndicatorValue(BOLLINGERBANDS_1, 2, 1, true) && sqOpen("NULL",0, 0) < sqGetIndicatorValue(BOLLINGERBANDS_1, 2, 1, true))

      &&   (sqGetIndicatorValue(CCI_1, 2)>-55.0))

      &&   sqIsFalling(KELTNERCHANNEL_1, 2, false, 4, 1));


I am a complete beginner, so help would be appreciated.


Thanks 



Attachments
Strategy 311300.mq5
(199.61 KiB)
Strategy 311300.mq4
(208.09 KiB)
Build strategies.cfx
(24.75 KiB)
Strategy 311300.sqx
(146.49 KiB)
Strategy 311300.txt
(4.03 KiB)
  • Votes 0
  • Project StrategyQuant X
  • Type Bug
  • Status Fixed
  • Priority Normal

History

GA
#1

GaryAitcheson

17.12.2019 11:01

Task created

TB
#2

Tomas Brynda

17.12.2019 13:22

Status changed from New to Fixed

Attachment screen.png added

Hi GaryAitcheson,

during export from SQ to MQL code, the subchart symbols are filled as they are in SQ. 


When running multi-chart or multi-timeframe EAs in your terminal, you must set up the correct symbols in your EA parameters.

See the attached screenshot. If you set the correct symbol, the EA should run normally.


Hope this helps


Best regards,

Tomas

GA
#3

GaryAitcheson

17.12.2019 16:41

Description changed:

Unless I am missing something, I don't think MQL 5 code is doing multi time frames. I have attached configs, mql5 code, pseudo code and mql4 code for multi time frame strategy generated. mql4 seems to have subchart included, mt5 does not, which results in "indicators not loaded" errors when trying to run in mt5. 



The entry signal on mt4 is 

     // init signals only on bar open

     LongEntrySignal = ((((sqGetValue("NULL",0, PRICE_OPEN, 1) > sqBands(NULL,0, BBBarOpensPeriod, 2, 0, PRICE_CLOSE, 1, 1))&&(sqGetValue("NULL",0, PRICE_OPEN, 0) < sqBands(NULL,0, BBBarOpensPeriod, 2, 0, PRICE_CLOSE, 1, 1)))

      && (sqCCI(NULL,0, CCIPeriod, PRICE_CLOSE, 2)>-55))

      && (sqKeltnerChannel(Subchart1Symbol, Subchart1Timeframe, KCerPeriod, 2, 1, 4+1)>sqKeltnerChannel(Subchart1Symbol, Subchart1Timeframe, KCerPeriod, 2, 1, 4)));


On mt5, it is



     // init signals only on bar open

     LongEntrySignal = (((sqOpen("NULL",0, 1) > sqGetIndicatorValue(BOLLINGERBANDS_1, 2, 1, true) && sqOpen("NULL",0, 0) < sqGetIndicatorValue(BOLLINGERBANDS_1, 2, 1, true))

      &&   (sqGetIndicatorValue(CCI_1, 2)>-55.0))

      &&   sqIsFalling(KELTNERCHANNEL_1, 2, false, 4, 1));


I am a complete beginner, so help would be appreciated.


Thanks 



Thank you Tomas

I managed to get this to export mql5 properly on another computer running strategyquant. I think the problem is that I installed SQ as a non-administrator on my windows server. I have had problems doing this before, and it works now that I have installed it as Administrator. I'm not sure why that should be, but there it is. 


Thank you for your help.


Gary

h
#4

hankeys

18.12.2019 07:47
but where is the subchart called in the MQL5 code?


&&   sqIsFalling(KELTNERCHANNEL_1, 2false41));

GA
#5

GaryAitcheson

18.12.2019 16:01

Attachment MQL5 Code.txt added

Attachment MQL4 Code.txt added

Attachment Pseudo Code.txt added

Attachment Strategy 416375.sqx added

Sorry guys, there does seem to be a problem with the mt5 code being generated. I have tried this on many strategies now (H1 and D1) and each time it gets the exit signals right but leaves out the subchart on the entry signals. 


The MQL 4 code includes the subchart ok, the MQL 5 does not. 


Here's another example attached. 

GA
#6

GaryAitcheson

18.12.2019 21:00
OK, so I think I have sorted it now. The sub chart is defined as iCustom above.


Working now

TB
#7

Tomas Brynda

19.12.2019 08:27
Yes, you are right, the subcharts are used when creating indicator handles.


You can take a look into initIndicators() function in MQL to see how the indicators are set up during EA initialization.



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