Gamestudio Links
Zorro Links
Newest Posts
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
Release 2.68 replacement of the .par format
by Martin_HH. 09/23/25 20:48
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
1 registered members (TipmyPip), 16,510 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Immediate entry on pending trades #487683
07/23/23 11:51
07/23/23 11:51
Joined: Jan 2022
Posts: 70
Budapest
N
NorbertSz Offline OP
Junior Member
NorbertSz  Offline OP
Junior Member
N

Joined: Jan 2022
Posts: 70
Budapest
Hello!

Somehow my pending trades open immediately in the backtest, and I can't figure out why.
I attached a screenshot where you can see visually: the Entry price is the orange one, the Stop is red, and the TakeProfit is green. Also, you can see the exact value on the Zorro output console. I place the pending order at the first moment of the backtest, and the position should not open immediately; however, it does.

The whole codebase is a huge one; I can't paste it here, but these are the options in the init section:
Code
DLLFUNC void run() {
	StartDate = settings.startDate;
	EndDate = settings.endDate;
	BarPeriod = settings.barPeriod;
	asset(settings.asset.c_str());
	EntryTime = 5000;
	ColorEquity = 0;
	ColorDD = 0;
	PlotScale = 10;
	Spread = Commission = RollLong = RollShort = Slippage = Penalty = 0;	//just for research
	Hedge = 2;
	set(LOGFILE);
	set(PLOTNOW);
	setf(PlotMode, PL_LONG);
	LookBack = SCREENSIZE + 2;



Here is a shortened version of what I am doing to get that screenshot. As you can see, I really plotted those values I am using to open the trade:
Code
Stop = [...calculate stop...];
TakeProfit = [...calculate tp...];
Entry = [...calculate entry...];
printf("\n price: %.5f entry: %.5f stop %.5f tp %.5f", priceClose(0), Entry, Stop, TakeProfit);
plotGraph("sl", impulses[impulseId].startBar, Stop, LINE, RED);
plotGraph("sl", impulses[impulseId].endBar, Stop, LINE | END, RED);
[...the same plot method for all the lines...]
enterShort();


At the moment of trade opening, I saw this in the "Open, Pending, Phantom Trades" window:

  • Open: 1.0963
  • Price: 1.0963
  • Entry: 1.0968

Could you help me point out the settings I should check to activate the pending order possibility?

Thank you!

Attached Files immediate_entry.png
Re: Immediate entry on pending trades [Re: NorbertSz] #488416
10/21/24 17:35
10/21/24 17:35
Joined: Jan 2022
Posts: 70
Budapest
N
NorbertSz Offline OP
Junior Member
NorbertSz  Offline OP
Junior Member
N

Joined: Jan 2022
Posts: 70
Budapest
Oh, hello me laugh
I figured out the answer, but forget this thread.
The problem was with the Entry parameter. It is not so obvious, but it's in the documentation at the description of Entry:
Quote
A positive price level or positive distance constitutes an entry stop, a negative price level or negative distance constitutes an entry limit.

If you want to make a Long pending order, and the entry price is above the current price, you use Entry. If the entry price is below of the current price, you must use -Entry. Because without the minus it fills immediately of course (the price is above the entry level).

Last edited by NorbertSz; 10/21/24 18:13.

Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1