I have the following signal and apply in a 1 min chart.
----------------------------------------------------------------------------
SETEXITONCLOSE;
IF DATE <> DATE[1] THEN BEGIN
BUY ("B1") NEXT BAR AT MARKET;
BUY ("B2") NEXT BAR AT MARKET;
BUY ("B3") NEXT BAR AT MARKET;
END;
IF TIME = 1000 THEN BEGIN
SELL ("E1") 1 CONTRACT TOTAL NEXT BAR AT MARKET;
END;
IF TIME = 1100 THEN BEGIN
SELL ("E2") 1 CONTRACT TOTAL NEXT BAR AT MARKET;
END;
IF TIME = 1200 THEN BEGIN
SELL ("E3") 1 CONTRACT TOTAL NEXT BAR AT MARKET;
END;
----------------------------------------------------------------------------
The system will exit all 3 contracts at 10:00. The result is wrong.
If I apply the same code in TS2000 (replace the SELL with EXITLONG), the result is right. The system will exit ONLY 1 contract each time.
If I change the 3 BUY orders to 1 BUY order as follow, then the result become correct in MC.
----------------------------------------------------------------------------
IF DATE <> DATE[1] THEN BEGIN
BUY ("B1") 3 CONTRACTS NEXT BAR AT MARKET;
END;
----------------------------------------------------------------------------
Is it a BUG?
DIFFERENT RESULT WITH TS2K
You can try another example:
----------------------------------------------------------------------------
var: _counter(0) ;
VARS: COUNTER2(0);
SETEXITONCLOSE;
IF DATE <> DATE[1] THEN BEGIN
FOR COUNTER2 = 1 TO 2 BEGIN
BUY ("B1") 5 CONTRACTS NEXT BAR AT MARKET;
END;
_counter = 0 ;
END;
IF DATE = DATE[1] and _counter = 1 THEN
SELL("S1") 1 CONTRACT entry("B1") NEXT BAR AT MARKET;
IF DATE = DATE[1] and _counter = 2 THEN
SELL("S2") 1 CONTRACT entry("B1") NEXT BAR AT MARKET;
IF DATE = DATE[1] and _counter = 3 THEN
SELL("S3") 1 CONTRACT entry("B1") NEXT BAR AT MARKET;
IF DATE = DATE[1] and _counter = 4 THEN
SELL("S4") 1 CONTRACT entry("B1") NEXT BAR AT MARKET;
IF DATE = DATE[1] and _counter = 5 THEN
SELL("S5") 1 CONTRACT entry("B1") NEXT BAR AT MARKET;
IF DATE = DATE[1] and _counter = 6 THEN
SELL("S6") 1 CONTRACT entry("B1") NEXT BAR AT MARKET;
IF DATE = DATE[1] and _counter = 7 THEN
SELL("S7") 1 CONTRACT entry("B1") NEXT BAR AT MARKET;
IF DATE = DATE[1] and _counter = 8 THEN
SELL("S8") 1 CONTRACT entry("B1") NEXT BAR AT MARKET;
IF DATE = DATE[1] and _counter = 9 THEN
SELL("S9") 1 CONTRACT entry("B1") NEXT BAR AT MARKET;
IF DATE = DATE[1] and _counter = 10 THEN
SELL("S10") 1 CONTRACT entry("B1") NEXT BAR AT MARKET;
if ( barstatus = 2 ) then _counter += 1 ;
----------------------------------------------------------------------------
The above code is modified from the previous post:
http://forum.tssupport.com/viewtopic.ph ... highlight=
The S5 will exit 2 contracts. Is it a bug?
----------------------------------------------------------------------------
var: _counter(0) ;
VARS: COUNTER2(0);
SETEXITONCLOSE;
IF DATE <> DATE[1] THEN BEGIN
FOR COUNTER2 = 1 TO 2 BEGIN
BUY ("B1") 5 CONTRACTS NEXT BAR AT MARKET;
END;
_counter = 0 ;
END;
IF DATE = DATE[1] and _counter = 1 THEN
SELL("S1") 1 CONTRACT entry("B1") NEXT BAR AT MARKET;
IF DATE = DATE[1] and _counter = 2 THEN
SELL("S2") 1 CONTRACT entry("B1") NEXT BAR AT MARKET;
IF DATE = DATE[1] and _counter = 3 THEN
SELL("S3") 1 CONTRACT entry("B1") NEXT BAR AT MARKET;
IF DATE = DATE[1] and _counter = 4 THEN
SELL("S4") 1 CONTRACT entry("B1") NEXT BAR AT MARKET;
IF DATE = DATE[1] and _counter = 5 THEN
SELL("S5") 1 CONTRACT entry("B1") NEXT BAR AT MARKET;
IF DATE = DATE[1] and _counter = 6 THEN
SELL("S6") 1 CONTRACT entry("B1") NEXT BAR AT MARKET;
IF DATE = DATE[1] and _counter = 7 THEN
SELL("S7") 1 CONTRACT entry("B1") NEXT BAR AT MARKET;
IF DATE = DATE[1] and _counter = 8 THEN
SELL("S8") 1 CONTRACT entry("B1") NEXT BAR AT MARKET;
IF DATE = DATE[1] and _counter = 9 THEN
SELL("S9") 1 CONTRACT entry("B1") NEXT BAR AT MARKET;
IF DATE = DATE[1] and _counter = 10 THEN
SELL("S10") 1 CONTRACT entry("B1") NEXT BAR AT MARKET;
if ( barstatus = 2 ) then _counter += 1 ;
----------------------------------------------------------------------------
The above code is modified from the previous post:
http://forum.tssupport.com/viewtopic.ph ... highlight=
The S5 will exit 2 contracts. Is it a bug?
I am not able to verify your code in TS, as it seems order can not be inside a loop, its this part of the code which has problem
FOR COUNTER2 = 1 TO 2 BEGIN
BUY ("B1") 5 CONTRACTS NEXT BAR AT MARKET;
END;
also there is error on last line of code it should read
if ( barstatus(1) = 2 ) then _counter =_counter + 1 ;
-------------------------------------------------------
Marina's Code on the other link with last line modification as above works perfectly in TS
FOR COUNTER2 = 1 TO 2 BEGIN
BUY ("B1") 5 CONTRACTS NEXT BAR AT MARKET;
END;
also there is error on last line of code it should read
if ( barstatus(1) = 2 ) then _counter =_counter + 1 ;
-------------------------------------------------------
Marina's Code on the other link with last line modification as above works perfectly in TS
- Marina Pashkova
- Posts: 2758
- Joined: 27 Jul 2007
"Wow "did not know that powerlangage coding is different from EasyLanguage, just learnt something new.Hi Super,
The above code cannot be run in TS. It can be run in MC. You can see the bug on the MC chart.
I ran your latest code on MC and this is what I see on my screen, looks like its showing desired results. I am using MC v 5 Beta 2
Regards
Super
- Attachments
-
- ppan.jpg
- (91.43 KiB) Downloaded 638 times
- Marina Pashkova
- Posts: 2758
- Joined: 27 Jul 2007
- Andrew Kirillov
- Posts: 1589
- Joined: 28 Jul 2005
- Has thanked: 2 times
- Been thanked: 31 times
- Contact: