Position Label.

Created at 08 Sep 2017, 19:04
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!
AB

ablouwrens

Joined 08.09.2017

Position Label.
08 Sep 2017, 19:04


Good day Ctrader Team.

I would appreciate some help please.

The cBot needs to open 2 trades each with a different label, the easy part.

But I would like to know how can I, when a SMA is active, get the bot to open the second trade when the SMA crosses above the open trade with a already specified label?

​For example:

if (sma > (first trade label)

{

ExecuteMarketOrder (TradeType.Buy, Symbol, Volume, 2ndTrade);

}

 

 

Thank you kindly.

 

Andre'


@ablouwrens
Replies

Spotware
11 Sep 2017, 09:08

Dear ablouwrens,

Thanks for posting in our forum. Please see the code sample below and let us know if this is what you need

            var sma = Indicators.SimpleMovingAverage(MarketSeries.Median, 14);
            if (sma.Result.LastValue > Positions.Find("first trade label").EntryPrice)
            {
                ExecuteMarketOrder(TradeType.Buy, Symbol, 1000, "2ndTrade");
            }

Best Regards,

cTrader Team


@Spotware

ablouwrens
15 Sep 2017, 10:32

RE:

Spotware said:

Dear ablouwrens,

Thanks for posting in our forum. Please see the code sample below and let us know if this is what you need

            var sma = Indicators.SimpleMovingAverage(MarketSeries.Median, 14);
            if (sma.Result.LastValue > Positions.Find("first trade label").EntryPrice)
            {
                ExecuteMarketOrder(TradeType.Buy, Symbol, 1000, "2ndTrade");
            }

Best Regards,

cTrader Team

Dear cTrader Team.

You are more than welcome and thank you kindly for your reply.

Will be sure to visit the forum again in the near future.

Kind regards.

Andre'


@ablouwrens