Replies

harry
08 Apr 2017, 04:21 ( Updated at: 21 Dec 2023, 09:20 )

RE: RE: can explain more?

and how is the calculation for placing the pending orders? limit order? any trading session or time when to place? and the distance between orders? more details and examples is better

thanks

zarathustra said:

harry said:

hi zarathustra , please give real examples of what you would want the bot does

Hi Harry! I have a grid system. I dont want to enter the orders separately. A bot must do it for me . An example of pending orders.... 0.01 then 0.03 and then 0.05.

 


@harry

harry
07 Apr 2017, 10:38

can explain more?
hi zarathustra , please give real examples of what you would want the bot does
@harry

harry
01 Oct 2016, 12:40

Hohoho, yeah, need to set the totalprofit to 0 first, took me like 2 hours to figure out, I know it is possible but hadn't thought to resetting the totalprofit to 0 first....

Thanks lucian!


@harry

harry
01 Oct 2016, 12:05

RE: RE:

My rusty brain can't think on how to not compounding the totalprofit from previous totalprofit calculation, so only 1 of each id gets calculated once inside the totalprofit.

Everytime Totalprofit is called, it will recalculate the Totalprofit from the current History data and add to the previously calculated totalprofit.

So I hold the previously calculated totalprofit into a variable to hold it, so clearly it becomes 0;

How to do so it calculates 1 of each ids and not compounding to the previous totalprofit?

Thanks

 

foreach (HistoricalTrade trade in History)
            {
                if (( trade.Label="MyLabel" && trade.SymbolCode == Symbol.Code) && (trade.ClosingTime.Date.Day == Server.Time.Date.Day) && (trade.ClosingTime.Date.Month == Server.Time.Date.Month))
                {
                    totalprofit += trade.NetProfit;
                    previousprofit = totalprofit;
                    currentprofit = totalprofit - previousprofit;

                }
            }

 

harry said:

 

thanks! will try it

lucian said:

 foreach (HistoricalTrade trade in History)
            {
                if (( trade.Label="MyLabel" && trade.SymbolCode == Symbol.Code) && (trade.ClosingTime.Date.Day == Server.Time.Date.Day) && (trade.ClosingTime.Date.Month == Server.Time.Date.Month))
                {
                    totalprofit += trade.NetProfit;
                }
            }

if necessary check : 

trade.ClosingTime.Date.Year == Server.Time.Date.Year)

 

 


@harry

harry
30 Sep 2016, 03:01

RE:

 

much appreciated L!

lucian said:

Try this:

 

 

   var pos = Positions.FindAll("SampleRSI", Symbol, TradeType.Buy);
            foreach (var position in pos)
            {
                if (position.EntryTime < DateTime.Now.AddSeconds(-300))
                {
                    Open(TradeType.Buy);
                }
            }
            if (pos.Length == 0)
                Open(TradeType.Buy);

 

 


@harry

harry
30 Sep 2016, 03:00

RE: RE: RE:

Thanks rmssf, now i know why it never open any position

rmssf said:

With no open positions your cbot never reaches that part of the code.

"foreach" really has the literal meaning "for each of open positions", so without open positions, the code inside is skipped.

 

harry said:

lucian said:

Use  Server.Time.AddSeconds(-300) or  Time.AddSeconds(-300)

DateTime.Now is the  Windows Time.

cBot works on  Robot(TimeZone = TimeZones.UTC)

 

Thanks L!

Am still confused why hasn't it opened any position despite I put OR position == null.

Well am running it again and see if it would open any position, am moving the position == null in front of the Time now.

   if (position == null || position.EntryTime < Time.AddSeconds(-300))

 

 

 


@harry

harry
29 Sep 2016, 19:40

RE:

lucian said:

Use  Server.Time.AddSeconds(-300) or  Time.AddSeconds(-300)

DateTime.Now is the  Windows Time.

cBot works on  Robot(TimeZone = TimeZones.UTC)

 

Thanks L!

Am still confused why hasn't it opened any position despite I put OR position == null.

Well am running it again and see if it would open any position, am moving the position == null in front of the Time now.

   if (position == null || position.EntryTime < Time.AddSeconds(-300))

 


@harry

harry
27 Sep 2016, 15:24

indicators using cAlgo

 

Hi Matt, am also new to cAlgo.

You can create indicators using cAlgo.

I have looked on some samples, you can just modify some samples using the data you want to output.

I took the code below from sample SMA cAlgo, just notice the Output below is to show the plot on the chart

Run an instance using the indicators on cAlgo to better understand what am saying

 

// -------------------------------------------------------------------------------------------------
//
//    This code is a cAlgo API example.
//    
//    All changes to this file will be lost on next application start.
//    If you are going to modify this file please make a copy using the "Duplicate" command.
//
// -------------------------------------------------------------------------------------------------

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

namespace cAlgo
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AutoRescale = false, AccessRights = AccessRights.None)]
    public class SampleSMA : Indicator
    {
        [Parameter("Source")]
        public DataSeries Source { get; set; }

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

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

        public override void Calculate(int index)
        {
            double sum = 0.0;

            for (int i = index - Periods + 1; i <= index; i++)
            {
                sum += Source[i];
            }
            Result[index] = sum / Periods;
        }
    }
}

 

 


@harry

harry
27 Sep 2016, 15:04

RE:

 

thanks! will try it

lucian said:

 foreach (HistoricalTrade trade in History)
            {
                if (( trade.Label="MyLabel" && trade.SymbolCode == Symbol.Code) && (trade.ClosingTime.Date.Day == Server.Time.Date.Day) && (trade.ClosingTime.Date.Month == Server.Time.Date.Month))
                {
                    totalprofit += trade.NetProfit;
                }
            }

if necessary check : 

trade.ClosingTime.Date.Year == Server.Time.Date.Year)

 


@harry

harry
27 Sep 2016, 10:29

RE:

thanks for the confirmation

 

lucian said:

Yes, you can use onBar() and onTick() at the same time.

 


@harry

harry
19 Sep 2016, 04:58

RE: RE:

Wondering how to assign the Timeframe to the RSI indicator. as the paramenters of RSI only (Source, period)

 

Thanks

 

moneybiz said:

Spotware said:

Dear Trader,

Please use the following code snippet:

[Parameter("RSI Indicator Time Frame", DefaultValue = "Minute15")]
public TimeFrame RelativeStrengthIndexIndicatorTimeFrame { get; set; }

 

Thank you, it works.

It would be nice to be able to set a default TimeFrame for the robot itself addition to the TimeZone and AccessRights parameters.

 


@harry

harry
01 Sep 2016, 03:37

RE: Close all Profitable Positions based on Pips Count

say we target 3 pips, we can

change the 

  if (position.GrossProfit > 0)

from provided sample code above into

  if (position.pips > 3)

cmiimw :)

 

susantasaren said:

Hi,

Can you provide a code so that the trade closes automatically when a certain value of Pip is reached.

i.e like an auto Take Profit applies based on Pips as soon as we go into a trade.

Best Regards.

 


@harry

harry
30 Aug 2016, 13:21

Congratulations!


Wishing all the best for the new website!


@harry