Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 552 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, 11honza11, ccorrea, sakolin, rajesh7827
19046 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Pending Entries not being hit #448332
01/29/15 14:18
01/29/15 14:18
Joined: May 2013
Posts: 245
S
swingtraderkk Offline OP
Member
swingtraderkk  Offline OP
Member
S

Joined: May 2013
Posts: 245
Hi jcl,

Can you have a look at the attached script and pic please.

I'm trying to set a buy stop at the high of the last candle, but it does not appear to be hit when it should be mid-candle on the next candle, rather it is opened at the open of the subsequent candle.

What am I doing wrong? I have TICKS set in script.



Code:
function run()
{

	set (TICKS);						
	set (PLOTNOW);						
	set (LOGFILE);						
	set (TESTNOW);						
	
 
	BarPeriod		= 60;			 
	BarOffset 		= (ET+17)*60;
	
	LookBack			= 100; 
	
	StartDate		= 20110101;
	EndDate			= 20110120;
	
	Hedge				= 2; 

	vars op			= series(priceOpen());
	vars cl			= series(priceClose());
	vars hi			= series(priceHigh());
	vars lo			= series(priceLow());
	vars wt			= series((hi[0]+lo[0]+cl[0]+cl[0])/4);
	
	Stoch(14,3,MAType_EMA,3,MAType_EMA);
	vars sto5K		= series(rSlowK);	
	vars sto5D		= series(rSlowD);
	
	vars signal		= series(0);

	Stop				= 40*PIP;
	TakeProfit		= 20*PIP;
	
	EntryTime		= 10;


	if ((sto5K[0] < 30) and (sto5K[0] > sto5K[1]))
		{
			signal[0] = 1;
		}


	if (NumOpenLong < 1)
		{
			if ((NumPendingLong < 1) and (signal[0] > 0))
				{
					enterLong(0,hi[0]);
					plotGraph("Entry",0,hi[0]+5*PIP,MAIN|TRIANGLE4,PURPLE);
				}
				
			if ((NumPendingLong > 0) and (signal[0] > 0))
				{
					exitLong();
					enterLong(0,hi[0]);
					plotGraph("Entry2",0,hi[0]+5*PIP,MAIN|TRIANGLE4,MAGENTA);
				}
				
			if (((NumPendingLong > 0) and (signal[0] < 1)) and (hi[0] < hi[1]))
				{
					exitLong();
					enterLong(0,hi[0]);
					plotGraph("Entry3",0,hi[0]+5*PIP,MAIN|TRIANGLE4,MAROON);
				}

		}
		
	
	
	if (is(EXITRUN))
	{
		exitLong();
		exitShort();
	}

	
	
	plot("Sto 5,2,2 K",sto5K[0],NEW,RED);
	plot("Sto 5,2,2 D",sto5D[0],0,BLUE);
	plot("30",30,0,GREY);
	plot("70",70,0,GREY);
	

	

	PlotWidth		= 2400;
	PlotHeight1		= 800;

}


Attached Files
zorro problem.png (13 downloads)
Re: Pending Entries not being hit [Re: swingtraderkk] #448383
02/02/15 16:39
02/02/15 16:39
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
How do you know that it is opened at the open of the next candle? What does the log say?

Re: Pending Entries not being hit [Re: jcl] #448390
02/02/15 19:24
02/02/15 19:24
Joined: May 2013
Posts: 245
S
swingtraderkk Offline OP
Member
swingtraderkk  Offline OP
Member
S

Joined: May 2013
Posts: 245
Please see pic attached and log as applied to same period.


Code:
[112: Mon 10.01.11 07:00]  17p 1/0
(EUR/USD::L) Missed entry 1.2911 at exit command
(EUR/USD::L) Long 1@1.2912 Entry stop

[113: Mon 10.01.11 08:00]  17p 1/0
[114: Mon 10.01.11 09:00]  17p 1/0
(EUR/USD::L) Missed entry 1.2912 at exit command
(EUR/USD::L) Long 1@1.2926 Entry stop

