So it is my understanding that in order to partially close a position, I have to include...
[From Entry("EntryLabel")] whereas....
EntryLabel - an optional parameter; ties the exit to the particular entry that was
assigned the EntryLabel name; the name must be preceded by the word "Entry",
the word "From" is a skip word and can be omitted
If EntryLabel is not specified, all of the open long entries will be closed.
So I have a question... Can I use a variable to assign the name of a variable? In that way, each time I open a position, I can assign the variable with the name of the entry. For example.
Vars: EntryName("test");
Buy ("LongEntry-1") 10 contracts next bar market;
EntryName = "LongEntry-1";
If cond1 = true then Sell ("LongExit-1") from Entry EntryName 9 contracts next bar market;
Can I do this???
Partially closing an open position...
-
- Posts: 17
- Joined: 04 Jan 2013
- Been thanked: 1 time
- Kate MultiCharts
- Posts: 591
- Joined: 21 Oct 2020
- Has thanked: 9 times
- Been thanked: 148 times
Re: Partially closing an open position...
Hello,
Yes, it is possible to do.
Here's an example you can refer to:
Yes, it is possible to do.
Here's an example you can refer to:
Code: Select all
Input: EntryName1("LE1"); //Switch "LE1" or "LE2"
if mod(currentbar, 8) = 0 then
begin
Buy ("LE1") 10 contracts next bar market;
end;
if mod(currentbar, 13) = 0 then
begin
Buy ("LE2") 25 contracts next bar market;
end;
Var: cond1(true);
cond1 = mod(currentbar, 17) = 0;
If cond1 = true then
begin
Sell (" LongE1 ") from Entry (EntryName1) 9 contracts next bar market;
end;
-
- Posts: 29
- Joined: 15 Aug 2012
- Has thanked: 2 times
Re: Partially closing an open position...
On a similar scope, will this work?
Input: EntryName1("LE1");
if mod(currentbar, 7) = 0 then
begin
Buy (EntryName1) 10 contracts next bar market;
end;
Input: EntryName1("LE1");
if mod(currentbar, 7) = 0 then
begin
Buy (EntryName1) 10 contracts next bar market;
end;