Averaging in MC.net

Questions about MultiCharts .NET and user contributed studies.
Alexxx
Posts: 25
Joined: 28 Aug 2014
Has thanked: 4 times
Been thanked: 2 times

Averaging in MC.net

Postby Alexxx » 28 Aug 2014

As averaged in MC.net, using limit orders?
On playback its don't work.
I working only wirh market orders, but I want to use limit.

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Averaging in MC.net

Postby Henry MultiСharts » 28 Aug 2014

Hello Alexxx,

Please describe in mode details what you mean exactly.
What exact version and build number of MultiCharts are you running? (in MultiCharts go to Help tab-> About)
Which broker do you use?
Are you referring to automated or manual trading ?

Alexxx
Posts: 25
Joined: 28 Aug 2014
Has thanked: 4 times
Been thanked: 2 times

Re: Averaging in MC.net

Postby Alexxx » 28 Aug 2014

MC.net 9.0 beta 2
CQG
Automated trade

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Averaging in MC.net

Postby Henry MultiСharts » 29 Aug 2014

Alexxx, what is the particular difficulty you have ?

Alexxx
Posts: 25
Joined: 28 Aug 2014
Has thanked: 4 times
Been thanked: 2 times

Re: Averaging in MC.net

Postby Alexxx » 01 Sep 2014

