Replies

handiphangceo@gmail.com
27 Mar 2017, 17:57

RE: RE: RE: RE: RE: RE: RE: RE: RE: RE: RE: RE: RE: RE: RE: RE: RE:

AthenasGuidance said:

handiphangceo@gmail.com said:

AthenasGuidance said:

AthenasGuidance said:

It could be because of the foreach statement (Position instead of (var PositionLong..

And you may need these before the foreach statements:

            var PositionLong = Positions.Find("Buy", null, TradeType.Buy);
            var PositionShort = Positions.Find("Sell, null, TradeType.Sell);

 

alot or error > . <

sure i can show you, send me your email address

 

Email: AthenasGuidance@sharklasers.com

It's a temporary disposable email.

done


@handiphangceo@gmail.com

handiphangceo@gmail.com
27 Mar 2017, 17:29

RE: RE: RE: RE: RE: RE: RE: RE: RE: RE: RE: RE: RE: RE: RE:

AthenasGuidance said:

AthenasGuidance said:

It could be because of the foreach statement (Position instead of (var PositionLong..

And you may need these before the foreach statements:

            var PositionLong = Positions.Find("Buy", null, TradeType.Buy);
            var PositionShort = Positions.Find("Sell, null, TradeType.Sell);

 

alot or error > . <

sure i can show you, send me your email address


@handiphangceo@gmail.com

handiphangceo@gmail.com
27 Mar 2017, 15:47

RE: RE: RE: RE: RE: RE: RE: RE: RE: RE: RE: RE:

AthenasGuidance said:

AthenasGuidance said:

Please change the second foreach functions label from "Buy" to "Sell".

build succeeded but cannot execute buy or sell, anyway thanks for helping me sir, i hope someone can help yours too :)


@handiphangceo@gmail.com

handiphangceo@gmail.com
27 Mar 2017, 14:48

RE: RE: RE: RE:

AthenasGuidance said:

handiphangceo@gmail.com said:

 

Hi, i tried and i can only open position for 1 transaction :)

 

 

What do you mean by 'Transaction'?

,,Do you mean pair?

Yes Sir.

i sorry for my broken English, 

so why im asking the code is because the bot keep opening multiple transaction, example : it buy EURUSD, then another minute it buy EURUSD again.

i want to check if i already have EURUSD opened, then the bot no need to open position anymore. But i want them to keep able buy/sell another pair :)


@handiphangceo@gmail.com

handiphangceo@gmail.com
27 Mar 2017, 14:33

RE: RE:

AthenasGuidance said:

handiphangceo@gmail.com said:

hellow, can you check is this correct..

 

protected override void OnBar()
        {
            var positionsBuy = Positions.FindAll("Buy");
            var positionsSell = Positions.FindAll("Sell");

            var distanceFromUpKumo = (Symbol.Bid - ichimoku.SenkouSpanA.Last(26)) / Symbol.PipSize;
            var distanceFromDownKumo = (ichimoku.SenkouSpanA.Last(26) - Symbol.Ask) / Symbol.PipSize;



            if (MarketSeries.Open.Last(1) <= ichimoku.SenkouSpanA.Last(27) && MarketSeries.Open.Last(1) > ichimoku.SenkouSpanB.Last(27))
            {
                if (MarketSeries.Close.Last(1) > ichimoku.SenkouSpanA.Last(27))
                {
                    if (distanceFromUpKumo <= 25)
                    {

                       //but if i put this way, i can only have 1 opened position at one momment, am i right ?

                        if (position.TradeType != TradeType.Buy && TradeType.Sell)

                        {
                        ExecuteMarketOrder(TradeType.Buy, Symbol, Volume, "Buy", StopLossPips, TakeProfitPips);

                        }
                    }
                }
            }

 

 

Hi Handi

I'm sorry I don't think that is correct ..however, I could be wrong.

If the previous code did not work, try the one below, the previous one was written not copied and pasted:

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

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.CentralStandardTime, AccessRights = AccessRights.None)]
    public class BigBarRobot : Robot
    {
        [Parameter("Volume:", DefaultValue = 1, MinValue = 1, Step = 1)]
        public int Volume { get; set; }
        [Parameter("StopLossPips:", DefaultValue = 10, MinValue = 1, Step = 0.5)]
        public double StopLossPips { get; set; }
        [Parameter("TakeProfitPips:", DefaultValue = 20, MinValue = 1, Step = 0.5)]
        public double TakeProfitPips { get; set; }

 protected override void OnBar()
        {
            //Search All Positions Open And Label That Search "TotalPositions"
            var TotalPositions = Positions.Count;
            {
                //If The Search Labeled "TotalPositions" Reports That No Position Is Open (Null or Less Than 1 or zero), Then, ExecuteMarketOrder
                if (TotalPositions < 1)
                    ExecuteMarketOrder(TradeType.Buy, Symbol, Volume, "Buy", StopLossPips, TakeProfitPips);
            }
        }
    }
}

Enjoy.

Hi, i tried and i can only open position for 1 transaction :)


