|
Rodorush
|
Posted Friday, June 25, 2010
|
|
Group: Forum Members
Last Active: Thursday, June 30, 2011
Posts: 29,
Visits: 67
|
Hello, I´m using at the same time some robots here.
So, after to open a position with CreateOrder(Instrument, Account, Amount, bsBuy, Stop, Limit, 1, Tag) for example.
How to identify this order? For example I need set "OpenPos" to zero, if an order was rejected.
Like this:
...
CreateOrder(Tick.Instrument, Account, Amount, bsBuy, Stop, Limit, 1, Tag)
...
procedure OnOrderChange(const Action: TDataModificationType; const Order: TOrder);
begin
if (Order.OrderType = otRejInit) then OpenPos := 0; //we need here identifying this order with something like (Order.Tag = 'Robot A')
end;
But remember that I have other robots opened, so how to identify this robot? Becouse if other robot B, bring up (otRejInit), robot A can run OnOrderChange.
Someone could help me please?
[ ]´s
Rodolfo Andrade
www.rodorush.com.br
rodolfo@rodorush.com.br
+55(16)9193-6808
|
|
|
|
|
Rodorush
|
Posted Wednesday, June 30, 2010
|
|
Group: Forum Members
Last Active: Thursday, June 30, 2011
Posts: 29,
Visits: 67
|
Hello, I've written this script to get the answer of this topic, but what I found left me with more questions. I would kindly help the Administrator to clarify these results, because I seem too complex and not documented in the manual. To build professionals robots with good results we need to know the details of the operation of scripts. Some questions are: Why "OnOrderChange" and "OnTradeChange" are executed multiple times? What is the logic behind it? Why is a line executed and the other not? Attached my test script and results are below.
Results:
For CreateOrder with NullRate, NullRate
------------------------------
19:47:45.671: Strategy started
19:47:58.859: Order
19:47:58.859: ****
19:47:58.875: Trade
19:47:58.875: **Test**
19:47:58.875: Order
19:47:58.875: ****
19:49:13.750: Strategy stopped
------------------------------
For CreateOrder with Stop, NullRate
------------------------------
19:52:57.156: Strategy started
19:53:07.813: Order
19:53:07.813: **Test**
19:53:08.281: Order
19:53:08.297: **Test**
19:53:08.297: Order
19:53:08.313: ****
19:53:08.328: Trade
19:53:08.328: **Test**
19:53:08.344: Order
19:53:08.344: ****
19:53:08.344: Trade
19:53:08.344: **Test**
19:53:08.344: Order
19:53:08.344: **Test**
19:56:04.219: Strategy stopped
------------------------------
For CreateOrder with NullRate, Limit
------------------------------
20:00:09.938: Strategy started
20:00:10.938: Order
20:00:10.938: **Test**
20:00:11.219: Order
20:00:11.235: **Test**
20:00:11.235: Order
20:00:11.235: ****
20:00:11.250: Trade
20:00:11.250: **Test**
20:00:11.250: Order
20:00:11.250: ****
20:00:11.250: Trade
20:00:11.250: **Test**
20:00:11.250: Order
20:00:11.250: **Test**
20:00:16.985: Strategy stopped
------------------------------
For CreateOrder with Stop, Limit
------------------------------
20:01:12.047: Strategy started
20:01:19.188: Order
20:01:19.203: **Test**
20:01:19.219: Order
20:01:19.219: **Test**
20:01:19.219: Order
20:01:19.219: **Test**
20:01:19.219: Order
20:01:19.219: **Test**
20:01:19.219: Order
20:01:19.219: ****
20:01:19.219: Trade
20:01:19.219: **Test**
20:01:19.328: Order
20:01:19.344: ****
20:01:19.344: Trade
20:01:19.360: **Test**
20:01:19.360: Order
20:01:19.360: **Test**
20:01:19.360: Trade
20:01:19.360: **Test**
20:01:19.360: Order
20:01:19.360: **Test**
20:01:38.468: Strategy stopped
------------------------------
[ ]´s
Rodolfo Andrade
www.rodorush.com.br
rodolfo@rodorush.com.br
+55(16)9193-6808
Test.act
(105 views,
2.51 KB)
|
|
|
|
|
Rodorush
|
Posted Tuesday, July 06, 2010
|
|
Group: Forum Members
Last Active: Thursday, June 30, 2011
Posts: 29,
Visits: 67
|
Hello friends, I think that the solution for the question of topic is the code that I created.
Follow below:
if OpenPos = 1 then
begin
for i := 0 to TradeList.Count-1 do
begin
if TradeList.Get(i).Tag = StrategyName then
begin
OpenPos := 1;
Break;
end
else OpenPos := 0;
end;
if TradeList.Count-1 = -1 then OpenPos := 0;
if OpenPos = 0 then log('Order Rejected!');
end;
When you to use CreateOrder() set OpenPos to 1. If the order is rejected this code solve the problem.
But the second question remains. Could someone help?
[ ]´s
Rodolfo Andrade
www.rodorush.com.br
rodolfo@rodorush.com.br
+55(16)9193-6808
|
|
|
|
|
eMoe
|
Posted Wednesday, July 07, 2010
|
|
Group: Forum Members
Last Active: 2 days ago @ 2:45 AM
Posts: 201,
Visits: 299
|
Hi, Rodorush!
There are so many order tags because every trade changing is also order change (when we buy lots we should create order for this buying and after that this order is executed (so order list changes one more TIME)). So every order putting (for example just “Stop”) is 2 changes at the order list: 1 is identification (insert) and 2 is update (put order on the existing position). I think that we should ask administrators for the description of this operation.
Best Regards
Best regards!
|
|
|
|
|
Rodorush
|
Posted Wednesday, July 07, 2010
|
|
Group: Forum Members
Last Active: Thursday, June 30, 2011
Posts: 29,
Visits: 67
|
Hello eMoe, thanks for the reply. Yes, it would be great if the administrators make available a file containing details of these steps. The return of the log it was clear that "OnTradeChange" runs the first time in the insert, the second time for an update to limit or stop and the third time for another update to limit or stop. Now "OnOrderChange" was very confusing, as appears in odd numbers and kind of out of position.
[ ]´s
Rodolfo Andrade
www.rodorush.com.br
rodolfo@rodorush.com.br
+55(16)9193-6808
|
|
|
|
|
sdesign
|
Posted Monday, July 12, 2010
|
|
Group: Forum Members
Last Active: Monday, July 12, 2010
Posts: 5,
Visits: 11
|
I would like to ask for help! A strategy which would need more than one Entry or Entry Limit Orders Sell Limit can be imported into the same position.
Example:
Variable:
OPEN 5 ENTRY ORDERS LIMIT position EUR/USD 1,2695
Propertries: Instruments: EUR/USD
VOL.K: 2.000
RATE: 1,2695
TRADING STOP: 5 distance in POINTS
Trading Limits: 11 distance in points
Please Help Me!
|
|
|
|
|
Rodorush
|
Posted Monday, July 12, 2010
|
|
Group: Forum Members
Last Active: Thursday, June 30, 2011
Posts: 29,
Visits: 67
|
Sorry, I didn´t understand. Could you explain in other words, please? Try explain your idea step-by-step.
[ ]´s
Rodolfo Andrade
www.rodorush.com.br
rodolfo@rodorush.com.br
+55(16)9193-6808
|
|
|
|
|
black
|
Posted Saturday, August 07, 2010
|
|
Group: Forum Members
Last Active: 3 hours ago
Posts: 462,
Visits: 848
|
See: http://help.sysfx.com/documents/traders_manual/10.5/en_US/index.html?data_types.htm
var
BuySell: String;
procedure OnNewCandle;
begin
Point := History.Instrument.PointSize;
if (TradeList.Count > 0) then
begin
for i:=TradeList.Count-1 downto 0 do
begin
if (TradeList.Get(i).BuySell = bsBuy) then
begin
BuySell:='Buy';
end;
if (TradeList.Get(i).BuySell = bsSell) then
begin
BuySell:='Sell';
end;
log('Time: ' +DateTimeToStr(Now)+ ' Open Trade ID Number: ' +TradeList.Get(i).Id+ ' Buy or Sell: ' +BuySell+ ' Open Price: ' +FloatToStr(TradeList.Get(i).OpenRate)+ ' Current Price: ' +FloatToStr(TradeList.Get(i).CloseRate)+ ' Lots: ' +FloatToStr(TradeList.Get(i).Amount)+ ' Tag: ' +TradeList.Get(i).Tag);
end;
end;
|
|
|
|
|
black
|
Posted Friday, September 17, 2010
|
|
Group: Forum Members
Last Active: 3 hours ago
Posts: 462,
Visits: 848
|
In addition to the above, if you are not using the "Tag" for anything else, you can place information into it... information that you can retrieve later.
For example (and please pardon any mistakes).
var
CandleCount: Integer;
TagString: String;
SomeOther: Double;
procedure OnNewCandle;
begin
Point := History.Instrument.PointSize;
TagString:=IntToStr(CandleCount);
if (IF SOME CONDITION IS MET) then
begin
CreateOrder(History.Instrument, Account, Amount, bsBuy,
History.Instrument.Sell - Point*Stop,
History.Instrument.Sell + Point*Limit, TraderRange, TagString);
end;
if (IF SOME CONDITION IS MET) then
begin
CreateOrder(History.Instrument, Account, Amount, bsSell,
History.Instrument.Buy + Point*Stop,
History.Instrument.Buy - Point*Limit, TraderRange, TagString);
end;
if (IF SOME CONDITION IS MET)
and (TradeList.Count>0) then
begin
for i:=TradeList.Count-1 downto 0 do
begin
SomeOther:=StrToFloat(TradeList.Get(i).Tag);
// DO SOMETHING WITH SomeOther.
// OR CREATE SomeOther AS AN ARRAY TO HOLD ENTRIES FROM MULTIPLE
// OPEN TRADES THAT YOU CAN USE LATER, OUTSIDE OF THE FOR LOOP.
end;
end;
CandleCount:=CandleCount+1;
end;
|
|
|
|