For OCO group, may I use below code for entry?
Code: Select all
if marketposition = 0 then
begin
buy("BUY") next bar close+10 stop;
sellshort("Sell") next bar close-1 stop;
end;
Code: Select all
if marketposition = 0 then
begin
buy("BUY") next bar close+10 stop;
sellshort("Sell") next bar close-1 stop;
end;
OCO mean one cancels the other.Dear TS,
For OCO group, may I use below code for entry?Code: Select all
if marketposition = 0 then
begin
buy("BUY") next bar close+10 stop;
sellshort("Sell") next bar close-1 stop;
end;
If you posted an order to the broker, it will stay there for the bar, or until withdrawn.Dear TJ,
what I supposed is when the condition is met in bar#1, both buy and sell orders was posted in the beginning of bar#2, if the buy order was filled during the bar#2, then canncel the sell one.
I saw your guide about the OCO, the sample code just for order closure, is that means it can be only used in order closure, can not use in order initiate?
Steven
I don't quite understand what you mean.Dear TJ,
Thanks for the reply, I've read your post for OCO usage, it's just for "set-exit-type" orders ,
Is that means OCO cannot work for REGULAR orders?
Steven
Code: Select all
if marketposition = 0 then
begin
buy("BUY") next bar close+10 stop;
sellshort("Sell") next bar close-1 stop;
end;
Code: Select all
If Condition = true then
Begin
Buy ("B") next bar at Market;
End ;
sell ("s1") next bar at entryprice+10 stop;
sell ("s2") next bar at entryprice-1 stop;
OCO means One Cancel Other.let me make it simple, May I use below codes to implentment OCO?
...
I would suggest you to try out InteractiveBrokers demo system.... can you tell the exactly behaviors for below 2 codes?
...
have you read this section?
EasyLanguage Essentials Programmers Guide
Built-in Stops.......... pg. 90
with the above code,let me make it simple, May I use below codes to implentment OCO?
If not, can you tell the exactly behaviors for below 2 codes?
code 1, entry with OCO:
expectation: "buy" and "sell" orders are posted at the same time, when anyone of them was filled, cancel the other one.Code: Select all
if marketposition = 0 then
begin
buy("BUY") next bar close+10 stop;
sellshort("Sell") next bar close-1 stop;
end;
Thanks for the info, I got that, what about the code 2?with the above code,
1. the orders will be effective for one bar. At the end of the bar, if none of the conditions are met, the orders will be cancelled.
2. If the buy order is hit, the sellshort order will still sit there until the bar is closed.
3. if the buy order is hit, then the sellshort order is hit in the same bar, the sellshort order will sell 2 contracts for you, and you will ended up with one short position.
4. if you want to cancel one order after the other is filled, you will need to write codes to that effect.
I would suggest you to read through the ebooks here:
https://www.multicharts.com/multicharts ... mentation/
You should work through the exercises and examples in each section; they are very easy to understand.
You have not read the manualThanks for the info, I got that, what about the code 2?with the above code,
1. the orders will be effective for one bar. At the end of the bar, if none of the conditions are met, the orders will be cancelled.
2. If the buy order is hit, the sellshort order will still sit there until the bar is closed.
3. if the buy order is hit, then the sellshort order is hit in the same bar, the sellshort order will sell 2 contracts for you, and you will ended up with one short position.
4. if you want to cancel one order after the other is filled, you will need to write codes to that effect.
I would suggest you to read through the ebooks here:
https://www.multicharts.com/multicharts ... mentation/
You should work through the exercises and examples in each section; they are very easy to understand.
another extra request: you said "you will need to write codes to that effect.", could you please give me a sample?
Steven