Gamestudio Links
Zorro Links
Newest Posts
Why Zorro supports up to 72 cores?
by 11honza11. 04/26/24 08:55
M1 Oversampling
by 11honza11. 04/26/24 08:32
MT5 bridge not working on MT5 v. 5 build 4160
by EternallyCurious. 04/25/24 20:49
Data from CSV not parsed correctly
by EternallyCurious. 04/25/24 10:20
Trading Journey
by howardR. 04/24/24 20:04
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (AndrewAMD, VoroneTZ, Quad, 1 invisible), 823 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Daily entry #484395
10/21/21 14:40
10/21/21 14:40
Joined: Sep 2021
Posts: 2
Bogotá
Avedon Offline OP
Guest
Avedon  Offline OP
Guest

Joined: Sep 2021
Posts: 2
Bogotá
Hi everyone,
I found these trading rules in a trading forum and I'm trying to translate them into Lite-C:

1. Set up your chart with any asset, 5 minute chart, starting at 9:30 AM Exchange time, and ending
at 3:15 PM.
2. Record the open of the first bar of the day, and refer to it as “openp”
3. At the close of the second bar of the day (at 9:40 AM) go long if:
A. The low of bar 2 is greater than openp
B. The 5 bar RSI indicator is below 50 OR both the close if greater than previous bar close AND
the close if greater than close 2 bars ago AND the daily close is less than the daily close 2 bars ago
4. At the close of the second bar of the day (at 9:40 AM) go short if:
A. The high of bar 2 is less than openp
B. The 5 bar RSI indicator is above 50 OR both the close if less than previous bar close AND the
close if less than close 2 bars ago AND the daily close is greater than the daily close 2 bars ago
5. If you are in a short trade, and the time is after than 11:00 AM and the position is profitable, exit at
the open of the next bar.

6. To add a volatility filter:
A. If the true range of the daily bar is greater than the average true range of the last 5 daily
bars, then:
1. No new trades can be entered
2. Any existing trades should be closed out
B. If the true range condition is not met, then trading should proceed as usual.

This is the Work-in-Progress Code:

Code
function run()
{
     
  
  StartDate = 2010; 
  EndDate = 2020;   
  BarPeriod = 5;	
  LookBack = 1000;	
  var Openp = priceOpen(2);
  var Close = priceClose();
  var Day0 =  dayClose(ET,0);
  var Day2 =  dayClose(ET,2);
  vars Closes = series(priceClose());
  asset("EUR/USD");
		
  
    if(timeOffset(ET,0,9,40) == 0) // enter a trade at second bar
  {    
    if(priceLow() > Openp
      && RSI(Closes,5) < 50
      || (priceClose() > priceClose(1) && priceClose() > priceClose(2) && Day0 < Day2))
      enterLong();
     
    if(priceHigh() < Openp
      && RSI(Closes,5) > 50
      || (priceClose() < priceClose(1) && priceClose() < priceClose(2) && Day0 > Day2))
      enterShort();
  }
}



I got this Error:

Error 045: Negative price offset at bar 11 and Zorro continues to train the algorithm indefinitely.
Nor do I understand how to execute numeral 6 "To add a volatility filter" in a trade that is already open.
I have tried to solve it and I have not been able, could you help me to solve it please?

Re: Daily entry [Re: Avedon] #484397
10/21/21 15:43
10/21/21 15:43
Joined: Apr 2008
Posts: 586
Austria
Petra Offline
Support
Petra  Offline
Support

Joined: Apr 2008
Posts: 586
Austria
Check the dayclose call. If called before market close, you're requesting a price from the future.

Re: Daily entry [Re: Avedon] #484403
10/22/21 19:02
10/22/21 19:02
Joined: Sep 2021
Posts: 2
Bogotá
Avedon Offline OP
Guest
Avedon  Offline OP
Guest

Joined: Sep 2021
Posts: 2
Bogotá
Now it is working, but in the test entry time is 13:40, not 9:40, I could just subtract 4 hours from it, but I would like it to work from the code, any suggestion or reason why this happens?

Re: Daily entry [Re: Avedon] #484408
10/23/21 05:02
10/23/21 05:02
Joined: Aug 2017
Posts: 294
Netherlands
G
Grant Offline
Member
Grant  Offline
Member
G

Joined: Aug 2017
Posts: 294
Netherlands
You prob need to choose a different zone for the timeOffset() function.

Last edited by Grant; 10/23/21 05:03.

Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1