[115: Mon 10.01.11 10:00]  17p 1/0
(EUR/USD::L) Missed entry 1.2926 at exit command
(EUR/USD::L) Long 1@1.2916 Entry stop
(EUR/USD::L) Entry stop 1.2916 hit at 10:00
[EUR/USD::L1602] Long 1@1.2916 Risk 3$ p at 10:00



The entry stop is moving as it should at 07:00 to the previous high of 1.2912. Entry time is 10 so the stop should endure for 10 bars.

08:00 candle indicated in pic should have triggered buy stop at 1.2912.

09:00 candle also should have triggered buy stop at 1.2912, and even moves stop to 1.2926, a high greater than the entry level of the buy stop.

The 2 successful trades before and after display the expected behaviour, i.e. buy stop moves down to high of previous bar until triggered.

Attached Files
zorro problem2.png (72 downloads)
Re: Pending Entries not being hit [Re: swingtraderkk] #448391
02/02/15 19:37
02/02/15 19:37
Joined: May 2013
Posts: 245
S
swingtraderkk Offline OP
Member
swingtraderkk  Offline OP
Member
S

Joined: May 2013
Posts: 245
Another example:

Code:
[225: Mon 17.01.11 03:00]  8p 3/1
[226: Mon 17.01.11 04:00]  8p 3/1
[227: Mon 17.01.11 05:00]  8p 3/1
[228: Mon 17.01.11 06:00]  8p 3/1
[229: Mon 17.01.11 07:00]  8p 3/1
[230: Mon 17.01.11 08:00]  8p 3/1
[231: Mon 17.01.11 09:00]  8p 3/1
[232: Mon 17.01.11 10:00]  8p 3/1
(EUR/USD::L) Long 1@1.3277 Entry stop
(EUR/USD::L) Missed entry 1.3277 at exit command
(EUR/USD::L) Long 1@1.3277 Entry stop

[233: Mon 17.01.11 11:00]  8p 3/1
(EUR/USD::L) Missed entry 1.3277 at exit command
(EUR/USD::L) Long 1@1.3297 Entry stop

[234: Mon 17.01.11 12:00]  8p 3/1
(EUR/USD::L) Entry stop 1.3297 hit at 12:00
[EUR/USD::L3505] Long 1@1.3319 Risk 3$ p at 12:00
[EUR/USD::L3505] Target 1@1.3339: +1.42 at 12:24

[235: Mon 17.01.11 13:00]  27p 4/1
[236: Mon 17.01.11 14:00]  27p 4/1
[237: Mon 17.01.11 15:00]  27p 4/1
[238: Mon 17.01.11 16:00]  27p 4/1
[239: Mon 17.01.11 17:00]  27p 4/1
[240: Mon 17.01.11 18:00]  27p 4/1


Attached Files
zorro problem3.png (71 downloads)
Re: Pending Entries not being hit [Re: swingtraderkk] #448399
02/03/15 09:54
02/03/15 09:54
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
The log looks fine to me. You're placing and immediately removing a pending trade at every bar. Only the third entry was hit because the price was already over the limit when you placed the trade.

So, I can not see any problem so far, at least not in the log. Your script does indeed not make much sense to me, maybe it does not do what you intended? For looking into details, just print more data to the log, such as the current price.

The computer just does what you tell it to do.

Re: Pending Entries not being hit [Re: jcl] #448403
02/03/15 13:27
02/03/15 13:27
Joined: May 2013
Posts: 245
S
swingtraderkk Offline OP
Member
swingtraderkk  Offline OP
Member
S

Joined: May 2013
Posts: 245
OK

Apologies for clumsy example script, I've tidied it up with printfs to try to explain the logic.

With new code there are still buy stops not being hit when they should.

