Topics
Replies

ktzn
29 Jul 2014, 20:40

RE: RE:

Thanks Breaker!

 

Have completely forgotten to check here for a while - tried to look at what you posted but I cant get it to work according to what i have in mind :(

 

Possible to have a quick skype chat maybe, I can also post the full code here if it helps.

 

breakermind said:

Hi,

look at this: (MA - movingAverage) something like this

        protected override void OnTick()
        {

            foreach (var position in Positions)
            {

                if (position.TradeType == TradeType.Buy)
                {
                    // TP == MA
                    ModifyPosition(position, position.StopLoss, Convert.ToInt64(Ma));
                }
                if (position.TradeType == TradeType.Sell)
                {

                    // HighMinusLow == Ma 
                    ModifyPosition(position, Convert.ToInt64(Ma), position.TakeProfit);
                }

            }

        }

 

or:

            if (Symbol.Bid > Ma)
            {
                foreach (var openedPosition in Positions)
                {
                    ClosePosition(openedPosition);
                }
                Stop();
            }

close all position is allways possible :D:D:D

Regards

 


@ktzn

ktzn
13 Jun 2014, 23:21

no one ? :)


@ktzn

ktzn
27 May 2014, 10:56

RE:

modarkat said:

There are two ways to do that.

First of all you can convert moving average value to pips distance from a spot price.

Another way is to execute market order without TP and then modify TP as an absolute value.

            ExecuteMarketOrder(TradeType.Sell, Symbol, Volume, label, StopLossPips, null);
            if (LastResult.IsSuccessful)
            {
                ModifyPosition(LastResult.Position, LastResult.Position.StopLoss, mAverage);
            }

 

Thanks alot!

 

It works but not sure if it is doing exactly what i want. I want it to keep updating the target to current SMA, not just to modify the position once at entry to make target SMA.

 

The idea is that all trades should be exited as soon as price touches SMA no matter if it is long or short

 

is that possible?


@ktzn