Limit order hold with IOG true
|March 24th, 2015, 05:33 AM||#1 (permalink)|
Futures Experience: Intermediate
Platform: Thinkorswim, Multicharts
Favorite Futures: ES, TF, DX, Stocks
Posts: 13 since Nov 2014
Thanks: 1 given, 3 received
Limit order hold with IOG true
In Multicharts, I'm having a problem getting a limit order to "stick" for more than one tick after sending, with IOG on/true. This is the same problem I've read about in a couple of other threads where the limit order is sent, cancelled, sent, cancelled, etc. after each tick. I have tried the suggestions but with no success.
I'm using a 1minute bar chart and trying to accomplish the following:
A. Evaluate OPEN tick of 1minute bar for buy or sell condition
i. Look back at the previous tick (closing tick of previous 1min bar) and compare to a variable to determine if buy or sell condition is TRUE
ii. If buy or sell condition = TRUE, then set buy or sell price to the calculatedprice variable
iii. Set "trade" variable to trigger a buy or sell in the trade execution routine.
B. Evaluate value of "trade" variable to determine if a buy or sell should be executed
i.Execute a buy or sell limit at buyprice or sellprice
I'm using the (barstatus(1)=0) code is so that the buyprice or sellprice, and the determination of whether to buy or sell, is set/made only once within the 1min bar and the condition will hold until next 1min bar open tick. This should prevent the constant submitting and cancelling of my limit order until executed. The problem is that even though the trade price is set and the trigger variable is set to buy or sell on the open tick of the 1min bar, the trade trigger variable still resets to zero on the next ticks outside of this "barstatus" routine. I'm not sure why this is happening since this part of the code should only be executed once in each 1min bar.
It seems like there is a simple explanation for this. Can anyone help with this? Example code follows:
[IntrabarOrderGeneration = True];
if (barstatus(1) = 0) then begin // evaluate opening tick of 1min bar
If close > pricevar then begin //compare closing tick of previous bar to variable
buyprice=calculateprice; //set buyprice variable to calculated price variable
print("O bar # is", maxbarsback+currentbar," ",close," ",buyprice); //for debugging
trade = 1; //set a trade trigger variable for a buy
If close < pricevar then begin //compare closing tick of previous bar to variable
sellprice=calculatedprice; //set sellprice variable to calculated price variable
print("O bar # is", maxbarsback+currentbar," ",close," ",sellprice); //for debugging
trade = -1; //set a trade trigger variable for a sell
If close = calculatedprice then begin //set a trade trigger variable to neutral - no trade
//Following code is to execute a buy,sell, or no trade based on value of "trade" variable. The price for the limit order
//has been calculated in the previous code and the trade trigger variable has been set in previous code.
//My assumption here is that neither variable should change until the opening tick of next 1min bar, however
//when I look at the output window the "trade" variable is 1 or -1 on the first tick after 1min bar opening tick, and for
//all other ticks it goes to zero/0. See following code.
if trade=1 then begin //buy next tick if trade variable=1
buy ("B1")next bar at buyprice limit;
print(time,"trade=",trade," ",buyprice); //for debugging
if trade = -1 then begin //sell next tick if trade variable=-1
sellshort ("S1") next bar at sellprice limit;
print(time,"trade=",trade," ",sellprice); //for debugging