Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Using GlobalVariables and the GV*.DLL making it all work
I have a simple use case which using a Global Variable is key. I am trying to simply store the entry price of an order at the time of order entry and pass it to a signal that will use that order entry price to calculate a stop or target. Using a Global Variable allows this.
Background
I am using MC64 v14 easy language version. I have installed the GV.DLL and the other dependent ELD and DLLs to support passing GV's. etc (Reference: https://www.multicharts.com/discussion/viewtopic.php?t=2483). All .dlls and functions exist and the signals using them all compile cleanly. The signals execute without error, however it seems that the GV functions are not working. The signals are not failing at runtime but it is as if the GVs are just not passing the values.
Here is the relevant code for the use case:
Signal 1 - Creates an order, stores a value in the Global Variable memory space.
...
IF MP = 0 then
begin
if condition2 = true then
begin
l_sellSig = true;
end;
end;
if l_sellSig = true then
begin
Sell Short ("KltChSE v2.09") next bar at market;
l_entryPrice = entryprice;
GVSetInteger(2,l_entryPrice); // assign the entry price to global var
Signal 2 - Retrieves the value from the GV and uses it to set a stop
...
if marketposition = -1 then
begin
if (g_entryPrice - Close) <= (MinMove * tickThreshold) then
StopPrice = g_entryPrice - MinMove; buy to cover ("JZX_S1T") next bar StopPrice stop;
g_entryPrice = GVGetInteger(2);
print("The entry price tied to JZX_S1T: ", g_entryPrice);
g_entryPrice = 0;
end;
if anyone has experience with the GV *.dll and its functions and can point out where or why this is not working. The use of the GV seems straightforward and reviewing the documentation doesn't have any troubleshooting info. I will confirm via the return code if an internal error actually occurs but nothing currently is being thrown at runtime.
Cheers,
JZ
Can you help answer these questions from other members on NexusFi?
I think someone replied asking if I was able to get this working. To me, no it is not working. Yet, what I have it not erroring out or throwing an error.
I think it is possible that it is working but compounded by another issue.
First this is what I have implemented between the calling signal and the receiving signal. And an alert that is supposed to catch any error thrown by the GV.
Part 1 - The sending signal. This is the signal that initiates the entry (in this case a short entry). This is to:
trigger the sell
capture the entry price
set the GV to be retrieved by the receiving signal (Break Even signal)
...
if l_sellSig = true then
begin
Sell Short ("KltChSE v2.09") next bar at market;
l_entryPrice = entryprice;
IntRtn = GVSetInteger(2,l_entryPrice); // assign GV
if IntRtn <> 0 then
begin
Alert(Text("GVSet failed to set : ",IntRtn, l_entryPrice));
end;
//reset sell trigger
l_sellSig = false;
condition1 = false;
condition2 = false;
end;
Then the receiving signal. In this case a signal to set the BE stop is to:
Determine position entry
retrieve the GV and assign it to a local variable
Check if the value returned is an error or the entry price
Then get the entry price and calculate the stop price
Effectively I am looking to set a stop +1tick above/below the entry price when the current price is N ticks away from the entry price.
if marketposition = -1 then
begin
g_entryPrice = GVGetInteger(2);
if g_entryPrice = -1 then
begin
Alert(Text("GVGet failed to get : ", g_entryPrice));
end;
if (g_entryPrice - Close) <= (MinMove * tickThreshold) then
StopPrice = g_entryPrice - MinMove; buy to cover ("JZX_S1T") next bar StopPrice stop;
print("The entry price tied to JZX_S1T: ", g_entryPrice);
g_entryPrice = 0;
end;
I have tried different permutations of MinMove, etc. to calculate the stop price. What is happening is that a stop price does get set, but is not offset at all by the min move calculation. It looks to be just setting the stop price at the next tick price.