NexusFi: Find Your Edge


Home Menu

 





Limit order hold with IOG true


Discussion in MultiCharts

Updated
    1. trending_up 1,478 views
    2. thumb_up 1 thanks given
    3. group 2 followers
    1. forum 2 posts
    2. attach_file 0 attachments




 
Search this Thread

Limit order hold with IOG true

  #1 (permalink)
 cygneslim 
Edwardsville, IL
 
Experience: Intermediate
Platform: Thinkorswim, Multicharts
Trading: ES, TF, DX, Stocks
Posts: 13 since Nov 2014
Thanks Given: 1
Thanks Received: 3

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];

Variable:
pricevar (0),
calculatedprice (0),
buyprice (0),
sellprice (0),
trade (0);


if (barstatus(1) = 0) then begin // evaluate opening tick of 1min bar
If close[1] > pricevar[1] 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[1]," ",buyprice); //for debugging
trade = 1; //set a trade trigger variable for a buy
end else

If close[1] < pricevar[1] 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[1]," ",sellprice); //for debugging
trade = -1; //set a trade trigger variable for a sell
end else

If close[1] = calculatedprice[1] then begin //set a trade trigger variable to neutral - no trade
trade=0;
end;
end;

//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
end else

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
end;

Follow me on Twitter Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NexusFi Journal Challenge - May 2024
Feedback and Announcements
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
How to apply profiles
Traders Hideout
REcommedations for programming help
Sierra Chart
Cheap historycal L1 data for stocks
Stocks and ETFs
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
What is Markets Chat (markets.chat) real-time trading ro …
76 thanks
Spoo-nalysis ES e-mini futures S&P 500
55 thanks
Just another trading journal: PA, Wyckoff & Trends
37 thanks
Bigger Wins or Fewer Losses?
24 thanks
The Program
17 thanks
  #2 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,436 since Apr 2013
Thanks Given: 482
Thanks Received: 1,629

cygneslim,

variables should be of type intrabarpersist when they can change their value during the bar. It could simply be that they are not holding the values correctly in your code and therefore the code assumes you changed an entry condition and cancels or re-sends orders.
If this doesn't work, I would suggest getting rid of the barstatus = 0 and keep track of a new bar in the code yourself.

Regards,
ABCTG

Follow me on Twitter Reply With Quote
Thanked by:
  #3 (permalink)
 cygneslim 
Edwardsville, IL
 
Experience: Intermediate
Platform: Thinkorswim, Multicharts
Trading: ES, TF, DX, Stocks
Posts: 13 since Nov 2014
Thanks Given: 1
Thanks Received: 3


Many thanks ABCTG.

I really don't understand why this works yet, but it works. I need to study up on the why though.

I used a dummy code to test this and the variable that I am using to trigger the trade now holds it's value every tick until reset at the open of the next bar, which is what I've been trying to accomplish. I have more work to do but it's a big relief to have made some progress and you've saved me a lot of time.

For future reference for anyone who runs into the same problem, my solution was basically the following:

[Intrabarordergeneration=TRUE];

variables:
intrabarpersist tradetrigger (0);
intrabarpersist buyprice (0);

tradetrigger=tradetrigger;
buyprice=buyprice;

if *condition to buy is TRUE* then tradetrigger=1 and buyprice=*price*;

if tradetrigger=1 then buy next bar at buyprice limit;

Follow me on Twitter Started this thread Reply With Quote




Last Updated on March 24, 2015


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts