
Topics
Replies
PanagiotisChar
25 Oct 2023, 06:11
( Updated at: 25 Oct 2023, 06:13 )
RE: RE: Only trade within certain hours
sarvann24 said:
PanagiotisCharalampous said:
Hi Liquidity,
Here you go
// -------------------------------------------------------------------------------------------------//// This code is a cAlgo API sample.//// This cBot is intended to be used as a sample and does not guarantee any particular outcome or// profit of any kind. Use it at your own risk.//// The "Sample RSI cBot" will create a buy order when the Relative Strength Index indicator crosses the level 30, // and a Sell order when the RSI indicator crosses the level 70. The order is closed be either a Stop Loss, defined in // the "Stop Loss" parameter, or by the opposite RSI crossing signal (buy orders close when RSI crosses the 70 level // and sell orders are closed when RSI crosses the 30 level). //// The cBot can generate only one Buy or Sell order at any given time.//// -------------------------------------------------------------------------------------------------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 SampleRSIcBot : Robot { [Parameter("Source")] public DataSeries Source { get; set; } [Parameter("Periods", DefaultValue = 14)] public int Periods { get; set; } [Parameter("Quantity (Lots)", DefaultValue = 1, MinValue = 0.01, Step = 0.01)] public double Quantity { get; set; } [Parameter("From", DefaultValue = 7)] public int From { get; set; } [Parameter("To", DefaultValue = 10)] public int To { get; set; } private RelativeStrengthIndex rsi; protected override void OnStart() { rsi = Indicators.RelativeStrengthIndex(Source, Periods); } protected override void OnTick() { if (Server.Time.Hour >= From && Server.Time.Hour < To) { if (rsi.Result.LastValue < 30) { Close(TradeType.Sell); Open(TradeType.Buy); } else if (rsi.Result.LastValue > 70) { Close(TradeType.Buy); Open(TradeType.Sell); } } } private void Close(TradeType tradeType) { foreach (var position in Positions.FindAll("SampleRSI", Symbol, tradeType)) ClosePosition(position); } private void Open(TradeType tradeType) { var position = Positions.Find("SampleRSI", Symbol, tradeType); var volumeInUnits = Symbol.QuantityToVolume(Quantity); if (position == null) ExecuteMarketOrder(tradeType, Symbol, volumeInUnits, "SampleRSI"); } }}
Best Regards,
Panagiotis
Hi, can anybody help me how to close all the open position after “ X ” hour
Hi there,
You can write something like this
if(Server.Time.TimeOfDay > TimeSpan.ParseExact("21:00", "hh\\:mm", null))
{
foreach (var position in Positions)
{
position.Close();
}
}
@PanagiotisChar
PanagiotisChar
25 Oct 2023, 06:05
( Updated at: 25 Oct 2023, 06:13 )
Hi there,
You can post suggestions here.
You can also use cTrader CLI to interact externally with cBots.
@PanagiotisChar
PanagiotisChar
25 Oct 2023, 06:01
Hi there,
I didn't say anything as your problem is still not clear to me. I would be able to advise you only if I am able to easily reproduce the issue.
@PanagiotisChar
PanagiotisChar
24 Oct 2023, 07:11
Hi there,
Check this video explaining all the trading operations in cTrader Automate
@PanagiotisChar
PanagiotisChar
24 Oct 2023, 06:58
Hi,
Nope, that is not possible with a hedging account. Only with a netting account you can achieve this
@PanagiotisChar
PanagiotisChar
24 Oct 2023, 06:57
Hi there,
You should post your issue in the correct section of the forum and share some more information e.g. screenshots so that the rest can understand what are you looking at
@PanagiotisChar
PanagiotisChar
24 Oct 2023, 06:56
( Updated at: 21 Dec 2023, 09:23 )
That's not where you need to right click. You need to right click here

@PanagiotisChar
PanagiotisChar
23 Oct 2023, 06:43
Hi Walter,
As per your screenshot, the optimization has not finished yet.
@PanagiotisChar
PanagiotisChar
23 Oct 2023, 05:57
( Updated at: 21 Dec 2023, 09:23 )
Hi,
Just right click on the header of the grid and choose which columns you need to be displayed

@PanagiotisChar
PanagiotisChar
23 Oct 2023, 05:53
Hi,
No it cannot. Only cBots can execute trading operations
@PanagiotisChar
PanagiotisChar
22 Oct 2023, 06:36
Hi there,
The image is not displayed so it is hard to understand what exactly you are talking about
@PanagiotisChar
PanagiotisChar
22 Oct 2023, 06:34
Hi there,
It is better to share a specific example that somebody can easily reproduce. Share the full cBot code, the broker and symbol you are running this code on.
@PanagiotisChar
PanagiotisChar
21 Oct 2023, 07:12
Hi there,
I don't see anything wrong. The code reads the value of the last closed bar, not the current bar. If you are looking for the current bar use Last(0)
@PanagiotisChar
PanagiotisChar
21 Oct 2023, 07:09
I understand now. It's not possible to disable it but it disappears instanly for me. Maybe a faster computer would benefit your usability and experience
@PanagiotisChar
PanagiotisChar
20 Oct 2023, 05:33
( Updated at: 20 Oct 2023, 05:35 )
Hi there,
If you help us reproduce this, we might be able to spot the issue for you
@PanagiotisChar
PanagiotisChar
20 Oct 2023, 05:32
( Updated at: 20 Oct 2023, 05:35 )
Hi there,
Find some reasons causing this below
https://help.ctrader.com/ctrader-copy/faq/#my-copy-trading-account-history-is-missing-trades-that-have-been-executed-by-the-strategy-provider-why-is-this-happening
@PanagiotisChar
PanagiotisChar
20 Oct 2023, 05:27
( Updated at: 20 Oct 2023, 05:35 )
Hi there,
Each broker has his own formula. You can contact your broker for an explanation
@PanagiotisChar
PanagiotisChar
20 Oct 2023, 05:26
( Updated at: 20 Oct 2023, 05:35 )
Hi Phider,
It works as you have described it. If you would like to suggest a change, you can do it in the Suggestions section
@PanagiotisChar
PanagiotisChar
20 Oct 2023, 05:25
Hi there,
Then maybe if you share some screenshots, we will communicate a bit better :)
@PanagiotisChar
PanagiotisChar
25 Oct 2023, 06:12 ( Updated at: 25 Oct 2023, 06:13 )
Hi there,
You should contact your broker instead. cTrader cannot help you with broker issues
@PanagiotisChar