Gamestudio Links
Zorro Links
Newest Posts
Bmap creation - wrong Alpha values
by txesmi. 12/11/19 12:43
A9
by preacherX. 12/11/19 11:01
Error Message 010: invalid stops
by Volker. 12/11/19 08:25
AssetFix & Assets.csv
by MatPed. 12/11/19 07:03
How to handle profit in a TMF during training
by StefanCGN. 12/09/19 20:09
Simulate complex commission costs [Test]
by AndrewAMD. 12/09/19 13:52
AUM Magazine
Latest Screens
The Space Between
Pogostuck: Rage With Your Friends
Worst Case Z
AckCon'18 - Lotter vs the World 2 - Preview Release
Who's Online Now
6 registered members (3run, AndrewAMD, Volker, Quad, PabloMF, 1 invisible), 802 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
timW, PabloMF, deepscreener, wzschultz, Alit
18342 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
How to control entry/exit price? #477487
07/02/19 06:07
07/02/19 06:07
Joined: Jun 2019
Posts: 5
J
JesseL Offline OP
Newbie
JesseL  Offline OP
Newbie
J

Joined: Jun 2019
Posts: 5
Hi,

I'm testing a simple strategy with daily bars. Enter long if today's high is the highest in 20 days, and exit long if today's low is the lowest in 50 days. I want the order and fill prices are the price at the moment when the crossing happens in the day. I tried to use TradePriceOpen and TradePriceClose to set the order price, but the printed TradePriceClose and TradePriceOpen are not the cross level as expected. So are they supposed to use to set the order and fill prices? If not, how to set the order and fill prices? Thanks!

Code
    if (NumOpenLong > 0)   // long position
    {
        if (priceLow() < LL(50-1, 1))  // exit triggered
            {
                TradePriceClose = LL(50-1, 1);
                printf(" Exit Long low=%f order_price=%f ", priceLow(), TradePriceClose);
                exitLong();
                printf(" TradeLots=%d NumOpenLong=%d", TradeLots, NumOpenLong);
            }
    }
    else  if (priceHigh() > HH(20-1, 1))  // entry long triggered
    {
            TradePriceOpen = HH(20-1, 1);
            printf(" Enter Long high=%f order_price=%f q_order=%d", priceHigh(), TradePriceOpen, q_order);
            enterLong(q_order);
            printf(" TradeLots=%d NumOpenLong=%d", TradeLots, NumOpenLong);
    }

Last edited by JesseL; 07/02/19 06:08.
Re: How to control entry/exit price? [Re: JesseL] #477490
07/02/19 09:53
07/02/19 09:53
Joined: Jul 2000
Posts: 27,070
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,070
Frankfurt
For triggering exactly at the crossing, use a tick() function. And it's priceClose(), not TradePriceClose.

Re: How to control entry/exit price? [Re: jcl] #477492
07/02/19 14:38
07/02/19 14:38
Joined: Jun 2019
Posts: 5
J
JesseL Offline OP
Newbie
JesseL  Offline OP
Newbie
J

Joined: Jun 2019
Posts: 5
The data are daily bars, so priceClose() returns EOD price. How can tick() works? Do I have to use tick data?

Re: How to control entry/exit price? [Re: JesseL] #477497
07/02/19 16:01
07/02/19 16:01
Joined: Feb 2017
Posts: 816
Chicago
AndrewAMD Online
User
AndrewAMD  Online
User

Joined: Feb 2017
Posts: 816
Chicago
priceClose() is different in tick() vs. in run().

In your context, you can use M1 data and use TICKS mode, which will be close enough for your purposes. Using actual tick data would work too, but it would be overkill for a daily bar system.

Re: How to control entry/exit price? [Re: JesseL] #477498
07/02/19 16:51
07/02/19 16:51
Joined: Jun 2019
Posts: 5
J
JesseL Offline OP
Newbie
JesseL  Offline OP
Newbie
J

Joined: Jun 2019
Posts: 5
Please forgive the newbie. I'm confused. Can I use only daily EOD data, not 1min or tick data, with tick() to implement this?
Since I know the exact trade prices, LL(50-1, 1) and HH(20-1, 1), can I just directly set the order or trade price with daily data only, like a limit order?

Last edited by JesseL; 07/02/19 19:12.
Re: How to control entry/exit price? [Re: JesseL] #477507
07/03/19 09:46
07/03/19 09:46
Joined: Jul 2000
Posts: 27,070
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,070
Frankfurt
When you have only EOD data, you can obviously not trigger exactly at the crossing, no matter in which way, at least not in the backtest.

Re: How to control entry/exit price? [Re: JesseL] #478557
11/07/19 17:56
11/07/19 17:56
Joined: Aug 2017
Posts: 25
Netherlands
G
Grant Offline
Newbie
Grant  Offline
Newbie
G

Joined: Aug 2017
Posts: 25
Netherlands
What I don't get is this, when Zorro is able to export the exact entry price fillings (testtrades.csv file), then why can't I have access to this data without guesstimating them? I've made a comparison between the estimated fillings ('AskPrice' for long trades and 'AskPrice - Spread' in the Tick() function) and the actual entry fillings from testtrades.csv and found out that 90% of the long entries and 74% of the short entries differ (80 trades with EURUSD_2015.t6) data.

Re: How to control entry/exit price? [Re: JesseL] #478558
11/08/19 14:16
11/08/19 14:16
Joined: Jul 2000
Posts: 27,070
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,070
Frankfurt
Maybe you missed this page: https://manual.zorro-project.com/trade.htm

Re: How to control entry/exit price? [Re: jcl] #478562
11/09/19 15:33
11/09/19 15:33
Joined: Aug 2017
Posts: 25
Netherlands
G
Grant Offline
Newbie
Grant  Offline
Newbie
G

Joined: Aug 2017
Posts: 25
Netherlands
I've tried using a TMF but for some reason the TradePriceOpen/PriceTradeEntry returns a 0-value.

Code
double PriceTradeEntry;


int PlaceEntry()
	{
	Lots = 1;
	PriceTradeEntry = TradePriceOpen;
	return 16;
	}

enterLong(PlaceEntry);
printf("\nPriceTradeEntry: %.5f", PriceTradeEntry);

Re: How to control entry/exit price? [Re: JesseL] #478569
11/10/19 10:30
11/10/19 10:30
Joined: Apr 2008
Posts: 256
Austria
Petra Offline
Member
Petra  Offline
Member

Joined: Apr 2008
Posts: 256
Austria
The manual is your friend

"All trade variables listed above can only be accessed inside a TMF, inside a trade enumeration loop, or when ThisTrade was explicitely set to a valid TRADE* pointer. In all other cases they have invalid content."

I suppose a 0-value is invalid content, which means you did not access the variable correctly. A TMF makes no sense here, I would set ThisTrade directly from enterLong. And check if it is nonzero and your trade was really entered, otherwise you wont get an entry price, right? laugh


Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1