How to do I build a multi timeframe\symbol portfolio?
-
@sktsec any advice on the previous post?
-
if a then b=1; if a then b=2; -> b must be 2
if a then b=1 else if a then b=2 -> b must be 1I am afraid the logic is clear.
In your case, it may need an array to handle the list of TFs
-
@gooseman oh, you need to repeat the same symbol on multiple timeframes?

Then I think its best to use the Set TF loop block with multiple fixed timeframes (just put all the timeframes you ever use in this block).
Next 2 blocks will filter out the symbol-timeframe pairs that are not allowed. Then we continue with the rsi target setting block.
And yes, we can use the pipes again, but only in the condition block
https://fxdreema.com/shared/aGKfK5Btd -
@roar hmm. ive tried what you suggested and its trading but something isnt right. I say that because im comparing the total trades to my historical test and getting lower results. So I just wanted to make sure were on the same page here. Here is a small sample of the portfolio. Each row is independant from each other, an asset. Column D are the historical total trades of n years. The ones that are marked with the red line, ive ammended to the project


This will backtest all symbols but not all trades. in other words, the total trades do not match my historical total trades (352 trades) I can confirm symbols being traded but not sure if its either the TF or LV variable is the culprit here. I understand the mql code but guess what I dont understand is the logic here so please forgive me if im repeating myself here. Once this portfolio is live, my next step is learn how to code in mql5. Between you guys helping, chatgpt, mql5 youtube videos, Im finding it more interesting and cant wait. so thank you guys for being patient with me.
-
@roar ive turned the RSI parameter to a constant instead of a variable. Now each RSI parameter has its own set of blocks.

now that we have the TF and SYMBOL as variables

CADCHF H1 has 142 historical trades
CADCHF H2 has 101 historical tradesI've removed the code and tested it individually and does return the correct amount of trades. but when together
(market == "CADCHF_QDM_FTMO_II" && (TF == PERIOD_H2 || TF == PERIOD_H1))I get a total result of 190 when it should be 243 total amount of trades. any ideas?

EDIT
Ive tried out the old code as well:
if(market == "CADCHF_QDM_FTMO_II") { TF = PERIOD_H1; } if(market == "CADCHF_QDM_FTMO_II") { TF = PERIOD_H2; }This results in H1 only being traded. H2 is ignored.
-
@roar finally! no more error codes! I eliminated the LV variable and made that into different constants instead and created separate block structures for each of those LV. I coded all the symbol and TF into the project and I loaded up the robot on a demo last night to see if I woke up to any codes. I woke up and found no codes and its trading! the portfolio still doesn't match historical results

A - Current version
B - Original versionbut it is fine! ill run with this portfolio in the meantime. I will learn mql5 language and dissect this portfolio and get it running at 100%. still! missing over 4k trades is not bad at all. Thanks @roar @sktsec for the help. I really appreciate it.
-
Hey, @roar !
I'm using your example here as a learning opportunity for myself.
I have a question (I'm trying to learn arrays). In this instance, what was the purpose of subtracting one off of the loop id pre block, but then adding it back on after?
Wouldn't this mean that it would keep doing the same index in the array repeatedly and never move on to another?

-
Hi @MrDaisyBates! I'm not subtracting one off, I'm setting its value to exactly -1. Furthermore, the white section executes only once, even with loop blocks. Orange section executes for each loop iteration.
So effectively the loop_id is -1 before the loop starts, and it will be 0 when the loop starts working with the array. You need to start at 0 with arrays.
-
@roar AH! Okay! Thanks!
So, it sets it to -1 on the initial hit, it obviously exits on the "true" side of the block, which takes it to 0, which is used for the first index of the array. And then each time the loop completes, it comes all the way back to the "loop" block, adds one, and keeps going until the loop breaks?
I'm okay with the loop idea, but I'm still new with arrays. Will this "Loop" block (I've never used it) break (give a false output) if we get to an index one larger than the array? Or does this specific loop actually break on the "Set Market" block when we hit the snag of trying to load an index that doesn't exist?
-
@MrDaisyBates the loop works as you described in the upper part of you reply.
It doesnt automatically break if the array range is exceeded, but when you set "Cycles" to ArraySize(), this shouldn't be a problem.
-
@roar Gotcha! Thanks again. That makes sense.