Code:
function run()
{

	set (TICKS);						
	set (PLOTNOW);						
	set (LOGFILE);						
	set (TESTNOW);						
	
 
	BarPeriod		= 60;			 
	BarOffset 		= (ET+17)*60;
	
	LookBack			= 100; 
	
	StartDate		= 20110101;
	EndDate			= 20110120;
	
	Hedge				= 2; 

	vars op			= series(priceOpen());
	vars cl			= series(priceClose());
	vars hi			= series(priceHigh());
	vars lo			= series(priceLow());
	vars wt			= series((hi[0]+lo[0]+cl[0]+cl[0])/4);
	
	Stoch(14,3,MAType_EMA,3,MAType_EMA);
	vars sto5K		= series(rSlowK);	
	vars sto5D		= series(rSlowD);
	
	vars signal		= series(0);

	Stop				= 40*PIP;
	TakeProfit		= 20*PIP;
	
	EntryTime		= 10;


	if ((sto5K[0] < 30) and (sto5K[0] > sto5K[1]))
		{
			signal[0] = 1;
			printf("\nStoch Signal Fired");
		}


	if (NumOpenLong < 1) // if open trade do not set pending
		{
			printf("\nNo Trade Open");
			
			// Set new pending trade if signal fires
			
			if (NumPendingLong < 1)
			{
					printf("\nNo Pending Trade");
				
				if (signal[0] > 0)
				{
					enterLong(0,hi[0]);
					plotGraph("Entry",0,hi[0]+5*PIP,MAIN|TRIANGLE4,PURPLE);
					printf("\nNo Pending Trade, Signal = %1.1f, placing new pending at %1.4f",signal[0],hi[0]);
				}
			}
			
			// If pending not hit check if signal valid
			
			else
			{
				printf("\nPending Trade not Hit hi[1] = %1.4f; hi[0] = %1.4f",hi[1],hi[0]);
				
				if (signal[0] > 0)
				{
					exitLong();
					enterLong(0,hi[0]);
					plotGraph("Entry2",0,hi[0]+5*PIP,MAIN|TRIANGLE4,GREEN);
					printf("\nSignal = %1.1f, exiting old trade placing new pending at %1.4f",signal[0],hi[0]);
				}
				else
				{
					if  (hi[0] < hi[1])
					{
						exitLong();
						enterLong(0,hi[0]);
						plotGraph("Entry3",0,hi[0]+5*PIP,MAIN|TRIANGLE4,YELLOW);
						printf("\nSignal = %1.1f, exiting old trade placing new pending at %1.4f",signal[0],hi[0]);
					}
				}
				
			}
				
			

		}
		
	else printf("\nTrade Open");	
	
	
	if (is(EXITRUN))
	{
		exitLong();
		exitShort();
	}

	
	
	plot("Sto 5,2,2 K",sto5K[0],NEW,RED);
	plot("Sto 5,2,2 D",sto5D[0],0,BLUE);
	plot("30",30,0,GREY);
	plot("70",70,0,GREY);
	

	

	PlotWidth		= 2400;
	PlotHeight1		= 800;

}



Log file extract for region in attached pic:

Code:
[105: Mon 10.01.11 00:00]  1.28963
No Trade Open
No Pending Trade
[106: Mon 10.01.11 01:00]  1.28969
Stoch Signal Fired
No Trade Open
No Pending Trade
(EUR/USD::L) Long 1@1.2907 Entry stop
No Pending Trade, Signal = 1.0, placing new pending at 1.2907
(EUR/USD::L) Entry stop 1.2907 hit at 01:00
[EUR/USD::L0701] Long 1@1.2907 Risk 3$ p at 01:00

[107: Mon 10.01.11 02:00]  0p 1/0
Stoch Signal Fired
Trade Open
[EUR/USD::L0701] Target 1@1.2927: +1.35 at 02:18

[108: Mon 10.01.11 03:00]  17p 1/0
Stoch Signal Fired
No Trade Open
No Pending Trade
(EUR/USD::L) Long 1@1.2931 Entry stop
No Pending Trade, Signal = 1.0, placing new pending at 1.2931

[109: Mon 10.01.11 04:00]  17p 1/0
No Trade Open
Pending Trade not Hit hi[1] = 1.2931; hi[0] = 1.2925
(EUR/USD::L) Missed entry 1.2931 at exit command
(EUR/USD::L) Long 1@1.2925 Entry stop
Signal = 0.0, exiting old trade placing new pending at 1.2925

[110: Mon 10.01.11 05:00]  17p 1/0
No Trade Open
Pending Trade not Hit hi[1] = 1.2925; hi[0] = 1.2912
(EUR/USD::L) Missed entry 1.2925 at exit command
(EUR/USD::L) Long 1@1.2912 Entry stop
Signal = 0.0, exiting old trade placing new pending at 1.2912

