NexusFi: Find Your Edge


Home Menu

 





Using GlobalVariables and the GV*.DLL making it all work


Discussion in EasyLanguage Programming

Updated
    1. trending_up 820 views
    2. thumb_up 0 thanks given
    3. group 4 followers
    1. forum 3 posts
    2. attach_file 2 attachments




 
Search this Thread

Using GlobalVariables and the GV*.DLL making it all work

  #1 (permalink)
 JoeyZaza 
MA/USA
 
Experience: Intermediate
Platform: Multicharts 64
Broker: AMP Futures
Trading: emini es
Posts: 72 since Oct 2015
Thanks Given: 30
Thanks Received: 53

Hi Traders,

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

//reset sell trigger
l_sellSig = false;
condition1 = false;
condition2 = false;
end;
end;


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

Attached Files
Elite Membership required to download: Global Variable22.zip
Elite Membership required to download: Global Variable 2.2.doc
Visit my NexusFi Trade Journal Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Trade idea based off three indicators.
Traders Hideout
What broker to use for trading palladium futures
Commodities
MC PL editor upgrade
MultiCharts
Cheap historycal L1 data for stocks
Stocks and ETFs
Better Renko Gaps
The Elite Circle
 
  #2 (permalink)
smartpips
London, UK
 
Posts: 2 since Jan 2016
Thanks Given: 0
Thanks Received: 0

Were you able to get this to work?

Reply With Quote
  #3 (permalink)
 JoeyZaza 
MA/USA
 
Experience: Intermediate
Platform: Multicharts 64
Broker: AMP Futures
Trading: emini es
Posts: 72 since Oct 2015
Thanks Given: 30
Thanks Received: 53


Hi All,

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.

So a little inconclusive. Any thoughts?

Cheers,
JZ

Visit my NexusFi Trade Journal Started this thread Reply With Quote
  #4 (permalink)
 jojojo 
FrankfurtGermany
 
Experience: Beginner
Platform: Tradestation
Posts: 41 since Oct 2010
Thanks Given: 4
Thanks Received: 7

They are using their own stuff now , old Globals do not work anymore. Somekind C# based therefor "string", ...

AccuracySetNamedDouble("Value_1", 234);

Then you will be able to get it:

Sth. = AccuracyGetNamedDouble("Value_1", -1);

Reply With Quote




Last Updated on November 14, 2023


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts