Topics
21 Feb 2019, 15:59
 1310
 1
19 Feb 2019, 11:14
 1120
 3
18 Feb 2019, 14:21
 994
 1
01 Nov 2018, 15:55
 1170
 5
31 Oct 2018, 14:13
 1142
 1
26 Aug 2018, 21:15
 1085
 3
17 Aug 2018, 13:10
 1584
 2
Replies

jelle2500
20 Feb 2019, 01:03

RE:

erisoftdevelop said:

Well if you will use the OnBar event the evaluation of the condition to buy or Sell will be in the creation of the third candle.

  var lastcandlehigh= MarketSeries.High.Last(1);
  var beforelastcandlehigh= MarketSeries.High.Last(2);

 

// Buy Condition as you propose

// Example of Buy: Lastcandlehigh= 50 , beforelastcandlehigh=48 clearly a buy.

// Example of Sell: Lastcandlehigh: 50, beforelastcandlehigh=60 clearly a sell (ELSE condition)

if(lastcandlehigh>beforelastcandlehigh){

 ExecuteMarketOrder(TradeType.Buy, Symbol, VolumeInUnits, label, SLBuy, null);

}else{

 ExecuteMarketOrder(TradeType.Sell, Symbol, VolumeInUnits, label, SLSell, null);

}

 

As a observation this code could produce some effect in higher timeframe in short time frame as 15m and 5min or 1min not recommended, Why? Due to the Spread (The difference of the BID and ASK price) provided by the different brokers. Take in consideration requester.

Thanks fot your help! i've got it.

 

Jelle


@jelle2500

jelle2500
01 Nov 2018, 16:14

RE:

Panagiotis Charalampous said:

Hi jelle2500,

Here you are

            var tpBuy = Math.Round((MarketSeries.Low.Last(3) - Symbol.Ask) / Symbol.PipSize, Symbol.Digits);

            var tpSell = Math.Round((Symbol.Bid - MarketSeries.High.Last(3)) / Symbol.PipSize, Symbol.Digits);

Best Regards,

Panagiotis

you are the best! thanks Panagiotis!


@jelle2500

jelle2500
01 Nov 2018, 16:01

RE:

Panagiotis Charalampous said:

Hi jelle2500,

Yes this is right.

Best Regards,

Panagiotis

thanks Panagiotis! for the last part of my bot i'm tryping to make a take profit on last(3)

so when a buy trade is open take profit should be on MarketSeries.Low.Last(3)

and when a sell trade is open take profit should be on MarketSeries.High.Last(3)

 

can you help me with this?


@jelle2500

jelle2500
30 Oct 2018, 12:33

RE:

Panagiotis Charalampous said:

Change this one as well

var stopLossSell = MarketSeries.High.Last(1) + Symbol.PipSize * SL;

Best Regards,

Panagiotis

oh didn't see thisone yet..

works perfect! thanks Panagiotis!!


@jelle2500

jelle2500
30 Oct 2018, 12:27

RE:

Panagiotis Charalampous said:

Hi jelle2500,

Try this line of code

var SLSell = Math.Round((stopLossSell - Symbol.Bid) / Symbol.PipSize);

Best Regards,

Panagiotis

got another sollution..

i'm making 2 different types of stoploss parameters..

for example:

BuyStopLoss: 10 pips

SellStopLoss: -10 pips


@jelle2500

jelle2500
30 Oct 2018, 12:19

RE:

Panagiotis Charalampous said:

Hi jelle2500,

Try this line of code

var SLSell = Math.Round((stopLossSell - Symbol.Bid) / Symbol.PipSize);

Best Regards,

Panagiotis

i did celebrate to soon.. the stoploss still is below the high instead of above the high..


@jelle2500

jelle2500
30 Oct 2018, 12:15

RE:

Panagiotis Charalampous said:

Hi jelle2500,

Try this line of code

var SLSell = Math.Round((stopLossSell - Symbol.Bid) / Symbol.PipSize);