[111: Mon 10.01.11 06:00]  17p 1/0
No Trade Open
Pending Trade not Hit hi[1] = 1.2912; hi[0] = 1.2911
(EUR/USD::L) Missed entry 1.2912 at exit command
(EUR/USD::L) Long 1@1.2911 Entry stop
Signal = 0.0, exiting old trade placing new pending at 1.2911

[112: Mon 10.01.11 07:00]  17p 1/0
Stoch Signal Fired
No Trade Open
Pending Trade not Hit hi[1] = 1.2911; hi[0] = 1.2912
(EUR/USD::L) Missed entry 1.2911 at exit command
(EUR/USD::L) Long 1@1.2912 Entry stop
Signal = 1.0, exiting old trade placing new pending at 1.2912

[113: Mon 10.01.11 08:00]  17p 1/0
No Trade Open
Pending Trade not Hit hi[1] = 1.2912; hi[0] = 1.2921
[114: Mon 10.01.11 09:00]  17p 1/0
Stoch Signal Fired
No Trade Open
Pending Trade not Hit hi[1] = 1.2921; hi[0] = 1.2926
(EUR/USD::L) Missed entry 1.2912 at exit command
(EUR/USD::L) Long 1@1.2926 Entry stop
Signal = 1.0, exiting old trade placing new pending at 1.2926

[115: Mon 10.01.11 10:00]  17p 1/0
No Trade Open
Pending Trade not Hit hi[1] = 1.2926; hi[0] = 1.2916
(EUR/USD::L) Missed entry 1.2926 at exit command
(EUR/USD::L) Long 1@1.2916 Entry stop
Signal = 0.0, exiting old trade placing new pending at 1.2916
(EUR/USD::L) Entry stop 1.2916 hit at 10:00
[EUR/USD::L1602] Long 1@1.2916 Risk 3$ p at 10:00

[116: Mon 10.01.11 11:00]  17p 1/7
Trade Open
[EUR/USD::L1602] Target 1@1.2936: +1.30 at 11:14

[117: Mon 10.01.11 12:00]  34p 2/0
No Trade Open
No Pending Trade


Attached Files
zorro problem4.png (51 downloads)
Re: Pending Entries not being hit [Re: swingtraderkk] #448404
02/03/15 13:43
02/03/15 13:43
Joined: May 2013
Posts: 245
S
swingtraderkk Offline OP
Member
swingtraderkk  Offline OP
Member
S

Joined: May 2013
Posts: 245
Another example:

Code:
[214: Fri 14.01.11 13:00]  34p 2/0
No Trade Open
No Pending Trade
[215: Fri 14.01.11 14:00]  34p 2/0
Stoch Signal Fired
No Trade Open
No Pending Trade
(EUR/USD::L) Long 1@1.3386 Entry stop
No Pending Trade, Signal = 1.0, placing new pending at 1.3386

[216: Fri 14.01.11 15:00]  34p 2/0
No Trade Open
Pending Trade not Hit hi[1] = 1.3386; hi[0] = 1.3376
(EUR/USD::L) Missed entry 1.3386 at exit command
(EUR/USD::L) Long 1@1.3376 Entry stop
Signal = 0.0, exiting old trade placing new pending at 1.3376
(EUR/USD::L) Entry stop 1.3376 hit at 15:00
[EUR/USD::L1703] Long 1@1.3376 Risk 3$ p at 15:00
[EUR/USD::L1703] Target 1@1.3396: +1.29 at 15:06

[217: Fri 14.01.11 16:00]  51p 3/0
No Trade Open
No Pending Trade
[218: Fri 14.01.11 17:00]  51p 3/0
No Trade Open
No Pending Trade
[219: Fri 14.01.11 18:00]  51p 3/0
Stoch Signal Fired
No Trade Open
No Pending Trade
(EUR/USD::L) Long 1@1.3361 Entry stop
No Pending Trade, Signal = 1.0, placing new pending at 1.3361

