Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (degenerate_762), 1,098 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Donchian turtles #476291
02/14/19 09:55
02/14/19 09:55
Joined: Oct 2016
Posts: 8
Sniv Offline OP
Newbie
Sniv  Offline OP
Newbie

Joined: Oct 2016
Posts: 8
Hi all) please write why this script don't work. Does not open orders with donch 10,20 and dont close orders.

Code:
function run()
{
  StartDate = 20180301;
  Capital = 400;
  Lots = 1;
    vars Price = series(price());
	vars Close = series(priceClose());
	vars High = series(priceHigh());
	vars Low = series(priceLow());
	vars Open = series(priceOpen());
	//set(PARAMETERS);
	
   DChannel(10);
   vars donch_10_up = series(rRealUpperBand);
   vars donch_10_dn = series(rRealLowerBand);
   DChannel(20);
   vars donch_20_up = series(rRealUpperBand);
   vars donch_20_dn = series(rRealLowerBand);
   DChannel(55);
   vars donch_55_up = series(rRealUpperBand);
   vars donch_55_dn = series(rRealLowerBand);

  if((Close[0]>donch_20_up[0])or(Close[0]>donch_55_up[0])or(Close[0]>donch_10_up[0])) exitShort();
  if((Close[0]<donch_20_dn[0])or(Close[0]<donch_55_dn[0])or(Close[0]<donch_10_dn[0])) exitLong();

  if((NumOpenShort<6 and Close[0]>donch_20_dn[0])or(NumOpenShort<6 and Close[0]>donch_55_dn[0])or(NumOpenShort<6 and Close[0]>donch_10_dn[0])) enterShort();
  if((NumOpenLong<6 and Close[0]>donch_20_up[0])or(NumOpenLong<6 and Close[0]>donch_55_up[0])or(NumOpenLong<6 and Close[0]>donch_10_up[0])) enterLong();


/*
  plot("EChannelUp10",donch_10_up,BAND1,RED);
  plot("EChannelDn10",donch_10_dn,BAND2,GREEN);
  
  plot("EChannelUp20",donch_20_up,BAND1,ORANGE);
  plot("EChannelDn20",donch_20_dn,BAND2,GREY);
  
  PlotWidth = 1200;//1200
  PlotHeight1 = 600;//600
  */
}


Why? :((

Last edited by Sniv; 02/14/19 10:04.
Re: Donchian turtles [Re: Sniv] #476292
02/14/19 10:47
02/14/19 10:47
Joined: Apr 2008
Posts: 585
Austria
Petra Offline
Support
Petra  Offline
Support

Joined: Apr 2008
Posts: 585
Austria
Close condition looks always false to me. Price cannot be higher than the high or lower than the low.

Re: Donchian turtles [Re: Petra] #476294
02/14/19 11:20
02/14/19 11:20
Joined: Oct 2016
Posts: 8
Sniv Offline OP
Newbie
Sniv  Offline OP
Newbie

Joined: Oct 2016
Posts: 8
thanks), forgot about the value of the price on the bar 0
it works like this):

//FIXED - "donch_10_dn"
Code:
function trade(){

   vars Close = series(priceClose());
   vars High = series(priceHigh());
   vars Low = series(priceLow());
   DChannel(10);
   vars donch_10_up = series(rRealUpperBand);
   vars donch_10_dn = series(rRealLowerBand);
   DChannel(20);
   vars donch_20_up = series(rRealUpperBand);
   vars donch_20_dn = series(rRealLowerBand);
   DChannel(55);
   vars donch_55_up = series(rRealUpperBand);
   vars donch_55_dn = series(rRealLowerBand);
   Stop = optimize(1,1,5,1)*ATR(optimize(10,10,100,5));

  if((NumOpenShort<1 and Low[0]<donch_20_dn[1])or(NumOpenShort<1 and Low[0]<donch_55_dn[1])or(NumOpenShort<1 and Low[0]<donch_10_dn[1])) {enterShort();exitLong();}
  if((NumOpenLong<1 and High[0]>donch_20_up[1])or(NumOpenLong<1 and High[0]>donch_55_up[1])or(NumOpenLong<1 and High[0]>donch_10_up[1])) {enterLong();exitShort();}
}
function run()
{
  StartDate = 20170301;
  Capital = 400;
  Lots = 1;
  
  if(Train) {Hedge = 2;LookBack = 400;NumWFOCycles = 5;}

    vars Price = series(price());	
	vars High = series(priceHigh());
	vars Low = series(priceLow());
	vars Open = series(priceOpen());
	set(PARAMETERS);

while(asset(loop("AUD/CAD","AUD/CHF","AUD/JPY","AUD/NZD","AUD/USD","CAD/CHF","CAD/JPY","CHF/JPY","EUR/AUD","EUR/CAD","EUR/CHF","EUR/GBP","EUR/JPY","EUR/NZD","EUR/USD","GBP/AUD","GBP/CAD","GBP/CHF","GBP/JPY","GBP/NZD","GBP/USD","NZD/CAD","NZD/CHF","NZD/JPY","NZD/USD","USD/CAD","USD/CHF","USD/JPY")))
{
trade();
}
}


Last edited by Sniv; 02/14/19 16:55.
Re: Donchian turtles [Re: Sniv] #476295
02/14/19 14:50
02/14/19 14:50
Joined: Aug 2018
Posts: 98
O
OptimusPrime Offline
Junior Member
OptimusPrime  Offline
Junior Member
O

Joined: Aug 2018
Posts: 98
Hi Sniv: You have a typo in your second line.. you did not include donch_10


Thanks so much,

OptimusPrime

Re: Donchian turtles [Re: OptimusPrime] #476297
02/14/19 16:43
02/14/19 16:43
Joined: Oct 2016
Posts: 8
Sniv Offline OP
Newbie
Sniv  Offline OP
Newbie

Joined: Oct 2016
Posts: 8
Hi, thanks) in my version I have already fixed it. And this is only a template.


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1