Information
Username: | zumzum |
Member since: | 24 Nov 2014 |
Last login: | 24 Nov 2014 |
Status: | Active |
Activity
Where | Created | Comments |
---|---|---|
Algorithms | 0 | 4 |
Forum Topics | 6 | 13 |
Jobs | 0 | 1 |
Last Algorithm Comments
thanks for sharing.
Some Levels are wrong though.
thx for sharing.
Indicator is not working properly on tick charts.
Hi Joe,
thank you for sharing your code!
"How to get data further back than Jan?"
- I think that is the maximum that Spotware offers. I guess the way to get older tick data is by downloading it from some other places.
I would suggest to change these lines:
var sout = string.Join(",", sa);
to -> var sout = string.Join(";", sa);
and
private string csvhead = "datetime;ask;bid;spread;movavgX1X;volmin;volmax;pipsize;pipval\n";
-> , to ; and I deleted some spaces in this line
"," is a problem for people in countries where you use , as number seperator. Otherwise both the variables and numbers are separeted with the same symbol.
Kind regards
Last Jobs Comments
Hi,
depends on what you exactly need.
if you opend orders by bot or manually and you want to close all open positions it's easy to do.
If you opend orders manually and want to close a single (particular) order it's possible to close all orders of a currency but not a particular order, since it cannot be labeled (seems like cTrader offers labels only for orders executed by a bot and it seems impossible to add a label afterwards.
If you opend the order by bot and want to close a single (particular) it's easy since you can label that order.
I don't know if there is a workaround to close an order by ID, maybe some senior coders know that.
Anyway yesterday I had the same problem when AUD news beeing released in the middle of the night (living in europe), so I coded a small bot that fulfils my requirements.
Following code is untested you can use ist as sample, so modify it for you needs. If you got a question just ask.
//
//This is just some free sample code. Modify, test and use it (on a DEMO account) at your own risk. NO WARRENTY!
//
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 ClosingBot : Robot
{
[Parameter("Year", DefaultValue = 2014)]
public int year { get; set; }
[Parameter("Hour", DefaultValue = 1, MinValue = 1, MaxValue = 31)]
public int hour { get; set; }
[Parameter("Month", DefaultValue = 12, MinValue = 1, MaxValue = 12)]
public int month { get; set; }
[Parameter("Minute", DefaultValue = 0, MinValue = 0, MaxValue = 59)]
public int minute { get; set; }
[Parameter("Day", DefaultValue = 1, MinValue = 1, MaxValue = 31)]
public int day { get; set; }
[Parameter("Second", DefaultValue = 0, MinValue = 0, MaxValue = 59)]
public int second { get; set; }
[Parameter("Close ALL?", DefaultValue = 1, MinValue = 0, MaxValue = 1)]
public bool closeAll { get; set; }
[Parameter("Close EURCAD?", DefaultValue = 0, MinValue = 0, MaxValue = 1)]
public bool closeEurCad { get; set; }
[Parameter("Close NZDUSD?", DefaultValue = 0, MinValue = 0, MaxValue = 1)]
public bool closeNzdUsd { get; set; }
protected override void OnStart()
{
// Put your initialization logic here
}
protected override void OnTick()
{
DateTime date1 = Server.Time;
DateTime date2 = new DateTime(year, month, day, hour, minute, second);
int result = DateTime.Compare(date1, date2);
if (result > 0)
{
if (closeAll == false)
{
if (closeEurCad == true)
{
Symbol EURCAD = MarketData.GetSymbol("EURCAD");
var positionEURCAD = Positions.FindAll("", EURCAD);
foreach (var position in positionEURCAD)
ClosePosition(position);
Print("What Year Is It? ", date2);
Print("Am I rich yet? You just made: ", LastResult.Position.NetProfit);
}
if (closeNzdUsd == true)
{
Symbol NZDUSD = MarketData.GetSymbol("NZDUSD");
var positionNZDUSD = Positions.FindAll("", NZDUSD);
foreach (var position in positionNZDUSD)
ClosePosition(position);
Print("Am I rich yet?", LastResult.Position.NetProfit);
Print("Am I rich yet? You just made: ", LastResult.Position.NetProfit);
}
}
else
{
foreach (var position in Positions)
{
ClosePosition(position);
Print("What Year Is It? ", date2);
Print("Am I rich yet? You just made: ", LastResult.Position.NetProfit);
}
}
}
}
protected override void OnStop()
{
// Put your deinitialization logic here
}
}
}
//v0.0.1 aplha (untested) (2014-12-09):
//initial version
Hi Dirk,
thanks for sharing.
One idea, put the range_adr, range_adr_150 and range_adr_200 calculation into the Initialise function otherwise there is a lot of unnecessary calculation on each tick.
Cheers