Gamestudio Links
Zorro Links
Newest Posts
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
0 registered members (), 1,454 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19058 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Entry price a day late #429704
09/17/13 02:31
09/17/13 02:31
Joined: Aug 2013
Posts: 124
D
DMB Offline OP
Member
DMB  Offline OP
Member
D

Joined: Aug 2013
Posts: 124
The entry signal is a stop entry at OPEN - 0.3 * Yesterdays Range. The problem is that the order goes live a bar later. As a result, if the market traded past the entry price on the desired entry day, then we enter at the open of the following bar. If not, then if the market trades through the price that we wanted to enter yesterday, then we enter today at that price.

The attached graph plots the stop entry level with a blue line. You can see that the market enters either at that level on the next bar or at the OPEN if the OPEN is lower than the stop entry.

Here is the code. Don't worry about the IF statement or exit (WIP)...
Quote:
function run()
{

set(PARAMETERS+FACTORS+LOGFILE);
LookBack = 100;
StartDate = 20130601;
EndDate = 20131230;

var BreakoutValue;
int MarginFactor = slider(1,500,100,10000,"Margin","Margin");

int StopFactor = optimize(1,1,8);
Stop = StopFactor * ATR(10);
Trail = StopFactor * ATR(10);




BarPeriod = 1440;

BreakoutValue = 0.3 * (priceHigh(1)-priceLow(1));
var shortentry = priceOpen() - (0.3 * (priceHigh(1)-priceLow(1)));


if ( TRUE )
{

Entry = shortentry;
enterShort();

}


for(open_trades)
if(TradeIsOpen and TradeResult > 0)
exitTrade(ThisTrade);


plot("shortentry",shortentry,0,BLUE);
// plot("BreakoutValue",BreakoutValue,NEW,BLUE);


PlotScale = -10;
PlotWidth = 1400;
PlotHeight1 = 500;

}

Attached Files
Chart.png (11 downloads)
Re: Entry price a day late [Re: DMB] #429719
09/17/13 11:11
09/17/13 11:11
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
In the simulation, all trades enter at a bar boundary unless you set the TICKS flag. Then they can enter anytime, as in live trading.

Re: Entry price a day late [Re: jcl] #429725
09/17/13 12:40
09/17/13 12:40
Joined: Aug 2013
Posts: 124
D
DMB Offline OP
Member
DMB  Offline OP
Member
D

Joined: Aug 2013
Posts: 124
I added '+TICKS' to the SET command but that didn't make any difference. The stop entry order is not going live until the opening of the next bar.

Maybe someone can answer the rephrased question...How do I bracket the open to go either long or short by some amount plus or minus the open?

Re: Entry price a day late [Re: DMB] #429731
09/17/13 14:33
09/17/13 14:33
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
I am not sure that I understand your problem. Trades open at the moment when the entry condition is met, not earlier and not later. Therefore, aside from spread and slippage, a short trade opens either at its entry stop, or below when the price was already lower at the time when you placed the trade.

If you've set the TICKS flag, you can see the precise open times and entry prices in the log.

Re: Entry price a day late [Re: jcl] #429736
09/17/13 15:30
09/17/13 15:30
Joined: Aug 2013
Posts: 124
D
DMB Offline OP
Member
DMB  Offline OP
Member
D

Joined: Aug 2013
Posts: 124
Ok...I think this points to a misunderstanding that I have about programming with zorro. But that just comes from a hangover from programming with other software.

So to enter the market at, for example, open - 50 pips, I need to put this condition in to the if criteria so that when the market trades at that level, a market order is placed. So what do I put in the if brackets? I have tried some things and they don't seem to work. For example...

var shortentry = priceOpen() - (0.3 * (priceHigh(1)-priceLow(1)));

if (priceClose() == shortentry)
{
enterShort();
}

Yields no trades. Putting a < such that entering the trade the market trades through the entry level results in the same problem as before. I need to 'priceLast()' rather than a priceClose()...or I need to understand how to reference the last trade price. Does this make sense? I am just trying to get the basic opening range breakout working so that I can apply filters.

Re: Entry price a day late [Re: DMB] #429739
09/17/13 16:42
09/17/13 16:42
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
If you want to enter a trade at a certain price, you normally use an entry stop. For entering when tomorrow's price drops below today's open - 50 pips, the code would look like this:

Entry = priceOpen() - 50*PIP;
if(priceClose() > Entry) enterShort();

I'm not sure if you really want this, though. For a range breakout you normally use the current price and not the open from 24 hours ago. A normal entry stop code would look like this:

Entry = priceClose() - 50*PIP;
enterShort();

Re: Entry price a day late [Re: jcl] #429813
09/19/13 05:42
09/19/13 05:42
Joined: Aug 2013
Posts: 124
D
DMB Offline OP
Member
DMB  Offline OP
Member
D

Joined: Aug 2013
Posts: 124
I am pleased to say that I have finally got this sorted out. Such a simple problem. I assure you that I am brighter than this. Thanks for your patience. You are right in your second statement. I don't want the offset from yesterday's open. And since yesterday's close is about the same as today's open in 24h and intraday markets, I can use yesterday's close.


Moderated by  Petra 

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