Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
you will have to use the reserved word Close and make sure that you store it in a variable only once on the last bar. Then use this stored value for your order prices.
Hi
I have written two programs.On the first one the limit order is moving and on the second that I added once lastbaronchart ,the order disappears as the price moves
1)
variables:
var1 (0),
var2 (0),
atsStatus (0);
atsStatus = GetAppInfo(aiStrategyAuto);
If atsStatus=1 then begin
var2=Close+300points ;
var1=Close-300 points;
buy 1 contract next bar at var1 limit ;
sell 1 contract next bar at var2 limit ;
end;
2)
variables:
var1 (0),
var2 (0),
atsStatus (0);
atsStatus = GetAppInfo(aiStrategyAuto);
once (LastBarOnChart =true) begin
If atsStatus=1 then begin
var2=Close+300 points ;
var1=Close-300 points;
buy 1 contract next bar at var1 limit ;
sell 1 contract next bar at var2 limit ;
end;
end;
the code is doing exactly what you wrote it to do. In the first you constantly adjust the price, hence the order gets updated and in the second you don't keep the order alive.
You might want to read about order lifetime and keeping them alive in the MC wiki or help files.
in my opinion not every exit works well with every entry and you will likely have to do some research here. There are reserved words for a trailing stop (like setdollartrailing and setpercenttrailing) and some build in strategies that you can explore, plus you'll likely find a lot of examples via Google.
Hi, I searched for lectures or texts in MC wiki and help files about"order lifetime and keeping them alive in the MC wiki or help files".I could not find anything .can you tell me what I should read or can you please send me the link so I can study it?
I am sorry, but I don't have the links handy and would have to dig myself through the documentation, too.
In general Multicharts will keep orders alive as long as the conditions that sent the orders are still present.
That explains the behavior of your second code i.e. why it cancels the order after one bar.