Page 1 of 1

Sending multiple conditional orders

Posted: Oct 13 2014
by bondstrader
Again, a basic query. For some reason, Im not able to get it to execute.

What Im trying to do is trigger an order based on certain conditions (condition1 and condition2).
Once that executes, I want to check if the same conditions hold true at 10pm. If so, I want to trigger another order of the same quantity.
The first order triggers ok in in backtesting, but the second one doesnt. Any help on what Im missing?

Code: Select all

if marketposition = 0 and condition2 = true and condition3 = true then begin
Buy ("Open-L1") 1 contracts Next bar at Market;
end;

if marketposition = 1 and currentcontracts = 1 and time = 2200 and condition2 = true and condition3 = true then begin
Buy ("Open-L2") 1 contracts Next bar at Market;
end;

Re: Sending multiple conditional orders

Posted: Oct 13 2014
by Andrew MultiCharts
Hello bondstrader,

What is the chart type and chart resolution?

Re: Sending multiple conditional orders

Posted: Oct 13 2014
by bondstrader
Hi Andrew

Im using multiple timeframes. The execution takes place on the 5min chart, while data is derived from the daily and weekly charts.
As I see the 5 min chart, the first order triggers at 20:05 when the conditions turn true. After that, the conditions remain true for more than 24 hours, and according to my expectation, it should re-trigger another order at 22:00, but that doesnt happen. I even removed the conditions for the second order, but nothing. If I trigger an exit order, then the signal has no problems triggering new orders.....but for some reason, it doesnt add additional lots. Seems to be a net position issue, but Im not sure how to resolve it.

Re: Sending multiple conditional orders  [SOLVED]

Posted: Oct 13 2014
by furytrader
I have a suspicion what the problem might be but I can't tell without seeing the rest of the code.

If I were you, I would enter the following line to help you debug it:

Code: Select all

Print(Date," ", Time," Market Position = ",MarketPosition, " Current Contracts = ", currentContracts," Condition2 = ", condition2, " Condition3 = ", Condition3);
This will show you the value of each of these variables for each bar, so it may help you to better determine which part is going astray.

** Also, I assume you have checked the system property called "Allow up to X entry orders in the same direction as the currently held position" .. ?

Re: Sending multiple conditional orders

Posted: Oct 13 2014
by bondstrader
** Also, I assume you have checked the system property called "Allow up to X entry orders in the same direction as the currently held position" .. ?
You assumed wrong! Thank you for helping me right before I was about to pull out my hair. It was a basic issue, but took an experienced eye to spot it.
Thanks again. Its working perfectly now!