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 (SBGuy), 652 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Need help with this #454519
09/09/15 21:17
09/09/15 21:17
Joined: Jun 2015
Posts: 6
A
Alessio Offline OP
Newbie
Alessio  Offline OP
Newbie
A

Joined: Jun 2015
Posts: 6
Hi, I'm newbie and I'm trying to learn lite C.
I have some problems with this script; it's formally ok, but no one buyng and selling operations.

function run ()
{
//no trade costs...
BarPeriod = 5;
Spread = 0;
Slippage = 0;
RollLong = RollShort = 0;
vars Price = series(priceClose());
var HighC = (MaxVal(priceClose,6));
var LowC = (MinVal(priceClose,6));
var PriceRange = (priceHigh()-priceLow());
var BuyStop = priceClose() + 1*PIP;
var SellStop = priceLow() - 1*PIP;
TakeProfit = 150*PIP;
Stop = 200*PIP;
if (Price[0] > (HighC[1] + PriceRange[1]))
enterLong(1,BuyStop, TakeProfit, Stop);
if (Price[0] < (LowC - PriceRange))
enterShort(1,SellStop);
}

Can anyone help me?

Thanks

Re: Need help with this [Re: Alessio] #454556
09/10/15 10:09
09/10/15 10:09
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
Looks ok at a first glance, so maybe that system just does rightfully not trade because your method produces no signals? Plot the trade signals in a curve for checking how they behave over time.

Re: Need help with this [Re: jcl] #454595
09/11/15 10:15
09/11/15 10:15
Joined: Jun 2015
Posts: 6
A
Alessio Offline OP
Newbie
Alessio  Offline OP
Newbie
A

Joined: Jun 2015
Posts: 6
I'll try.
thanks

Re: Need help with this [Re: Alessio] #454683
09/14/15 17:23
09/14/15 17:23
Joined: Sep 2015
Posts: 8
T
Toronado Offline
Newbie
Toronado  Offline
Newbie
T

Joined: Sep 2015
Posts: 8
Alessio, jcl,

I decided to sketch this out to help my learning. Posted here for anyone reading back. This now charts the price movements and, I think, shows that it doesn't trade because the conditions are never met:

Code:
function run ()
{
	//no trade costs...	
	BarPeriod = 5;
	Spread = 0;
	Slippage = 0;
	RollLong = RollShort = 0; 

	vars Price = series(priceClose()); 
	var HighC = MaxVal(Price,6);
	var LowC = MinVal(Price,6);
	var PriceRange = (priceHigh()-priceLow());
	var BuyStop = priceClose() + 1*PIP;
	var SellStop = priceLow() - 1*PIP;
	TakeProfit = 150*PIP;
	Stop = 200*PIP;	

	if (Price[0] > (HighC + PriceRange))
		enterLong(1,BuyStop, TakeProfit, Stop); 

	if (Price[0] < (LowC - PriceRange))
		enterShort(1,SellStop);
		
	plot("HighC", HighC + PriceRange, MAIN, GREEN);
	plot("LowC", LowC - PriceRange, MAIN, RED);
	set(PLOTNOW+PLOTLONG);
		
}



Changing the conditions for a trade confirms this:

Code:
var priceTrigger = PriceRange / 2;

	if (Price[0] >= (HighC + priceTrigger))
		enterLong(1,BuyStop, TakeProfit, Stop); 

	if (Price[0] <= (LowC - priceTrigger))
		enterShort(1,SellStop);



That changes the trigger condition to a smaller distance and this causes the strategy to trade infrequently at a loss (in my tests).

Last edited by Toronado; 09/14/15 17:28.
Re: Need help with this [Re: Toronado] #454685
09/14/15 22:20
09/14/15 22:20
Joined: Jun 2015
Posts: 6
A
Alessio Offline OP
Newbie
Alessio  Offline OP
Newbie
A

Joined: Jun 2015
Posts: 6
Thanks Tornoado for yor reply, but now I've another problem....there're too many operations in my test and Zorro says "Erorr 049: too mant trades per bar".
Can you post the result of your test, please?
Thanks

Re: Need help with this [Re: Alessio] #454718
09/15/15 17:32
09/15/15 17:32
Joined: Sep 2015
Posts: 8
T
Toronado Offline
Newbie
Toronado  Offline
Newbie
T

Joined: Sep 2015
Posts: 8
I don't get too many trades per bar, I was testing against EUR/USD:

Code:
BackTest Alessio_1 EUR/USD

Simulated account   AssetsFix.dta 
Bar period          5 min (avg 7 min)
Test period         04.01.2010-10.09.2015 (413867 bars)
Lookback period     80 bars (6 hours)
Monte Carlo cycles  200
Assumed slippage    0.0 sec
Spread              0.0 pips (roll 0.00/0.00)
Commission          0.60
Contracts per lot   1000.0

Gross win/loss      52$ / -62$ (-112p)
Average profit      -1.72$/year, -0.14$/month, -0.01$/day
Max drawdown        -39$ -395% (MAE -41$ -417%)
Total down time     98% (TAE 0%)
Max down time       190 weeks from Jan 2010
Max open margin     10$
Max open risk       17$
Trade volume        10578$ (1862$/year)
Transaction costs   0.00$ spr, 0.00$ slp, 0.00$ rol, -0.54$ com
Capital required    38$

Number of trades    9 (2/year, 1/week, 1/day)
Percent winning     44%
Max win/loss        13$ / -17$
Avg trade profit    -1.08$ -12.4p (+149.3p / -141.8p)
Avg trade slippage  0.00$ 0.0p (+0.0p / -0.0p)
Avg trade bars      984 (+1690 / -419)
Max trade bars      4641 (23 days)
Time in market      2%
Max open trades     1
Max loss streak     2 (uncorrelated 4)

Annual return       -5%
Profit factor       0.84 (PRR 0.29)
Sharpe ratio        -0.11
Kelly criterion     -0.28
R2 coefficient      0.000
Ulcer index         0.0%
Prediction error    157%

Confidence level     AR   DDMax  Capital

 10%                 -4%    47$  44$
 20%                 -3%    56$  50$
 30%                 -3%    66$  58$
 40%                 -3%    78$  67$
 50%                 -2%    86$  73$
 60%                 -2%    98$  81$
 70%                 -2%   107$  87$
 80%                 -2%   121$  98$
 90%                 -2%   140$  112$
 95%                 -1%   150$  119$
100%                 -1%   184$  144$

Portfolio analysis  OptF  ProF  Win/Loss  Wgt%

EUR/USD             .000  0.84    4/5    100.0  
EUR/USD:L           .000  0.00    0/3    275.0  
EUR/USD:S           .125  1.49    4/2    -175.0



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