The first problems
The first problems
30 Sep 2012, 16:28
begin to create a program in this new code
I will write the problems I encounter hoping for help
1) I want to create a parameter true/false
[Parameter ("Aggressive mode", DefaultValue = false)]
public bool aggressive {get; set;}
but does not work
tells me unsupported parameter type "boolean"
Replies
algoforce
02 Oct 2012, 09:24
public boolean not supported as you have found out, convert to int and use 1 / 0 for your function
@algoforce
banbeng
07 Oct 2012, 11:26
thanks for the replies
how do I filter the active orders from pending orders
those on this symbol than total
I would like to create a method to tell me how many orders there are active on this symbol (obviously the control must request this information to the platform)
exempol!!
for (int i = 0, to position.orderstotats (esempol 100), i++)
{
if ( position[i].type== active && position[i].symbol==symbol ) {totalat++;}
if ( position[i].type== pendent && position[i].symbol==symbol ) {totalat++;}
}
@banbeng
admin
08 Oct 2012, 09:39
( Updated at: 23 Jan 2024, 13:11 )
The total number of orders for the account is accessible via:
int totalActive = Account.Positions.Count; int totalPending = Account.PendingOrders.Count;
In order to manipulate orders in general you need to access them separately, for instance:
You will need two separate loops:
int totalat = 0; string symbol = "EURUSD"; foreach (var position in Account.Positions) { // position.SymbolCode is equal to the symbol parameter you choose when you run the robot. if (position.SymbolCode == symbol) totalat++; } foreach (var pendingOrder in Account.PendingOrders) { // pendingOrder.SymbolCode is equal to the symbol parameter you choose when you run the robot. if (pendingOrder.SymbolCode == symbol) totalat++; }
You can read more about pending orders here:
Pending orders: [/docs/reference/calgo/api/pendingorder]
You may also like to see a sample to create and manipulate multiple positions here.
@admin
admin
08 Oct 2012, 16:24
( Updated at: 21 Dec 2023, 09:20 )
The difference between double and double? is that "double" is a non nullable type whereas "double?" is a nullable type.
In other words, you cannot define a variable of type double like this:
double stoploss = null; // Compiler error
As far as stop loss and take profit are concerned, you could initialize it the value 0 and it would be fine as far as the compiler is concerned but if you forget to set it to a value other than zero before using it then it will produce a warning.
The proper way would be to define it as nullable, i.e.
double? stoploss = null;
Then if you wish to set the stop loss/ take profit parameters, you may do so, otherwise you should leave them as null or pass in the null value to the function that expects them. For instance, you may wish to set the take profit parameter but not the stop loss:
Trade.ModifyPosition(openedPosition, null, TakeProfit);
For more information on c# nullable types visit : http://msdn.microsoft.com/en-us/library/vstudio/1t3y8s4s.aspx
@admin
banbeng
08 Oct 2012, 23:06
thanks as always
all very clear
I wonder if it is normal for transferring what we say to the platform I do not take
as pre-set words
account
symbol
I have underlined the words that did not give any reaction to the program
public int ord_at() { int q=0; foreach( var pos in Account.Positions) //position sono attivi pendingorder passivi! { if(pos.symbolcode==symbol) { q++; } } return(q); }
ver. 1.0.78
it is normal that these words(account/sybol) do not appear in the dropdown menu???
@banbeng
banbeng
09 Oct 2012, 00:15
you can modify a pending order?
I read the feature, Trade.ModifyPosition, but I think one can only apply to active orders, as it should also amend the entry point
(for bank ect, the movement of change an order is more rapid than closing down an order and open a new order)
@banbeng
admin
09 Oct 2012, 12:00
( Updated at: 23 Jan 2024, 13:11 )
Hello,
For modifying Pending Orders please visit: [/docs/reference/calgo/api/internals/itrade/modifypendingorder]
As far as the previous question for the Account and the Symbol, it is not very clear. Please try to be more specific. Are you getting a compiler error or runtime error or are you expecting the intellisense to automatically input those?
If you press a key then the dropdown list produced does contain Account as well as Symbol.
For Symbol please see: [/docs/reference/calgo/api/internals/symbol]
For Account please see:[/docs/reference/calgo/api/internals/iaccount]
Please let us know if this helps.
@admin
banbeng
11 Oct 2012, 13:22
" If you press a key then the dropdown list produced does contain Account as well as Symbol. "
I don't have this (account, symbol) in mai dropdown list!
in my program I created 4 different classes
public class tool
{
}
public class Mainr: Robot
{
}
...
I can not access symbol because this class is not
: robot?
@banbeng
banbeng
14 Oct 2012, 20:39
( Updated at: 23 Jan 2024, 13:11 )
" For modifying Pending Orders please visit: [/docs/reference/calgo/api/internals/itrade/modifypendingorder] "
I read the page but I can not understand how to change the price of entry for the pending order!
if i have bid at 1.2301
and a sell entry at 1.2290
how can i cange this entry to 1.2280??
can i use this syntax??
foreach( PendingOrders pos in Account.PendingOrders) //position sono attivi pendingorder passivi! { if(pos.symbolcode==symbol && pos.TradeType=TradeType.Buy ) { // API for pending modify } }
I hope I've been clear as much as possible
@banbeng
admin
15 Oct 2012, 10:42
The entry price cannot be modified. You need to delete it and create a new one.
foreach (var pendingOrder in Account.PendingOrders) { if(pendingOrder.SymbolCode == Symbol.Code && pendingOrder.TradeType == TradeType.Buy) { Trade.DeletePendingOrder(pendingOrder); Trade.CreateBuyLimitOrder(Symbol, Volume, price, TakeProfit, StopLoss, expiration); } }
If the class is not of type Robot/Indicator then the intellisence will not produce the Account, Symbol or other internal class types.
@admin
cAlgo_Development
01 Jul 2013, 17:27
Boolean type parameters are supported now:
[Parameter("Use Stop Loss", DefaultValue = true)] public bool UseStopLoss { get; set; }
@cAlgo_Development
algoforce
03 Nov 2013, 05:03
RE:
ver. 1.0.78
it is normal that these words(account/sybol) do not appear in the dropdown menu???
use this article to Code from Visual Studio ( for better intellisense). It will open up a wide range of possibilities.
- http://carbonfx.io/2013/08/using-visual-studio-with-calgo/
@algoforce
banbeng
30 Sep 2012, 17:00
How can I initialize an array???
private double posx[200];
but does not work
sorry but i start now in calgo..
@banbeng