[220: Fri 14.01.11 19:00]  51p 3/0
Stoch Signal Fired
No Trade Open
Pending Trade not Hit hi[1] = 1.3361; hi[0] = 1.3358
(EUR/USD::L) Missed entry 1.3361 at exit command
(EUR/USD::L) Long 1@1.3358 Entry stop
Signal = 1.0, exiting old trade placing new pending at 1.3358

[221: Sun 16.01.11 23:00]  51p 3/0
No Trade Open
Pending Trade not Hit hi[1] = 1.3358; hi[0] = 1.3392
(EUR/USD::L) Entry stop 1.3358 hit at 23:00
[EUR/USD::L2204] Long 1@1.3375 Risk 3$ p at 23:00

[222: Mon 17.01.11 00:00]  51p 5/0
Trade Open
[223: Mon 17.01.11 01:00]  51p 3/2
Trade Open
[224: Mon 17.01.11 02:00]  51p 3/2
Trade Open
[EUR/USD::L2204] Stop 1@1.3335: -3.28 at 02:40

[225: Mon 17.01.11 03:00]  9p 3/1
No Trade Open
No Pending Trade
[226: Mon 17.01.11 04:00]  9p 3/1
No Trade Open
No Pending Trade
[227: Mon 17.01.11 05:00]  9p 3/1
No Trade Open
No Pending Trade
[228: Mon 17.01.11 06:00]  9p 3/1
No Trade Open
No Pending Trade
[229: Mon 17.01.11 07:00]  9p 3/1
No Trade Open
No Pending Trade
[230: Mon 17.01.11 08:00]  9p 3/1
No Trade Open
No Pending Trade
[231: Mon 17.01.11 09:00]  9p 3/1
No Trade Open
No Pending Trade
[232: Mon 17.01.11 10:00]  9p 3/1
Stoch Signal Fired
No Trade Open
No Pending Trade
(EUR/USD::L) Long 1@1.3277 Entry stop
No Pending Trade, Signal = 1.0, placing new pending at 1.3277

[233: Mon 17.01.11 11:00]  9p 3/1
Stoch Signal Fired
No Trade Open
Pending Trade not Hit hi[1] = 1.3277; hi[0] = 1.3297
(EUR/USD::L) Missed entry 1.3277 at exit command
(EUR/USD::L) Long 1@1.3297 Entry stop
Signal = 1.0, exiting old trade placing new pending at 1.3297

[234: Mon 17.01.11 12:00]  9p 3/1
No Trade Open
Pending Trade not Hit hi[1] = 1.3297; hi[0] = 1.3330
(EUR/USD::L) Entry stop 1.3297 hit at 12:00
[EUR/USD::L3505] Long 1@1.3319 Risk 3$ p at 12:00
[EUR/USD::L3505] Target 1@1.3339: +1.42 at 12:24

[235: Mon 17.01.11 13:00]  27p 4/1
No Trade Open
No Pending Trade
[236: Mon 17.01.11 14:00]  27p 4/1
No Trade Open
No Pending Trade
[237: Mon 17.01.11 15:00]  27p 4/1
No Trade Open
No Pending Trade


Attached Files
zorro problem5.png (50 downloads)
Re: Pending Entries not being hit [Re: swingtraderkk] #448425
02/04/15 17:47
02/04/15 17:47
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
Thanks for the new script! I'll look into this and will let you know when I find something.

Re: Pending Entries not being hit [Re: jcl] #448426
02/04/15 17:59
02/04/15 17:59
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
Ok, the reason is that pending trades are not opened when their stop or profit limit was hit before the entry limit was hit. This happened with your trade in bar #112; I didn't check the further trades. This would be a bug: it makes no sense to check stop or profit limits before the trade is even entered. Can you check if your script works ok when you do not set Stop or TakeProfit?

Update: It was indeed a bug - this will be fixed in the upcoming update. Thanks for finding it!

Re: Pending Entries not being hit [Re: jcl] #448433
02/05/15 09:46
02/05/15 09:46
Joined: May 2013
Posts: 245
S
swingtraderkk Offline OP
Member
swingtraderkk  Offline OP
Member
S

Joined: May 2013
Posts: 245
Much appreciated jcl.


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