Strategy remembering individual trades

Questions about MultiCharts and user contributed studies.
User avatar
Lobo.Trader
Posts: 12
Joined: 26 Nov 2011
Location: Germany
Has thanked: 19 times
Been thanked: 6 times

Strategy remembering individual trades

Postby Lobo.Trader » 17 Dec 2011

Hello

Some background :

I wish to automatically trade SLV-ETF @ARCA , Long only , NO SL => NO Lever (1:1) and using a MC - Strategy running on a Server and controlling TWS/IB .

The strategy will StopBuy some ETF when certain price is achieved . As soon, as this trade is profitable I wish to protect this cash with SL and place next trade ...such increasing my position .

Let us assume now, that after (i.e.) the 1st purchase (BUY SLV) price drops again and floating loss is recognised . Strategy will stand-by until charting identifies , that new trade would be meaningfull . Once this happens , I than wish the strategy to place the next order , same approach => StopBuy of some ETF .
Lets assume, the purchase takes place , I would have double shares , 50% bought at Price A and 50% at B . I now wish to handle these two "trades" (virtually // RMMM) as seperate , manage their SL,TP, trailings and so forth as individual . Maybe sell B at profit whilst A keeps on "waiting" with floating loss . Comment : I am aware , that this is virtual .

Here the issue now : Some trades can last for weeks and months . How do I remember the keydata of each individual trade , so that the Strategy can run full RM/MM at all times ?
I will have to store the data one/one, for example in an array which continuously I could update .
I am new to MC and my experience has grown in MT4 . Which code allows me to save/load individual data , for example stored in an array or other variables , on my PC so that I can reload when needed (boot of PC after weekend or other) ?

Thanks

Lobo

User avatar
Lobo.Trader
Posts: 12
Joined: 26 Nov 2011
Location: Germany
Has thanked: 19 times
Been thanked: 6 times

Re: Strategy remembering individual trades

Postby Lobo.Trader » 20 Dec 2011

MC support sent me following recommendation :


Yesterday we had a conversation in the Live Chat regarding the coding question. I’ve consulted with the coder and he suggested to use the Global Variable.



Global Variables are the external dlls that help to share the information between the charts and third party applications. The information is stored in a shared memory space. External processes can access the data in the memory for further operations.



Global Variables are saved even if the terminal is closed or when the lights are off. So it means that the values of the variables are stored independently.



From Multicharts the Global variables functionality is accessed by PowerLanguage functions. Using Global Variables it is important to determine the read-write action time because the actions are performed on the script calculation.



Additional info on our discussion forum (https://www.multicharts.com/discussion/ ) and here:

viewtopic.php?t=2483

http://www.bigmiketrading.com/tradestat ... harts.html
Thx

Lobo

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Strategy remembering individual trades

Postby JoshM » 24 Dec 2011

Thanks for the update LoboTrader!

I wonder where the GlobalVariables are saved, if these aren't saved in memory (as the quote below suggests):
Global Variables are saved even if the terminal is closed or when the lights are off. So it means that the values of the variables are stored independently.
Who knows that?

Regards,
Josh

User avatar
Lobo.Trader
Posts: 12
Joined: 26 Nov 2011
Location: Germany
Has thanked: 19 times
Been thanked: 6 times

Re: Strategy remembering individual trades

Postby Lobo.Trader » 24 Dec 2011

Hello Josh & Merry Christmas :-)

I haven´t started yet , but reviewed allread the manuals and thread´s refered too by MC .

From that , my current understanding is , that one really has to add three pieces of software ( which all of them appear to be coded for TS-use and not specific for MC , amazing considering that MC is no "lowcost"-solution ) .

These are :
- ELCollections ...which provides a set of code to manage data into " List" & "Map´s" . It shall be the foundation for =>
- ADE : AllDataEverywhere . In this manual it states on page 15 :
Directory = ADE.Directory;
Returns the ADE root directory (C:\ADE by default). The ADE functions will store data in a subdirectory of this directory called “Data”. If you use the “ADE Generate Class” indicator, it will read class definitions from a subdirectory called “Classes”, and it will output the generated functions and indicator to a subdirectory called “Code”.

If you want to use a root directory other than C:\ADE (e.g. if you want to keep it on a different drive), you should modify this function to return that directory.
This I consider to be first part of a reply to your question => Seperate File on hard disk

- GV (GlobalVariable2.2.) .... at page 25 & 26 I could find :
Installation


1.) To begin, extract the file “GlobalVariable.dll” from the Global Variable download zip file and place it into a subdirectory of your choice. Then move this file from the subdirectory in which you placed it to your installation’s equivalent to the following subdirectory (substitute your current build number for the letters WXYZ and your current version number for 8.x):

