Gamestudio Links
Zorro Links
Newest Posts
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
M1 Oversampling
by Petra. 04/24/24 10:34
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
StartWeek not working as it should
by jcl. 04/20/24 08:38
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (EternallyCurious, AndrewAMD, TipmyPip, Quad), 889 guests, and 8 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
Maximum of One Trade per Minute #483951
08/17/21 21:00
08/17/21 21:00
Joined: Aug 2018
Posts: 98
O
OptimusPrime Offline OP
Junior Member
OptimusPrime  Offline OP
Junior Member
O

Joined: Aug 2018
Posts: 98
Hi Team:

I am exploring various timing algorithms to use within a script. I can't figure out how to allow no more than one trade within a one-minute period. This one-minute rule is to apply, regardless of all other periodicity, trade direction, Timeframes, BarPeriods, etc. It's like a stand-alone timer that makes sure we never enter more than one trade within a minute.

Do you have any suggestions on how I might accomplish this?

Thanks so much


Thanks so much,

OptimusPrime

Re: Maximum of One Trade per Minute [Re: OptimusPrime] #483952
08/17/21 21:20
08/17/21 21:20
Joined: Aug 2021
Posts: 237
L
Lapsa Offline
Member
Lapsa  Offline
Member
L

Joined: Aug 2021
Posts: 237
It's possible to restrict total amount of trades per side.

Code
MaxLong = 5;
MaxShort = 5;


But that's not exactly the same as 1 per minute.

One approach might be to store the value of minute(0) and then check up that minute(0) != stored_minute if (NumOpenLong || NumOpenShort) > 0.

Re: Maximum of One Trade per Minute [Re: OptimusPrime] #483953
08/17/21 21:59
08/17/21 21:59
Joined: Aug 2021
Posts: 237
L
Lapsa Offline
Member
Lapsa  Offline
Member
L

Joined: Aug 2021
Posts: 237
It's sort of dumb approach.


Using hours as I lack tick data.

Code
#include <profile.c>

var storedHour = .0;

function run()
{
	set(PLOTNOW);
	BarPeriod = 1;
	LookBack = 100;
	StartDate = 20210715;
	EndDate = 20210816;

	var currentHour = hour(0);
        // var currentMinute = minute(0);
	
	bool goLong = random() > 0;
	bool goShort = !goLong;
			
	bool sureWhyNot =
		(NumOpenLong + NumOpenShort) <= 0 ||
		currentHour != storedHour;
	
	if (goLong && sureWhyNot) {
		enterLong();
		storedHour = currentHour;
	}		
	
	if (goShort && sureWhyNot) {
		enterShort();
		storedHour = currentHour;
	}
}


[Linked Image]


To be fair - I would question necessity for such feature.

Re: Maximum of One Trade per Minute [Re: OptimusPrime] #483954
08/18/21 03:20
08/18/21 03:20
Joined: Aug 2018
Posts: 98
O
OptimusPrime Offline OP
Junior Member
OptimusPrime  Offline OP
Junior Member
O

Joined: Aug 2018
Posts: 98
Hi Lapsa: Thanks for your response. I found minute() in the manual and I am testing it as follows. https://zorro-trader.com/manual/en/month.htm

if(minute() != StoredMinute)
TradeAllowed = true;

Appreciated !


Thanks so much,

OptimusPrime


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