Replies

apresau
03 Nov 2014, 16:46

Thankyou, invalid.

I now understand that function and realise that it isn't what I need to use -

I was trying to apply the lines to the full chart history and obviously need to use a different function.

Any ideas would be appreciated.

apresau


@apresau

apresau
30 Jul 2014, 05:22

RE: RE:

Thanks for your fast response, guys. Much appreciated.

In trying to track the problem I commented out all lines and functions referencing the RefPrice array.

The program ran fine. Which makes me think that my array syntax is wanting.

Looks like I'll have to download Visual Studio. (been avoiding it due to our awful internet speeds)

Invalid said:

Could you provide full code? 

Most probably position variable is not initialized.

apresau said:

Hi,

I'm having trouble with a crashing cBot.

The log message reads -

Crashed in OnTick with NullReferenceException: Object reference not set to an instance of an object.

The offending code is associated with the array -

        private double[] ExitPrice = new double[20];


        protected override void OnTick()
        {

// trade entry ---------
<>
               SetExitPriceArray();


// trade exit ---------
            if (Positions.Count > 0)
            {
                TradeCnt = Positions.Count;

                if (position.TradeType == TradeType.Buy)
                {
                    if (Ask <= ExitPrice[TradeCnt - 1])
                    {
                        CloseAllTrades();
                        return;
                    }
                }

                if (position.TradeType == TradeType.Sell)
                {
                    if (Bid >= ExitPrice[TradeCnt - 1])
                    {
                        CloseAllTrades();
                        return;
                    }
                }
            }
        }



// FUNCTIONS ------------------------------------------------------------------------------

<< other functions>>

        private void SetExitPriceArray()
        {
            double RefPrice;
            if (position.TradeType == TradeType.Buy)
            {
                RefPrice = Symbol.Ask;

                for (int i = 1; i < 4; i++)
                {
                    ExitPrice[i] = RefPrice;
                }
                for (int i = 4; i < 20; i++)
                {
                    ExitPrice[i] = RefPrice + (PipStep * Symbol.TickSize) * (i - 3);
                }
            }


            if (position.TradeType == TradeType.Sell)
            {
                RefPrice = Symbol.Bid;

                for (int i = 1; i < 4; i++)
                {
                    ExitPrice[i] = RefPrice;
                }
                for (int i = 4; i < 20; i++)
                {
                    ExitPrice[i] = RefPrice + (PipStep * Symbol.TickSize) * (i - 3);
                }
            }
        }
    }
}

I don't understand enough to be able to interpret the log entry.

If someone could help I'd be most grateful.

apresau

 

 


@apresau

apresau
31 Mar 2014, 18:23 ( Updated at: 21 Dec 2023, 09:20 )

RE:

Cerunnos said:

I'm looking for the Price Action Channel Indicator. Does anyone have experience with it?
Thanks,
Rainer

 

 

Perhaps this may help.

using cAlgo.API;
using cAlgo.API.Indicators;

namespace cAlgo.Indicators
{
    [Indicator(IsOverlay = true, AccessRights = AccessRights.None)]
    public class MAHi_LoBands : Indicator
    {
        private MovingAverage MA;
        private MovingAverage MA_hi;
        private MovingAverage MA_lo;


        [Parameter(DefaultValue = 5)]
        public int Period { get; set; }

        [Parameter("MAType")]
        public MovingAverageType matype { get; set; }

        [Output("Main", Color = Colors.Gray)]
        public IndicatorDataSeries EnvelopeMain { get; set; }

        [Output("ChannelHigh", Color = Colors.DeepSkyBlue)]
        public IndicatorDataSeries ChannelHigh { get; set; }

        [Output("ChannelLow", Color = Colors.Tomato)]
        public IndicatorDataSeries ChannelLow { get; set; }

        protected override void Initialize()
        {
            MA = Indicators.MovingAverage(MarketSeries.Close, Period, matype);
            MA_hi = Indicators.MovingAverage(MarketSeries.High, Period, matype);
            MA_lo = Indicators.MovingAverage(MarketSeries.Low, Period, matype);
        }

        public override void Calculate(int index)
        {
            EnvelopeMain[index] = MA.Result[index];
            ChannelHigh[index] = MA_hi.Result[index];
            ChannelLow[index] = MA_lo.Result[index];
        }
    }
}

 

 


@apresau

apresau
31 Mar 2014, 17:45

RE:

modarkat said:

cAlgo.API.Color is equalent to System.Drawing.Color:

http://safeery2k.files.wordpress.com/2013/06/system-drawing-knowncolor.png

Thanks very much.


@apresau