problem with API class and their position
problem with API class and their position
14 Oct 2012, 14:38
I am creating a program that uses
"Symbol.PipSize"
"Account.Positions "
but does not appear certain times in the list!!
public class Imperial : Robot
OnStart / OnTick / OnStop ex: protected override void OnStart()
this api can be used
If i have created 1 other class and i wont use a api --> does NOT work ( and I get the error that the api do not exist in that context)
public class Opertation //(the 2°)
public int ord_pn()
and this api can't be used
can you give me an example of program
with more classes A-B-C and class B within a management treiling or placing an order which will be called in the main class A!
Replies
banbeng
16 Oct 2012, 01:09
RE:
Hello,
In cAlgo you need to define each class in a separate file. Then you need to reference that file in the class which you want to use it. The filenames should be the same as the classes defined in them, i.e. class Imperial should be saved in filename Imperial.cs
e.g.
//#reference: ..\Robots\Opertation.algo using cAlgo.API; namespace cAlgo.Robots { public class Imperial : Robot { private Opertation robot; // etc. } }
@banbeng
admin
16 Oct 2012, 10:16
RE: RE:
Is it possible to post the code for the one with the problem?admin said:Hello,
In cAlgo you need to define each class in a separate file. Then you need to reference that file in the class which you want to use it. The filenames should be the same as the classes defined in them, i.e. class Imperial should be saved in filename Imperial.cs
e.g.
//#reference: ..\Robots\Opertation.algo using cAlgo.API; namespace cAlgo.Robots { public class Imperial : Robot { private Opertation robot; // etc. } }
I placed the codecreating two new classeswhich I compiledand called up/ / # reference: .. \ Robots \ HD.algo/ / # reference: .. \ Robots \ Tool.algobut one of them gave me a problem in compiling:build succeededUnable to load assembly: assembly must contain single algo type
@admin
banbeng
16 Oct 2012, 22:18
// ------------------------------------------------------------------------------- // // This is a Template used as a guideline to build your own Robot. // Please use the “Feedback” tab to provide us with your suggestions about cAlgo’s API. // // ------------------------------------------------------------------------------- using System; using cAlgo.API; using cAlgo.API.Internals; using cAlgo.API.Indicators; using cAlgo.Indicators; namespace cAlgo.Robots { public class Tool { //public Position pos; //Info informazione=new Info(); int decimali=0; public Tool(int decimalii) { this.decimali=decimalii; } //arrotonda// //arrotonda// public double round(int dir, double cos , double pipsize) { double norm,ln=0; if(decimali!=-1){ ln=Math.Round(cos,decimali);} else { Console.WriteLine("Error");} if(dir==-1) { if(ln<cos){norm=ln;} if(ln="=cos){norm=ln;}">cos){norm=ln-1* pipsize;} } if(dir==1) { if(ln<cos){norm=ln+1* pipsize;}="" if(ln="=cos){norm=ln;}">cos){norm=ln;} //Trade.CreateSellStopOrder(Symbol,1000,Symbol.Bid,null,null,null); } return ln; } } }
@banbeng
admin
17 Oct 2012, 12:22
If you are going to use namespace cAlgo.Robot
Then you need to define your class as Robot
i.e.
[Robot]
public class Tool:Robot
Other than that I see a few issues with the code but no syntax error, like norm is a local variable being assigned but not used.
So the code starting from if(dir == -1) ... (until right before) return ln;
is essentially useless.
Also note that ln-1*pipsize is equal to ln-pipsize as well as ln+1* pipsize is equal to ln+pipsize
I presume that what you need is (ln-1)*pipsize and (ln+1)* pipsize
@admin
admin
18 Oct 2012, 14:15
RE: RE:
I'm not sure what you mean. It seems like a c# question. If so, please visit msdn http://msdn.microsoft.com/en-us/default.aspx. Otherwise, please clarify.thanks both for response that for advice on the code
Robot class creates conflicts when call objects in my main?
I can then use the robot class to class without any problems?
I thought it was unique ability of the main class.
@admin
admin
15 Oct 2012, 09:57
Hello,
In cAlgo you need to define each class in a separate file. Then you need to reference that file in the class which you want to use it. The filenames should be the same as the classes defined in them, i.e. class Imperial should be saved in filename Imperial.cs
e.g.
@admin