Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (degenerate_762, AndrewAMD), 877 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
What is the use of "BuyLimit" and "SellLimit" in Luxor.c? #481633
10/11/20 09:15
10/11/20 09:15
Joined: Sep 2020
Posts: 22
Z
zzy Offline OP
Newbie
zzy  Offline OP
Newbie
Z

Joined: Sep 2020
Posts: 22
Hi All, I think I am having another silly question.

I am studying the script "Luxor.c" in the Strategy folder, and it seems that the "BuyLimit" and "SellLimit" variables do not take any effect. The results are exactly the same when I remove them in the script.

So am I missing something? Is there any subtle effect from these 2 variables that I didn't catch?

Re: What is the use of "BuyLimit" and "SellLimit" in Luxor.c? [Re: zzy] #481634
10/11/20 10:12
10/11/20 10:12
Joined: Mar 2019
Posts: 357
D
danatrader Offline
Senior Member
danatrader  Offline
Senior Member
D

Joined: Mar 2019
Posts: 357
They are pending orders.
In order to see an effect, increase the PIP value distance for entry and exit.


BuyStop = priceHigh() + 10*PIP;
BuyLimit = priceHigh() + 50*PIP;


SellStop = priceLow() - 10*PIP;
SellLimit = priceLow() - 50*PIP;

Re: What is the use of "BuyLimit" and "SellLimit" in Luxor.c? [Re: zzy] #481635
10/11/20 10:35
10/11/20 10:35
Joined: Mar 2019
Posts: 357
D
danatrader Offline
Senior Member
danatrader  Offline
Senior Member
D

Joined: Mar 2019
Posts: 357
https://zorro-trader.com/manual/en/stop.htm


A positive price level or positive distance constitutes an entry stop, a negative price level or negative distance constitutes an entry limit. An entry limit buys when the price moves against the trade direction and reaches or crosses the limit. It increases the profit because it buys at a price that went in opposite direction to the trade. An entry stop buys when the price moves in trade direction and reaches or crosses the limit; it reduces the profit, but enters only when the price is moving in favorable direction, and thus acts as an additional trade filter. For a long trade, an entry limit should be below and an entry stop should be above the current price. If the entry price is not reached within the allowed time period (set through EntryTime), the trade is cancelled and a "Missed Entry" message is printed to the log file.

Re: What is the use of "BuyLimit" and "SellLimit" in Luxor.c? [Re: danatrader] #481638
10/11/20 13:27
10/11/20 13:27
Joined: Sep 2020
Posts: 22
Z
zzy Offline OP
Newbie
zzy  Offline OP
Newbie
Z

Joined: Sep 2020
Posts: 22
Thanks danatrader, yes and you are right.

But what I meant is another issue: the "BuyLimit" and "SellLimit" variables seems redundant. For the enterLong conditions, for example, as long as "!NumOpenLong && Fast[0]>Slow[0]" is satisfied, "Closes[0]<BuyLimit" should be satisfied for sure.

I just don't understand why we include such a redundant condition check (Closes[0]<BuyLimit) here.

Re: What is the use of "BuyLimit" and "SellLimit" in Luxor.c? [Re: zzy] #481639
10/11/20 14:05
10/11/20 14:05
Joined: Sep 2020
Posts: 22
Z
zzy Offline OP
Newbie
zzy  Offline OP
Newbie
Z

Joined: Sep 2020
Posts: 22
OK, this might be the answer: the conditions "Closes[0]<BuyLimit" and "Closes[0]>SellLimit" are relevant for the period just after the LookBack period, where they are not 100% true when "!NumOpenLong && Fast[0]>Slow[0]" or "!NumOpenShort && Fast[0]<Slow[0]" is true.

I run 2 tests with the following versions of Luxor.c scripts, and they produce exactly the same "Luxor_test.log" files. "LookBack" is set to 122 on purpose, at which Fast just crossed over Slow.

But more weird things happen, they produce different testtrades.csv files:
=========================
$diff testtrades.csv_1 testtrades.csv_2
296a297,298
> testluxor,Long,GBP/USD,823183,1,2004-09-06 07:30,2004-09-07 10:00,1.77760,1.78030,+2.70,0.00,Reverse
> testluxor,Short,GBP/USD,828483,1,2004-09-07 10:00,2004-09-08 00:00,1.78030,1.77530,+5.00,0.00,Reverse
301a304
> testluxor,Short,GBP/USD,837784,1,2004-09-09 08:30,2004-09-09 21:00,1.78530,1.78710,-1.80,0.00,Reverse
785d787
< testluxor,Short,GBP/USD,2148115,1,2005-10-07 05:30,2005-10-10 06:30,1.77550,1.76220,+13.30,0.00,Reverse
789d790
< testluxor,Short,GBP/USD,2165817,1,2005-10-13 01:00,2005-10-13 15:30,1.74920,1.74950,-0.30,0.00,Reverse
=========================



version #1
=========================
function run(){
// set(PLOTNOW,LOGFILE,PARAMETERS);
set(PLOTNOW,LOGFILE);

StartDate = 2004;
EndDate = 2010;
BarPeriod = 30;
LookBack = 122; // This is the point where the cross condition is just satisfied

asset("GBP/USD");

vars Closes = series(priceClose());
vars Fast = series(SMA(Closes,3));
vars Slow = series(SMA(Closes,30));

Spread = Slippage = Commission = RollLong = RollShort = 0;

static var BuyStop, SellStop, BuyLimit, SellLimit;

int threshold = 1;
if(crossOver(Fast,Slow)){
BuyStop = priceHigh()+threshold*PIP;
BuyLimit = priceHigh()+5*threshold*PIP;
}
if(crossUnder(Fast,Slow)){
SellStop = priceLow()-threshold*PIP;
SellLimit = priceLow()-5*threshold*PIP;
}

if(!NumOpenLong && Fast[0]>Slow[0] && Closes[0]<BuyLimit){
enterLong(1,BuyStop);
}
if(!NumOpenShort && Fast[0]<Slow[0] && Closes[0]>SellLimit){
enterShort(1,SellStop);
}
}
=========================

version #2 (remove "Closes[0]<BuyLimit" and "Closes[0]>SellLimit")
=========================
function run(){
// set(PLOTNOW,LOGFILE,PARAMETERS);
set(PLOTNOW,LOGFILE);

StartDate = 2004;
EndDate = 2010;
BarPeriod = 30;
LookBack = 122; // This is the point where the cross condition is just satisfied

asset("GBP/USD");

vars Closes = series(priceClose());
vars Fast = series(SMA(Closes,3));
vars Slow = series(SMA(Closes,30));

Spread = Slippage = Commission = RollLong = RollShort = 0;

static var BuyStop, SellStop, BuyLimit, SellLimit;

int threshold = 1;
if(crossOver(Fast,Slow)){
BuyStop = priceHigh()+threshold*PIP;
BuyLimit = priceHigh()+5*threshold*PIP;
}
if(crossUnder(Fast,Slow)){
SellStop = priceLow()-threshold*PIP;
SellLimit = priceLow()-5*threshold*PIP;
}

if(!NumOpenLong && Fast[0]>Slow[0]){
enterLong(1,BuyStop);
}
if(!NumOpenShort && Fast[0]<Slow[0]){
enterShort(1,SellStop);
}
}
=========================


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1