Replies

joeatbayes
06 Apr 2015, 19:37

exact call as requested

PlaceLimitOrder(TradeType.Sell, Symbol, Symbol.VolumeMin, 1.07478, "EMACrosX1", 24 37, Time.AddMinutes(0.25), "Bid=1.07406 Ask=1.07413 targetLimitPrice=1.07406 stopPips=24.00000 profitPips=37.00000 LimitPriceEMA=1.07406 VeryShortEMA=1.07417 ShortEMA=1.07423275951391 LongEMA=1.07425 stopLimitPriceAdj=0.002470338 atRiskPerShare=0.00254444814 MaxCapitalAtRiskForSingleTrade=9.8989 maxShares=3890.39172950092 totalMaxRisk=7.63334442 orderVolume=3000 stopPips=24 profitPips=37 Account.FreeMargin=989.89 Account.Equity=989.89 PipSize=0.0001 Symbol.PipValue=0.0001 workingLongStopLimitPort=0.0023");


@joeatbayes

joeatbayes
03 Apr 2015, 02:27

Final work around / resolution

Taking the standard debugging approach of removing complexity until  it worked and then adding things back in until it stopped I found that the failure point occurred when I added the comment string parameter.   It worked fine with the stopPips and takeProfitPips which I previously thought was causing the issue.   I have not tried to figure out exactly what it was about my comment string the server had a problem with and there is no documentation I can find about the limits of what can be put in a comment string.   This documentation would be very helpful.


@joeatbayes

joeatbayes
31 Mar 2015, 23:45

RE: Modified for null stop limit and null take profit and same order worked.

March-31 13:37

I modified the code to set the stopPips and ProfitPips to null and the order executed as expected but since the stop limit  and target price are null the order to add missing stop limits had to kick in to modify the position to add them.   There is some extra latency when used this way that leaves the position exposed to greater risk than desired.    Next I will modify to try just setting the profitPips and see if it still works. 

I modified the code From (FAILS):

      var orderResult = PlaceLimitOrder(TradeType.Sell, Symbol, orderVolume, targetLimitPrice, StratLabel, stopPips, profitPips, expireTime, cmt);

TO: (WORKS)
      var orderResult = PlaceLimitOrder(TradeType.Sell, Symbol, orderVolume, targetLimitPrice, StratLabel, nullnull, expireTime, null);

From The Journal

31/03/2015 20:26:08.276 | Limit order to Sell 0.03 Lot(s) EURUSD (Price: 1.07478, ExpireDate: 31/03/2015 20:26) is sent to server

31/03/2015 20:26:08.495 | → Limit order OID5366660 to Sell 0.03 Lot(s) EURUSD (Price: 1.07478, ExpireDate: 31/03/2015 20:26) is ACCEPTED (31/03/2015 20:26:08.357 UTC+0)

31/03/2015 20:26:08.792 | → Limit order to SELL 0.03 Lot(s) EURUSD OID5366660 is FILLED at 1.07478, position PID3227196 (31/03/2015 20:26:08.645 UTC+0)

31/03/2015 20:26:08.839 | Request to amend position PID3227196 (SL: 1.07725, TP: 1.07231) is sent to server

31/03/2015 20:26:09.042 | → Request to amend position PID3227196 (SL: 1.07725, TP: 1.07231) is ACCEPTED


@joeatbayes

joeatbayes
31 Mar 2015, 22:40

RE:

joeatbayes said:

I have been using limit orders for TradeType.Buy successfully for quite some time but am struggling with the .Sell due to a "INVALID_REQUEST" message as shown below.    The same code runs fine in a backtest but fails when running live in a virtual account.   From the cAlgo journal it looks like it sent the order to the server with the right set of parameters or at least about what I would have expected. 

Snippet of Code 

 var orderResult = PlaceLimitOrder(TradeType.Sell, Symbol, orderVolume, targetLimitPrice, StratLabel, stopPips, profitPips, expireTime, cmt);
 

Can anybody see what I am doing wrong?

Error from CAlgo Journal

31/03/2015 06:24:00.857 | Limit order to Sell 0.03 Lot(s) EURUSD (Price: 1.07831, SL: 1.08081, TP: 1.07461, ExpireDate: 31/03/2015 06:24) is sent to server
31/03/2015 06:24:01.029 | ? Limit order to Sell 0.03 Lot(s) EURUSD (Price: 1.07831, SL: 1.08081, TP: 1.07461, ExpireDate: 31/03/2015 06:24) is REJECTED with error "INVALID_REQUEST"

Values from my External Log File

L513: 2015-03-31 06:24:00.826: Bid=1.07831 Ask=1.07838 targetLimitPrice=1.07831  stopPips=24.80113 profitPips=37.20170 Account.FreeMargin=984.62 Account.Equity=984.62 PipSize=0.0001 Symbol.PipValue=0.0001 

March-31 - Trade result is showing "Error: TechnicalError"

I modified the SL and take profit to require a Minimum of 1 Pip in the PlaceLimitOrderCall.  Also converted them to Integer values since that was shown in the examples.  I am now printing out the TradeResult and get the following Error:

 L527: 2015-03-31 18:54:07.628: OrderResult=TradeResult (Error: TechnicalError)

Request:   When the server rejects and order it would be nice to print out all the Order parameters the server thinks it rejected and would be even better if we got an indication of which parameters the server finds unsuitable. 

For the same Trade the Journal is still showing:

31/03/2015 18:54:07.456 | Limit order to Sell 0.03 Lot(s) EURUSD (Price: 1.07406, SL: 1.07646, TP: 1.07036, ExpireDate: 31/03/2015 18:54) is sent to server

