6 registered members (AndrewAMD, Ayumi, degenerate_762, 7th_zorro, VoroneTZ, HoopyDerFrood),
1,268
guests, and 6
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
How to control entry/exit price?
#477487
07/02/19 06:07
07/02/19 06:07
|
Joined: Jun 2019
Posts: 6
JesseL
OP
Newbie
|
OP
Newbie
Joined: Jun 2019
Posts: 6
|
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!
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]
#477498
07/02/19 16:51
07/02/19 16:51
|
Joined: Jun 2019
Posts: 6
JesseL
OP
Newbie
|
OP
Newbie
Joined: Jun 2019
Posts: 6
|
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]
#478558
11/08/19 14:16
11/08/19 14:16
|
Joined: Jul 2000
Posts: 27,986 Frankfurt
jcl
Chief Engineer
|
Chief Engineer
Joined: Jul 2000
Posts: 27,986
Frankfurt
|
|
|
|
Re: How to control entry/exit price?
[Re: JesseL]
#478569
11/10/19 10:30
11/10/19 10:30
|
Joined: Apr 2008
Posts: 586 Austria
Petra
Support
|
Support
Joined: Apr 2008
Posts: 586
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?
|
|
|
|