@handiphangceo@gmail.com

handiphangceo@gmail.com
27 Mar 2017, 13:45

RE: Hi Handi

AthenasGuidance said:

I new to programming, so please take this with a grain of salt:

            //Check To See If Any Pending Orders Are Open
            var TotalOrders = Position.Count;

            {
                //Check if TotalOrders (any position) is open, if so, do not go to next line
                if (TotalOrders = null)
                    
                    //next line
                    ExecuteMarketOrder()
            }

Hope it helps.

 thanks for replying :)


@handiphangceo@gmail.com

handiphangceo@gmail.com
27 Mar 2017, 13:43

if (position.SymbolCode == Symbol.Code && positionsBuy.Length == 0 && positionsSell.Length == 0)

 

if i put this way it cannot execute buy/sell ^^''


@handiphangceo@gmail.com

handiphangceo@gmail.com
27 Mar 2017, 12:21

hellow, can you check is this correct..

 

protected override void OnBar()
        {
            var positionsBuy = Positions.FindAll("Buy");
            var positionsSell = Positions.FindAll("Sell");

            var distanceFromUpKumo = (Symbol.Bid - ichimoku.SenkouSpanA.Last(26)) / Symbol.PipSize;
            var distanceFromDownKumo = (ichimoku.SenkouSpanA.Last(26) - Symbol.Ask) / Symbol.PipSize;



            if (MarketSeries.Open.Last(1) <= ichimoku.SenkouSpanA.Last(27) && MarketSeries.Open.Last(1) > ichimoku.SenkouSpanB.Last(27))
            {
                if (MarketSeries.Close.Last(1) > ichimoku.SenkouSpanA.Last(27))
                {
                    if (distanceFromUpKumo <= 25)
                    {

                       //but if i put this way, i can only have 1 opened position at one momment, am i right ?

                        if (position.TradeType != TradeType.Buy && TradeType.Sell)

                        {
                        ExecuteMarketOrder(TradeType.Buy, Symbol, Volume, "Buy", StopLossPips, TakeProfitPips);

                        }
                    }
                }
            }

 


@handiphangceo@gmail.com

handiphangceo@gmail.com
24 Mar 2017, 19:50

excellent! it works! ^^ thank you


@handiphangceo@gmail.com

handiphangceo@gmail.com
24 Mar 2017, 15:11

ups sorry i miss a line

here is the complete one

 

foreach (var position in Positions)
            {
                if (position.TradeType == TradeType.Buy)
                {
                    if (((Symbol.Bid + Symbol.Ask) / 2) <= (distanceFromKijun - 0.02))
                    {
                        foreach (var position in Positions)
                        if (position.SymbolCode == Symbol.Code)
                        {

                            ClosePosition(position);
                        }


                    }
                    else if (position.TradeType == TradeType.Sell)
                    {
                        if (((Symbol.Ask + Symbol.Bid) / 2) >= (distanceFromKijun + 0.02))
                        {
                            foreach (var position in Positions)
                            if (position.SymbolCode == Symbol.Code)
                            {

                                ClosePosition(position);
                            }
                            {
                            }
                        }
                    }


@handiphangceo@gmail.com

handiphangceo@gmail.com
24 Mar 2017, 15:07

thanks for replying Sir..

but i got this error

Error CS0136: A local variable named 'position' cannot be declared in this scope because it would give a different meaning to 'position', which is already used in a 'parent or current' scope to denote something else.

 

this is my code

foreach (var position in Positions)
            {
                if (position.TradeType == TradeType.Buy)
                {
                    if (((Symbol.Bid + Symbol.Ask) / 2) <= (distanceFromKijun - 0.02))
                    {

                        if (position.SymbolCode == Symbol.Code)
                        {

                            ClosePosition(position);
                        }
                        {
                        }
                    }
                    else if (position.TradeType == TradeType.Sell)
                    {
                        if (((Symbol.Ask + Symbol.Bid) / 2) >= (distanceFromKijun + 0.02))
                        {
                            foreach (var position in Positions)
                                if (position.SymbolCode == Symbol.Code)
                                {

                                    ClosePosition(position);
                                }
                            {
                            }
                        }
                    }


sorry if its messy > . <


@handiphangceo@gmail.com

handiphangceo@gmail.com
23 Mar 2017, 05:48

help pleaseee > . <


@handiphangceo@gmail.com