Can I modify the order which created by cTrader?
Can I modify the order which created by cTrader?
20 Jan 2013, 19:24
Hi,
When I trade in cTrader, I can see the order in cAigo window, it updates realtime., I can modify this orader in manual also.
The question is how can I modity the order in programming. I tried, the system shows it can't find this order at all, the position is null.
Can I modify the order which created by cTrader?
Best regurads.
Henry
Replies
henry
24 Jan 2013, 04:00
I have tried it. The result is,
If the position is created by cAigo, it workes.
If the position is created bt cTrader(same acct.), it does not work.
So, I tried another one from your sample. The result is th same.
using System; using cAlgo.API; using cAlgo.API.Indicators; using cAlgo.Indicators; namespace cAlgo.Robots { [Robot] public class Mytest : Robot {privatePosition position;protectedoverridevoidOnStart(){ // Trade.CreateBuyMarketOrder(Symbol,10000); // this step use cTrader instead.}protectedoverridevoidOnTick(){if(position !=null){Print("The current position's profit is: {0}", position.GrossProfit);Print("The current position's gross profit is: {0}", position.GrossProfit);Print("The current position's Commissions are: {0}", position.Commissions);Print("The current position's TakeProfit is: {0}", position.TakeProfit);Print("The current position's stoploss is: {0}", position.StopLoss);Print("The current position's entryprice is: {0}", position.EntryPrice);Print("The current position's id is: {0}", position.Id);Print("The current position's netprofit is: {0}", position.NetProfit); // Print("The current position's profit is: {0}", position.Profit);Print("The current position's swap is: {0}", position.Swap);Print("The current position's symbolcode is: {0}", position.SymbolCode);Print("The current position's Tradetype is: {0}", position.TradeType);Print("The current position's volume is: {0}", position.Volume);}}protectedoverridevoidOnPositionOpened(Position openedPosition){ position = openedPosition;}}
@henry
admin
24 Jan 2013, 12:35
Please use the code in this sample and let us know if it does not function properly. If it does then it is probably something else in the code that is not functioning as intended.
The code in your previous post does not modify any orders. You need this statement in order to modify orders Trade.ModifyPosition. See ModifyPosition in the API reference.
@admin
admin
21 Jan 2013, 10:56
Currently, you can loop through the positions in the account and check for the conditions of that specific position. Please look at this example.
Your condition may be that the position's entry time is less than 10 seconds, or you may identify it by the symbol code or volume or a combination of all those.
@admin