Best Regards,

Panagiotis

hero!

thank!


@jelle2500

jelle2500
29 Oct 2018, 12:46

RE:

freemangreat said:

The result of the indicator will be in the Log. For the best filtering of candles see how to change the function checkCandle.

using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;

namespace cAlgo
{
    [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class TestCandle : Indicator
    {
        [Parameter(DefaultValue = 0.0)]
        public double Parameter { get; set; }

        [Output("Main")]
        public IndicatorDataSeries Result { get; set; }

        bool bFirst =true;
        
        protected override void Initialize()
        {
            // Initialize and create nested indicators
        }

        public override void Calculate(int index)
        {
        CANDLE candle;
        
            if(IsLastBar && bFirst) 
            {
            int c =5; // check last 5 bars
            index -=(c - 1);
            
                while(c-- > 0)
                {
                    candle =checkCandle(index);
                    Print("Bar: {0} - Body: {1} PinUp: {2} PinDown: {3} DiffPins: {4}", 
                            index++, 
                            candle.fBody,
                            candle.fPinUp,
                            candle.fPinDown,
                            candle.fDiffPins);
                }
                
                bFirst =false;
            }
        }
//........................................................................
        public CANDLE checkCandle(int iCandle)
        {
        CANDLE candle = new CANDLE {};
        
            candle.fBody =(MarketSeries.Close[iCandle] - MarketSeries.Open[iCandle]);
            
            // if bull candle
            if(candle.fBody > 0) 
            {
                candle.fPinUp =(MarketSeries.High[iCandle] - MarketSeries.Close[iCandle]);
                candle.fPinDown =(MarketSeries.Open[iCandle] - MarketSeries.Low[iCandle]);
            }
            // if bear or 0
            else 
            {
                candle.fPinUp =(MarketSeries.High[iCandle] - MarketSeries.Open[iCandle]);
                candle.fPinDown =(MarketSeries.Close[iCandle] - MarketSeries.Low[iCandle]);
            }
            
            candle.fDiffPins =0;
            // compare pins
            if(candle.fPinUp >= Symbol.PipSize && candle.fPinDown >= Symbol.PipSize)
                if(candle.fPinUp > candle.fPinDown)
                    candle.fDiffPins =(candle.fPinUp / candle.fPinDown);
                else
                if(candle.fPinUp < candle.fPinDown)
                    candle.fDiffPins =(-candle.fPinDown / candle.fPinUp);        
                
            candle.fDiffPins *=100;
            
        return(candle);            
        }
//------------------------------------------------------------------------
        public struct CANDLE
        {
            public double fBody;    // +/0/- ; bullish - positive, bearish - negative
            public double fPinUp;   // +/0 ; allways positive or 0
            public double fPinDown; // +/0 ; allways positive or 0
            public double fDiffPins; // +/-(%); PinUp > PinDown (+) : PinUp < PinDown (-)
        } 
    }
}

 

got it thanks!!


@jelle2500

jelle2500
27 Aug 2018, 10:52

RE: RE:

patrick.sifneos@gmail.com said:

Hey Jelle

Difference in Pips: 

(MarketSeries.High.Last(1) - MarketSeries.Low.Last(1)) / Symbol.PipSize 

So this part (and more then a number of pips) is solved then.

thanks!

 

 

jelle2500 said:

Can someone fix this for me?

 

I need this:

 

the difference between MarketSeries.High.Last(1) and MarketSeries.Low.Last(1) = 100 % and more then (number of pips).

then if the difference between MarketSeries.Low.Last(1) and MarketSeries.Close.Last(1) = more then 50% of the candle

{

Buy signal = true.

Else if the difference between MarketSeries.High.Last(1) and  MarketSeries.Close.Last(1) = more than 50% of the candle

{

Sell signal = true.

 

 

Thanks,

Jelle

 

 


@jelle2500

jelle2500
17 Aug 2018, 16:33 ( Updated at: 21 Dec 2023, 09:20 )

 

just need a simple bot who takes buy after the bullish pin bar is closed ans sell after the bearish pin bar is closed.

 

but i need to have a parameter witch i can use to set the minimal percentage of tail in the candle 


@jelle2500

jelle2500
24 May 2018, 09:47

RE:

Panagiotis Charalampous said:

Hi,

You can try something like this

 _volume = (long)Math.Ceiling(Account.Equity / 1000) * 1000

Best Regards,

Panagiotis

Thanks Panagiotis!


@jelle2500

jelle2500
14 May 2018, 09:51

RE:

Panagiotis Charalampous said:

Hi jelle2500,

You can use a condition like below

            if (Positions.Count(x => x.TradeType == TradeType.Buy) == 0)
            {
                // Execute Buy Trade
            }

?Let me know if this helps you

 

Best Regards,

Panagiotis

Again, thanks a lot Panagiotis!


@jelle2500

jelle2500
14 May 2018, 09:49

RE:

Panagiotis Charalampous said:

Hi jelle2500,

See below

if(AllowBuy1 || AllowBuy2)
{
// Execute Buy Order
}
if(AllowSell1 || AllowSell2)
{
// Execute Sell Order
}

Let me know if this is what you are looking for.

Best Regards,

Panagiotis

Perfect! thanks a lot Panagiotis!

 


@jelle2500

jelle2500
23 Apr 2018, 16:03

RE:

tradermatrix said:

you have to program one command at a time
can be like that;
 

using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;

namespace cAlgo
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class EMACross_RSI : Robot
    {
        [Parameter("Source")]
        public DataSeries SourceSeries { get; set; }

        [Parameter("Slow Periods", DefaultValue = 30)]
        public int SlowPeriods { get; set; }

        [Parameter("Fast Periods", DefaultValue = 14)]
        public int FastPeriods { get; set; }

        [Parameter("Quantity (Lots)", DefaultValue = 1, MinValue = 0.01, Step = 0.01)]
        public double Quantity { get; set; }

        [Parameter("Stop Loss (pips)", DefaultValue = 20, MinValue = 0)]
        public int StopLossInPips { get; set; }

        [Parameter("Take Profit (pips)", DefaultValue = 60, MinValue = 0)]
        public int TakeProfitInPips { get; set; }

        private ExponentialMovingAverage slowMa;
        private ExponentialMovingAverage fastMa;

        private const string label = "EMA";

        private Position longPosition;
        private Position shortPosition;

        protected override void OnStart()
        {
            fastMa = Indicators.ExponentialMovingAverage(SourceSeries, FastPeriods);
            slowMa = Indicators.ExponentialMovingAverage(SourceSeries, SlowPeriods);
        }

        protected override void OnBar()
        {
            var cBotPositions = Positions.FindAll(label);

            longPosition = Positions.Find(label, Symbol, TradeType.Buy);
            shortPosition = Positions.Find(label, Symbol, TradeType.Sell);

            if (cBotPositions.Length >= 1)
                return;

            if (slowMa.Result.Last(1) < fastMa.Result.Last(1) && longPosition == null)
            {
                ExecuteMarketOrder(TradeType.Buy, Symbol, VolumeInUnits, label, StopLossInPips, TakeProfitInPips);

            }
            else if (slowMa.Result.Last(1) > fastMa.Result.Last(1) && shortPosition == null)
            {
                ExecuteMarketOrder(TradeType.Sell, Symbol, VolumeInUnits, label, StopLossInPips, TakeProfitInPips);

            }


        }

        private long VolumeInUnits
        {
            get { return Symbol.QuantityToVolume(Quantity); }
        }
    }
}

thanks a lot for your reply, but can i put a rule that make 1 trade posible each MA Crossover till the next crossover comes?

because when i set a stoploss of trailing stoploss and the trade is closed my bot takes another trade when my signals are still active..

my bot needs to wait for the next MA Crossover.

 

 


@jelle2500