C:\Program Files\TS 8.x (Build WXYZ)\Program\
2.) Next, import the studies and functions from the ELD file that is included in the zip file. Be sure to import the studies and functions contained in the supplied ELD file before attempting to open either of the demonstration workspaces. Please note: some real-time anti-virus/firewall/internet security (AV/IS) products may interfere with the importation of ELD files. If you experience difficulty importing the studies and functions from the ELD file, follow these steps:

a.) Disable the AV/IS product.
b.) Deselect the option to load the AV/IS product at Windows start-up if this option was previously selected in the AV/IS software.
c.) Reboot the computer.
d.) Import the ELD file.
e.) Re-select the option to load the AV/IS product at Windows start-up if desired.
f.) Re-start the AV/IS product.
g.) Reboot the computer and ensure that the AV/IS product is loaded at Windows start-up (if this option was selected in Step e.) above).

3.) Extract the two demonstration workspaces, GV Demo Workspace 1.tsw and GV Demo Workspace 2.tsw, from the zip file and place them into your installation’s equivalent to the following subdirectory for easy access (substitute your current build number for the letters WXYZ and your current version number for 8.x):

C:\Program Files\TS 8.x (Build WXYZ)\MyWork\

4.) View the ReadMe.txt file that is included in the downloaded zip package.

5.) The additional C++ code and project files included in the zip file can be viewed in Visual Studio® 6 in the normal manner.
So , I understand that global Variables would be stored in the
C:\Program Files\TS Support\MultiCharts (???)

Lobo

User avatar
Lobo.Trader
Posts: 12
Joined: 26 Nov 2011
Location: Germany
Has thanked: 19 times
Been thanked: 6 times

Re: Strategy remembering individual trades

Postby Lobo.Trader » 26 Jan 2012

@JoshM

have more experiance now :

Code: Select all

Inputs: FileName ( "C:\ADE\Data\My_Memory.txt" );// File location

Vars: DataMap(ListN.New) ,// Create List of numeric values named "Datamap"
Ergebnis (0) ,// Variable for the content || result
Counter(0) ;// just to count up

Counter = Counter+1 ;// Barcounter one up (for debugg only)

if CurrentBar > 1 then begin // all bars in chart but the current
if ELC.PathExists(FileName) then begin // in case file is found
value1 = ListN.ReadFile(DataMap, FileName);// read file into list "DataMap"
Ergebnis = ListN.Get(DataMap,1) ;// pick first data in list and make it Ergebnis
Print (Counter, " Gefunden = ",Ergebnis);// print it for debugging only
end //
else //
print ( Counter , "Kein File vorhanden") ;// File not found
end ;//
value1 = ListN.Clear(DataMap) ;// Clear List and free memory
This is example of reading some numeric data from a file called "My_Memory" which I decided (!) to allocate in the ADE file .


Re above post´s : Each of the 3 AddOn´s comes with a Word-Manual which is important to study . =>
It is ELCollection which allows you to R&W data in any location of your PC .
ADE allows you to see same data in multiple TF .
Value of GV I still need to explore .

Enjoy, it´s real good stuff even though, again, I believe it should come with MC package .

Lobo


Return to “MultiCharts”