31/03/2015 18:54:07.628 | → Limit order to Sell 0.03 Lot(s) EURUSD (Price: 1.07406, SL: 1.07646, TP: 1.07036, ExpireDate: 31/03/2015 18:54) is REJECTED with error "INVALID_REQUEST"

The extract from my Text log file with parameters we are sending in the API call.

L513: 2015-03-31 18:54:07.456: CheckOpenShort: OPEN SELL cmt=Bid=1.07406 Ask=1.07413 
targetLimitPrice=1.07406 stopPips=24.00000 profitPips=37.00000 LimitPriceEMA=1.07406 
VeryShortEMA=1.07417 ShortEMA=1.07423275951391 LongEMA=1.07425 stopLimitPriceAdj=0.002470338 
atRiskPerShare=0.00254444814 MaxCapitalAtRiskForSingleTrade=9.8989 maxShares=3890.39172950092 
totalMaxRisk=7.63334442 orderVolume=3000 stopPips=24 profitPips=37 Account.FreeMargin=989.89 
Account.Equity=989.89 PipSize=0.0001 Symbol.PipValue=0.0001 workingLongStopLimitPort=0.0023

Advice on diagnosing this would be greatly appreciated. 

 

 

 


@joeatbayes

joeatbayes
21 Feb 2015, 01:46

I agree with this as a feature request

I have nearly identical requirements.   It seems like this should be a feature built into the application.   Otherwise it makes it difficult to run multiple copies with different configurations. 


@joeatbayes

joeatbayes
26 Dec 2014, 00:53

I would have some utility classes such as   public class parsedRow which I would like to move into separate C# source members from my main cbot.  I do not have visual studio installed and want to work only inside of calgo.   How do I add a reference to an extra C# file to the cBot directly without having to convert it to a DLL.  EG:   In  Lua I can use require "filename"   in F# I can do something similar.  


@joeatbayes

joeatbayes
26 Dec 2014, 00:45

Is there still a need to Importing external signal files?

see:  /algos/cbots/show/588  and /algos/cbots/show/591  I have also written the portion which does the import and executes trades based on external signals.   If others will find it of value then let me know and I can post it as a new CBot.  It takes quite a bit of extra effort to package things for external consumption but if there is sufficient demand I will do so.  Thanks Joe E. 


@joeatbayes

joeatbayes
26 Dec 2014, 00:41

I too would like this functionality of Running CAlgo as a Library from my larger C# application

I would also like the functionality of referencing  CAlgo as a loaded library rather than running it as a separate application.   For me the more important aspect is the ability to auto-start the system,  auto log in and debug easily all inside of visual studio.     Testing from inside of CAlgo is cumbersome and quite often forces me back to hand writing "Print" statements.    


@joeatbayes

joeatbayes
26 Dec 2014, 00:30

See: /algos/cbots/show/591 and /algos/cbots/show/588


@joeatbayes

joeatbayes
22 Dec 2014, 03:13

How to Convert MarketSeries.TickVolume() to Transaction Volume?

IN my code  /algos/cbots/show/591 I am using a line  MarketSeries.TickVolume.Last(1)  But this doesn't seem quite right. I don't want tick volume from   MarketSeries.TickVolume.Last(1).    I want actual units transacted.  Since any tick could represent a value from a fractional lot to several lots it seems that there is a huge difference in the actual value of money transacted for any tick move.    I think it makes more sense to record total units traded during the bar.      The theory is that  200 million $ traded during a bar that dropped 10 pips is more meaningful as momentum input than  $2000 traded with the same drop during the same duration.      I would greatly appreciate help doing this conversion.


@joeatbayes

joeatbayes
22 Dec 2014, 03:09

RE:

How do I convert  TickVolume to Transaction Volume.      EG:  IN my code  /algos/cbots/show/591 I am using a line  MarketSeries.TickVolume.Last(1)  But this doesn't seem quite right. I don't want tick volume from   MarketSeries.TickVolume.Last(1).    I want actual units transacted.  Since any tick could represent a value from a fractional lot to several lots it seems that there is a huge difference in the actual value of money transacted for any tick move.    I think it makes more sense to record total units traded during the bar.      The theory is that  200 million $ traded during a bar that dropped 10 pips is more meaningful as momentum input than  2000 traded with the same drop during the same duration.   

The volume reading in the market snapshot tools is in what units. For example, a volume reading of 1424 in a EURUSD 15m chart is what?

Thanks

 


@joeatbayes

joeatbayes
22 Dec 2014, 03:07

I Think your volume level will always return 0 in the output field.        I have published something similar at /algos/cbots/show/591  but I don't want tick volume from   MarketSeries.TickVolume.Last(1).    I want actual units transacted.  Since any tick could represent a value from a fractional lot to several lots it seems that there is a huge difference in the actual value of money transacted for any tick move.    I think it makes more sense to record total units traded during the bar.      The theory is that a 200 million $ traded during a bar that dropped 10 pips is more meaningful as momentum input than  2000 traded with the same drop during the same duration.   


@joeatbayes

joeatbayes
22 Dec 2014, 02:54

RE:

See: /algos/cbots/show/591   for the first 1/2 of what you wanted.  I had not planned to release the other have but might do so if there is sufficient interest.

badmonkeyface said:

Hi All,

Is it possible to download the backtest data to an external format through the platform?

Essentially I'm trying to get the backtest data in a format such as CSV to run through an external system to then feed back into an indicator.

Thanks.

 


@joeatbayes