Topics

Forum Topics not found

Replies

cAlgo_Fanatic
09 May 2013, 15:49

The addition of user defined time offset is in progress and will be available in one of the nearest releases. This will not remove Sunday bars, offseting the time will shift the time of the bar to appear that the bar is on Monday 00:00:00 instead of  Sunday 23:00:00.


@cAlgo_Fanatic

cAlgo_Fanatic
08 May 2013, 18:01

If you like please post or send (engage@spotware.com) us the code or a snippet in order to reproduce this and investigate the error.


@cAlgo_Fanatic

cAlgo_Fanatic
08 May 2013, 17:26

Please see this example.


@cAlgo_Fanatic

cAlgo_Fanatic
08 May 2013, 12:01

This is in our short term roadmap for future implementations.


@cAlgo_Fanatic

cAlgo_Fanatic
07 May 2013, 17:45

Brokers have their own liquidity.

cTrader does not have a liquidity network. Spotware Systems that produces cTrader is a software company, not a broker.


@cAlgo_Fanatic

cAlgo_Fanatic
07 May 2013, 16:35

If the label of the position is the same as the label of the pending order it means the pending order was filled.


@cAlgo_Fanatic

cAlgo_Fanatic
07 May 2013, 16:17

You can use Labels for this. Use the OnTick event to check for the positions with the label set when the order was created. Please see the examples here.


@cAlgo_Fanatic

cAlgo_Fanatic
07 May 2013, 16:12

We can try to investigate, in the meantime if you like you may post the code (or snippet) or email it to us at engage@spotware.com to help us reproduce the error.


@cAlgo_Fanatic

cAlgo_Fanatic
07 May 2013, 14:14

Retrieve the position details in the OnPositionOpened event.

        protected override void OnStart()
        {
            // open first trade
            TradeType sell = TradeType.Sell;
            var request = new MarketOrderRequest(sell, 10000)
                              {
                                  Label = "Robot 1",
                                  SlippagePips = 0,
                                  StopLossPips = 10,
                                  TakeProfitPips = 20
                              };

            Trade.Send(request);
        }

        protected override void OnPositionOpened(Position openedPosition)
        {
            // retrieve position details
            // open new trade if trades are less than 5 
// (you can have a global counter that increaments here or add the positions in a List.
// see example with List) }




@cAlgo_Fanatic

cAlgo_Fanatic
07 May 2013, 12:54

If the order fails to be filled due to invalid values being set then the error event will be raised and the error message will be technical error:

protected override void OnError(Error error)
{
// Do something if there is an error Print("Error: {0}", error.Code); }




@cAlgo_Fanatic

cAlgo_Fanatic
07 May 2013, 12:39 ( Updated at: 21 Dec 2023, 09:20 )

Below are the coding errors:

        // DefualtValue should be DefaultValue (misspelled)
        // Incorrect:
        //[Parameter("Take Profit", DefualtValue = 10)]
        // Correct:
        [Parameter("Take Profit", DefaultValue = 10)]
        public int TakeProfitInPips { get; set;}

        //...

        if (bb.Top.LastValue < Symbol.Bid)
        {
            // *** Method OpenPosition needs to be defined
            OpenPosition(TradeType.Sell);
        }
        else if (bb.Bottom.LastValue > Symbol.Ask)
        {
            // *** Method OpenPosition needs to be defined
            OpenPosition(TradeType.Buy);
        }

        //...

        // Define OpenPosition
        private void OpenPosition(TradeType tradeType)
        {
            // code for OpenPosition
        }

        //...

        private double GetAbsoluteStopLoss(Position position, int stopLossInPips)
        {
        	return position.TradeType == TradeType.Buy
        		? position.EntryPrice - Symbol.PipSize * stopLossInPips
            
                // *** Mistake *** 
                // *** Position and position are different. Position is the type and position is the variable.
                
                // Incorrect:
                // Position.EntryPrice + Symbol.PipSize * stopLossInPips;
                // Correct:
        		: position.EntryPrice + Symbol.PipSize * stopLossInPips;
        }
        
        private double GetAbsoluteTakeProfit(Position position, int takeProfitInPips)
        {
        	return position.TradeType == TradeType.Buy
        		? position.EntryPrice + Symbol.PipSize * takeProfitInPips
                
                        // *** Mistake: Same as above plus Pipsize should be PipSize
                        // Incorrect:
                        // Position.EntryPrice - Symbol.Pipsize * takeProfitInPips;
        		// Correct:
                       : position.EntryPrice - Symbol.PipSize * takeProfitInPips;
        }

C# is case sensitive: abc is different than Abc.

To avoid typos use the intellisense. By typing enter when the correct variable/type etc is located (highlighed) from the intellisense dropdown menu the selected keyword is inserted:

To get started with C# please visit csharp-station.com

For cAlgo help and examples see the cAlgo API Reference, the samples indicators and robots that are included with cAlgo as well as the reference-samples page of the forum.


@cAlgo_Fanatic

cAlgo_Fanatic
07 May 2013, 12:01

Take profit has to be above the entry price for a buy order and below the entry price for a sell order.


@cAlgo_Fanatic

cAlgo_Fanatic
07 May 2013, 12:01

// Global scope, outside any method (function)
private double one = 0.0;

// local scope, e.g. inside the OnTick event
bool somethingHappens = Symbol.Ask.Equals(1.2); // for instance

if (somethingHappens && one.Equals(0.0))
{
    // if one does not equal zero, execution of the program will not reach here
    one = Symbol.Ask;  
}

 


@cAlgo_Fanatic

cAlgo_Fanatic
07 May 2013, 10:45

The Math library is part of the .NET framework. We may implement an add in for support of excel functionality in the future.


@cAlgo_Fanatic

cAlgo_Fanatic
07 May 2013, 10:32

Technical errors are due to invalid values. Therefore, most probably the Take Profit you are setting cannot be applied to all open orders. You would have to modify the code to calculate the value for take profit instead of assigning the same value to all. 


@cAlgo_Fanatic

cAlgo_Fanatic
07 May 2013, 10:26

post was removed


@cAlgo_Fanatic

cAlgo_Fanatic
07 May 2013, 10:12

This section of the forum includes examples of code. This is an example of how to use MarketDepth. The values indicated do not correspond to the bars above. If you notice they are updated constantly according to level 2 data. You can build a custom indicator that shows historical data using this example as a reference.

If you need help with the code please post your questions in the indicator development support section of the forum.


@cAlgo_Fanatic

cAlgo_Fanatic
07 May 2013, 09:54

To calculate the total pips for all open positions you can use this loop:

    double totalPips = 0;
    foreach (var position in Account.Positions)
    {
        totalPips += position.Pips;
    }




@cAlgo_Fanatic

cAlgo_Fanatic
26 Apr 2013, 18:01

Can you please recopy the code and let us know if you get the error? Also, let us know what error you are getting.


@cAlgo_Fanatic

cAlgo_Fanatic
26 Apr 2013, 16:41

We are working on performance optimizations but 17 charts with heavy indicators is a little excessive and may always have a cost on performance.


@cAlgo_Fanatic