Strategy can`t enter to market by limit-order. But can enter, if use market-order.

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Averaging in MC.net

Postby Henry MultiСharts » 02 Sep 2014

Please be more precise in your description. What happens when you place a limit order?
Please go to File -> New -> Order and position tracker window->Orders tab. What is the state of the order? Are there any error messages in the logs tab related to this order?

Alexxx
Posts: 25
Joined: 28 Aug 2014
Has thanked: 4 times
Been thanked: 2 times

Re: Averaging in MC.net

Postby Alexxx » 03 Sep 2014

I'm trying to do it on the playback

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Averaging in MC.net

Postby JoshM » 03 Sep 2014

Nevermind.
Last edited by JoshM on 16 Sep 2014, edited 1 time in total.

Alexxx
Posts: 25
Joined: 28 Aug 2014
Has thanked: 4 times
Been thanked: 2 times

Re: Averaging in MC.net

Postby Alexxx » 10 Sep 2014

Code: Select all

if (RetreatMode == RetreatMarketOrPending.Market)
{
MarketSearchEnterPointOfVolume();
}
if (RetreatMode == RetreatMarketOrPending.Pending)
{
PendingSearchEnterPointOfVolume();
}

void PendingSearchEnterPointOfVolume()
{
RetratStruct.FindedPoint = true;
RetratStruct.OpenPrice = Bars.Close[0];
if (CurrentPosition.Side == PowerLanguage.EMarketPositionSide.Long)
{
RetratStruct.OpenPrice = RetratStruct.OpenPrice - RetreatPendingModePoints * InstrumentInfo.Digits;
}
if (CurrentPosition.Side == PowerLanguage.EMarketPositionSide.Short)
{
RetratStruct.OpenPrice = RetratStruct.OpenPrice + RetreatPendingModePoints * InstrumentInfo.Digits;
}
RetratStruct.Side = CurrentPosition.Side;
}

void MarketSearchEnterPointOfVolume()
{
if (CurrentPosition.Side == PowerLanguage.EMarketPositionSide.Long)
{
BuyMarket.Send(FixedPanelStartCountContracts * 2);
}
if (CurrentPosition.Side == PowerLanguage.EMarketPositionSide.Short)
{
SellShortMarket.Send(FixedPanelStartCountContracts * 2);
}
}

void PendingRetreatOrders()
{
if (CurrentPosition.Side == PowerLanguage.EMarketPositionSide.Long)
{
//BuyStop.Send(RetratStruct.OpenPrice, FixedPanelStartCountContracts * 2);
if (Bars.Close[0] <= RetratStruct.OpenPrice) BuyMarket.Send(FixedPanelStartCountContracts * 2);
if (!IsFaster) Draw_TradeOrdersOnChart(RetratStruct.OpenPrice, "Enter RetreatLong", Bars.TimeValue, "OliveDrab");
}
if (CurrentPosition.Side == PowerLanguage.EMarketPositionSide.Short)
{
//SellShortStop.Send(RetratStruct.OpenPrice, FixedPanelStartCountContracts * 2);
if (Bars.Close[0] >= RetratStruct.OpenPrice) SellShortMarket.Send(FixedPanelStartCountContracts * 2);
if (!IsFaster) Draw_TradeOrdersOnChart(RetratStruct.OpenPrice, "Enter RetreatShort", Bars.TimeValue, "OliveDrab");
}
}

void Trading_IsRetreat(string Mode)
{
if (CurrentPosition.Side != PowerLanguage.EMarketPositionSide.Flat)
{
//double TP = Convert.ToDouble(ExitTakePrice[ExitTakePrice.Count - 1]);
double TP = Trading.TakeProfit;
//double SL = Convert.ToDouble(ExitStopPrice[ExitStopPrice.Count - 1]);
double SL = Trading.StopLoss;
if (CurrentPosition.Side == PowerLanguage.EMarketPositionSide.Long)
{
if (CurrentPosition.OpenLots == FixedPanelStartCountContracts)
{
if (RetreatMode == RetreatMarketOrPending.Pending) PendingRetreatOrders();
// БУ по Retreat Long - не проверено
SellLimit.Send(StrategyInfo.AvgEntryPrice + InstrumentInfo.Digits, CurrentPosition.OpenLots);
if (!IsFaster) Draw_TradeOrdersOnChart(StrategyInfo.AvgEntryPrice + InstrumentInfo.Digits, "No Loss for Long", Bars.TimeValue, "OliveDrab");
}

if (CurrentPosition.OpenLots > FixedPanelStartCountContracts)
{
SellStop.Send(SL, CurrentPosition.OpenLots);
if (!IsFaster) Draw_TradeOrdersOnChart(SL, "2*SL Long in " + Mode, Bars.TimeValue, "OrangeRed");

SellLimit.Send(TP, CurrentPosition.OpenLots);
if (!IsFaster) Draw_TradeOrdersOnChart(TP, "TP Long in " + Mode, Bars.TimeValue, "OliveDrab");
}
}
if (CurrentPosition.Side == PowerLanguage.EMarketPositionSide.Short)
{
if (CurrentPosition.OpenLots == FixedPanelStartCountContracts)
{
if (RetreatMode == RetreatMarketOrPending.Pending) PendingRetreatOrders();
BuyToCoverLimit.Send(StrategyInfo.AvgEntryPrice - InstrumentInfo.Digits, CurrentPosition.OpenLots);
if (!IsFaster) Draw_TradeOrdersOnChart(StrategyInfo.AvgEntryPrice - InstrumentInfo.Digits, "No Loss for Short", Bars.TimeValue, "OliveDrab");
}
if (CurrentPosition.OpenLots > FixedPanelStartCountContracts)
{
BuyToCoverStop.Send(SL, CurrentPosition.OpenLots);
if (!IsFaster) Draw_TradeOrdersOnChart(SL, "2*SL Short in " + Mode, Bars.TimeValue, "OrangeRed");

BuyToCoverLimit.Send(TP, CurrentPosition.OpenLots);
if (!IsFaster) Draw_TradeOrdersOnChart(TP, "TP Sell in " + Mode, Bars.TimeValue, "OliveDrab");
}

}
}
}

protected override void CalcBar()
{
if (Bars.LastBarOnChart)
{
if (TradeModes.IsRetreat) Trading_IsRetreat("Trend");
}
}
MarketSearchEnterPointOfVolume() - work
PendingSearchEnterPointOfVolume() - don`t work
Last edited by Alexxx on 21 Sep 2014, edited 1 time in total.

Alexxx
Posts: 25
Joined: 28 Aug 2014
Has thanked: 4 times
Been thanked: 2 times

Re: Averaging in MC.net

Postby Alexxx » 14 Sep 2014

Can you post the strategy code? Or code that replicates this behaviour? Then we can determine whether it's programming or software related.
I typed code

Alexxx
Posts: 25
Joined: 28 Aug 2014
Has thanked: 4 times
Been thanked: 2 times

Re: Averaging in MC.net

Postby Alexxx » 21 Sep 2014

Please be more precise in your description. What happens when you place a limit order?
Please go to File -> New -> Order and position tracker window->Orders tab. What is the state of the order? Are there any error messages in the logs tab related to this order?
Nothing happens. The situation is tested for playback, so there is no logs and records in the Order and position tracker window.

Earlier I posted the source code that handles this situation.


Return to “MultiCharts .NET”