Topics
15 Jul 2014, 12:26
 3464
 7
11 Jul 2014, 10:27
 2515
 3
11 Jul 2014, 07:43
 3674
 7
02 Jul 2014, 00:18
 8721
 12
26 Jun 2014, 09:08
 3724
 9
25 Jun 2014, 07:17
 2510
 2
20 Jun 2014, 18:21
 2354
 3
15 Sep 2013, 12:50
 4762
 6
Replies

RootFX
17 Jul 2014, 22:07

thank you team spotware :) 


@RootFX

RootFX
17 Jul 2014, 06:47

thank you breakmind 

 


@RootFX

RootFX
14 Jul 2014, 22:11

ok how edit this method 

 protected int GetVolume
        {
            get
            {
                var risk = (int)(RiskPct * Account.Balance / 100);

                int volumeOnRisk = stoploss > 0 ? (int)(risk * Symbol.Ask / (Symbol.PipSize * stoploss)) : Volume;

                double maxVolume = Account.Equity * Leverage * 100 / 101;


                double vol = Math.Min(volumeOnRisk, maxVolume);

                return (int)Math.Truncate(Math.Round(vol) / 10000) * 10000;
                // round to 10K
            }
        }

you can set RiskPct like this 1% or 2 % ... etc 

but i want calc in stoploss 


@RootFX

RootFX
12 Jul 2014, 23:19

thank you 

i will try this in open market 

 


@RootFX

RootFX
11 Jul 2014, 11:40

thank you 
but Volume it's Big 
cbot show message not mony enough .! 

please try this in calgo 


@RootFX

RootFX
11 Jul 2014, 10:12 ( Updated at: 21 Dec 2023, 09:20 )

why show Long volume .?

 


@RootFX

RootFX
11 Jul 2014, 09:55 ( Updated at: 21 Dec 2023, 09:20 )

RE:

modarkat said:

Here you go

/forum/cbot-support/2929

 

but it's work like this method 100% .? 

double lotsoptimized(){
   double lot;
   if(stoploss>0)lot=AccountBalance()*(risk/100)/(stoploss*pt/MarketInfo(Symbol(),MODE_TICKSIZE)*MarketInfo(Symbol(),MODE_TICKVALUE));
   else lot=NormalizeDouble((AccountBalance()/1000)*minlot*risk,lotdigits);
   //lot=AccountFreeMargin()/(100.0*(NormalizeDouble(MarketInfo(Symbol(),MODE_MARGINREQUIRED),4)+5.0)/risk)-0.05;
   return(lot);
}

 


@RootFX

RootFX
03 Jul 2014, 21:42 ( Updated at: 21 Dec 2023, 09:20 )

now it's work 100%

 


@RootFX

RootFX
03 Jul 2014, 04:42

RE:

Spotware said:

First of all, value which you assign to the _prevValue field cannot be considered as a previous value of ZigZag. It is a last value calculated on the previous tick.

Second of all, ZigZag indicator doesn't write values to every index. Therefore in order to retrieve value which you selected on the image, you need to iterate through _zigZag.Result DataSeries and find a value which is not double.NaN.

thank you team Spotware

please you can set example .?


@RootFX

RootFX
01 Jul 2014, 04:10

i try this and it's Work 100%  :)

 

  protected override void OnBar()
        {
            // Put your core logic here
            

            bool isLongPositionOpen  = pos != null && pos.TradeType == TradeType.Buy;
            bool isShortPositionOpen = pos != null && pos.TradeType == TradeType.Sell;

   
            if (cci.Result.Last(2) < 0 && cci.Result.Last(1) > 0 && !isLongPositionOpen)
            {
                var result = ExecuteMarketOrder(TradeType.Buy, Symbol, GetVolume, Label, StopLoss, TakeProfit);
               pos = result.Position;
            }
            else if (cci.Result.Last(2) > 0 && cci.Result.Last(1) < 0 && !isShortPositionOpen)
            {
                var result = ExecuteMarketOrder(TradeType.Sell, Symbol, GetVolume, Label, StopLoss, TakeProfit);
                pos = result.Position;
            }


           




        }

thank you


@RootFX

RootFX
30 Jun 2014, 03:33 ( Updated at: 21 Dec 2023, 09:20 )

hi i try this

and show this result

and i change

  _cci = Indicators.CommodityChannelIndex(Periods);

i set this in method onBar()

and show this result

 

I do not know where is the problem !!!

in MQL4 it's very easy but in calgo I do not understand the problem

this expert :

 

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

namespace cAlgo
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]
    public class z_cci : Robot
    {
        [Parameter("Volume", DefaultValue = 10000)]
        public int Volume { get; set; }

        [Parameter("Periods", DefaultValue = 20, MinValue = 1)]
        public int Periods { get; set; }


        [Parameter("Label", DefaultValue = "labelname")]
        public string label { get; set; }

        [Parameter("TP", DefaultValue = 50, MinValue = 10)]
        public int TP { get; set; }


        [Parameter("SL", DefaultValue = 0, MinValue = 0)]
        public int SL { get; set; }



        private CommodityChannelIndex _cci;
        private Position _position;


        protected override void OnStart()
        {
            _cci = Indicators.CommodityChannelIndex(Periods);
        }


        protected override void OnBar()
        {
           // _cci = Indicators.CommodityChannelIndex(Periods);
            _position = Positions.Find(label);
            bool isLongPositionOpen = _position != null && _position.TradeType == TradeType.Buy;
            bool isShortPositionOpen = _position != null && _position.TradeType == TradeType.Sell;
            Print("CCI ===> "+ _cci.Result.LastValue );
            if (_cci.Result.HasCrossedAbove(0.0, 2) && _cci.Result.HasCrossedBelow(0.0, 1) && !isShortPositionOpen)
            {
                ExecuteMarketOrder(TradeType.Sell, Symbol, Volume, label, SL, TP);

            }

            if (_cci.Result.HasCrossedBelow(0.0, 2) && _cci.Result.HasCrossedAbove(0.0, 1) && !isLongPositionOpen)
            {
                ExecuteMarketOrder(TradeType.Buy, Symbol, Volume, label, SL, TP);
            }

        }


        protected override void OnStop()
        {
            // Put your deinitialization logic here
        }



    }
}

any body can fix this expert and show what problem

thank you


@RootFX

RootFX
29 Jun 2014, 00:42 ( Updated at: 21 Dec 2023, 09:20 )

RE: RE:

breakermind said:

Hi,

search solutions do not expect the final solution - if you want to learn

Check line by line why conditions dont work and use Print("CCI1 " + _cci + "" + ...)
search robot which already works and compare :)

but working! conditions check it alone:

cBots is a waste of time ... :)

Regards

thank you breakermind

i will try this after open market

thank you again :)


@RootFX

RootFX
27 Jun 2014, 01:10 ( Updated at: 21 Dec 2023, 09:20 )

thank you :)

but not open any order

 


@RootFX

RootFX
21 Jun 2014, 05:52

RE:

algotrader said:

You don't need to fix those warnings.

thank you :)

i love platform Ctrader and i'm move from metatrader to ctarder :)

 

 


@RootFX