Gamestudio Links
Zorro Links
Newest Posts
Issue with converted data
by steventrading15. 12/12/24 21:30
MT4 Bridge connectivity issue
by FXSurgeon. 12/11/24 14:40
Zorro Gives Wrong Calculation During Backtest
by vicknick. 12/11/24 06:31
Price is not shifted with PriceOffset
by vicknick. 12/10/24 13:30
Zorro Gives Price that Doesn't Exist
by jcl. 12/10/24 08:55
Multicore Optimize
by jcl. 12/10/24 08:48
Get timestamp as a var
by Mac81. 12/08/24 01:50
Multicore Optimizations
by Cristoig2001. 12/05/24 14:14
AUM Magazine
Latest Screens
Galactic Strike X
Zeal-X2
The Bible Game
A psychological thriller game
Who's Online Now
1 registered members (sequi), 656 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sequi, MikeHe, Algospider, jordi, FXSurgeon
19090 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: 63
Budapest
N
NorbertSz Offline OP
Junior Member
NorbertSz  Offline OP
Junior Member
N

Joined: Jan 2022
Posts: 63
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: 63
Budapest
N
NorbertSz Offline OP
Junior Member
NorbertSz  Offline OP
Junior Member
N

Joined: Jan 2022
Posts: 63
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