i need Heging

Created at 29 Aug 2016, 05:42
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
TA

tang_to_444@hotmail.com

Joined 26.04.2016

i need Heging
29 Aug 2016, 05:42


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 testHED : Robot
    {
        [Parameter("Lots", DefaultValue = 0.01)]
        public double Quantity { get; set; }
        [Parameter("Step (pips)", DefaultValue = 10)]
        public double step { get; set; }
        [Parameter("Label", DefaultValue = "H")]
        public string Label { get; set; }
        public int n;
        public double price;
        public int bs;
 
        protected override void OnStart()
        {
            Positions.Opened += openedposition;
            n = 0;
            bs = 0;
 
        }
        protected override void OnTick()
        {
            Print("price" + price);
            Print("N" + n);
            Print("bs" + bs);
            if (n > 0)
            {
                if (bs == 1)
                {
                     if (Symbol.Bid > (price + step * Symbol.PipSize)){
                         close();
                     }
                }
                else if(bs==2){
                    if(Symbol.Ask < (price - step * 2 * Symbol.PipSize)){
                        close();
                    }
                }
             /*   if ((Symbol.Bid > (price + step * Symbol.PipSize)) || (Symbol.Ask < (price - step * 2 * Symbol.PipSize)))
                {
                    close();
                }   */
            }
            var count = Positions.Find(Label, Symbol);
            if (count == null)
            {
                var volumeInUnits = Symbol.QuantityToVolume(Quantity);
                ExecuteMarketOrder(TradeType.Buy, Symbol, volumeInUnits, Label, null, null);
            }
 
        }
        public void openedposition(PositionOpenedEventArgs arg)
        {
 
            var pos = arg.Position;
 
            n++;
 
            var volumeInUnits = Symbol.QuantityToVolume(Quantity) * ((n + 1) * (n + 1));
 
            if (n == 1)
            {
                price = pos.EntryPrice;
            }
 
            if (pos.TradeType == TradeType.Buy)
            {
                bs = 1;
                PlaceStopOrder(TradeType.Sell, Symbol, volumeInUnits, pos.EntryPrice - (step * Symbol.PipSize), Label, null, null);
            }
 
            if (pos.TradeType == TradeType.Sell)
            {
                bs = 2;
                PlaceStopOrder(TradeType.Buy, Symbol, volumeInUnits, pos.EntryPrice + (step * Symbol.PipSize), Label, null, null);
            }
 
        }
 
        public void close()
        {
            n = 0;
            bs = 0;
            var Pos = Positions.FindAll(Label, Symbol);
 
            foreach (var pos in Pos)
            {
                ClosePosition(pos);
            }
 
            foreach (var order in PendingOrders)
            {
                CancelPendingOrder(order);
            }
 
        }
 
    }
    }

help please  

cAlgo not work 

cAlgo is sparrow 

if you can't help ,i can move platform to mql4 

open order sell 0.04 

position buy 0.01 loss 

fuck you


@tang_to_444@hotmail.com