Automatic string building for a comment
-
Hello
Please I would need some help to figure out what I would like to build.
Thanks to @roar I have been able to open several trades using his loop logic suggestion. Thanks to @miro1360 I could add the group number for each trade created by the loop into the "comment" field.
Then, the logic to open the trades is as follows:
n_Trades = 10 (loop Will pass 10 times)
Loop -> Trade1 (Id =1), Trade2 (Id = 2), …, Trade10 (Id = 10)n_Trades = n (loop Will pass n times)
Loop -> Trade1 (Id =1), Trade2 (Id = 2), …, Trade(n-1) (Id = n-1), Trade(n) (Id = n)What I would like to have is a block placed in the loop's logic that automatically creates a string that includes all the opened Id trades from the first one to the last one. Something like
AllOpenIds = (string)Id1","+(string)Id2","+ … +(string)Id(n-1)","+(string)Id(n);

Because the number of trades to be opened is a variable, the string content will also be variable depending on how many trades the loop opens.
Any help Will be very welcome.
Thanks
-
Do you want to append data to commentM3? Because now the value of commentM3 will be whatever the value is set in the last iteration of the loop.
-
Hi @fxDreema
Thanks for your support.
What I would like to have is a way to automatically create a string to manage the opened trades in blocks like "For each trade".
As an example. My Project opens (n) trades when the condition to enter at market is met. The loop creates (n) trades labelling each trade with a unique group number using a variable that is modified each time that loop passes:


Then, if n = 6 & positionIdBuy = 0, it is opened 6 trades with group numbers: 1,2,3,4,5,6.
I have created a string for using it in the "Filter by group" field available in blocks like the pink ones to do something depending on the conditions of the trade with the last group number. Like as follows


So, if (n) = 6, "LastTradeNumberBuysM3 = 6". But if the project's logic decides to open 10 trades (n = 10), the variable "LastTradeNumberBuysM3" Will be modified automatically to 10.
What I would like is to know if it is posible to create automatically a string that includes the group number of all the trades opened by the loop as the loop is ran. Like
loop pass = 1 -> TradesOpened=(string)positionId1;
loop pass = 2 -> TradesOpened=(string)positionId1+","+(string)positionId2;
loop pass = 3 -> TradesOpened=(string)positionId1+","+(string)positionId2+","+(string)positionId3;
.
.
.
loop pass = (n) -> TradesOpened=(string)positionId1+","+(string)positionId2+","+(string)positionId3+","+…+(string)positionId(n);Then, the result string Will be:
loop pass = 1 -> TradesOpened=1
loop pass = 2 -> TradesOpened=1,2
loop pass = 3 -> TradesOpened=1,2,3
.
.
.
loop pass = (n) -> TradesOpened=1,2,3,...,(n)Any suggestion or idea Will be very welcome.