How to use dynamic Label in ExecuteMarketOrder?

Created at 26 May 2014, 08:23
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
CU

curious

Joined 02.03.2014

How to use dynamic Label in ExecuteMarketOrder?
26 May 2014, 08:23


Hi

Is there any way to use dynamic Label in ExecuteMarketOrder?

I tried something like this but I am getting error message "Crashed in OnTick with NullReferenceException: Object reference not set to an instance of an object."

                tradeCount += 1;
                string tradeLabel = tradeCount.ToString();
                ExecuteMarketOrder(TradeType.Buy, Symbol, Volume, tradeLabel, StopLoss, TakeProfit);

 

 


@curious
Replies

Invalid
26 May 2014, 10:26

RE:

Try smth like this:

    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class Sample : Robot
    {
        int tradeCount = 0;

        protected override void OnTick()
        {
            tradeCount++;
            string tradeLabel = tradeCount.ToString();
            ExecuteMarketOrder(TradeType.Buy, Symbol, 10000, tradeLabel, StopLoss, TakeProfit);
        }
    }

 

curious said:

Hi

Is there any way to use dynamic Label in ExecuteMarketOrder?

I tried something like this but I am getting error message "Crashed in OnTick with NullReferenceException: Object reference not set to an instance of an object."

                tradeCount += 1;
                string tradeLabel = tradeCount.ToString();
                ExecuteMarketOrder(TradeType.Buy, Symbol, Volume, tradeLabel, StopLoss, TakeProfit);

 

 

 


@Invalid

curious
27 May 2014, 05:54

Thanx!


@curious