jwandia2022

Info
Username: | jwandia2022 |
Name: | jwandia2022 |
Member since: | 30 Sep 2022 |
About
Signature
Last Forum Posts
@Move Stop Loss for all open trades to a specific price: 04 Dec 2022, 00:16
Hi,
I am trying to come up with a logic that will move the stop loss for all open positions to a certain price once a specific condition is met.
Kindly assist.
Joyce.
@Scaling Into an existing trade: 03 Dec 2022, 23:51
Hi,
I am trying to come up with a logic that will scale into a bullish/bearish trade. The condition should be that:
- For a bullish trade, there should be no open buy positions within x pips above or below a given price
- For a bearish trade, there should be no open sell positions within x pips above or below a given price
Kindly assist.
Joyce.
@Unable to load DLL 'winhttp.dll' or one of its dependencies: 24 Nov 2022, 15:05
Hi,
I am trying to build this cbot from the indicator referenced below.
However, I keep getting the error [Crashed in Initialize with DllNotFoundException: Unable to load DLL 'winhttp.dll'] when I try to run an instance of this cbot. What could be the issue.
Kindly advise.
Joyce.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
namespace cAlgo.Robots
{
[Robot(AccessRights = AccessRights.None)]
public class Swing : Robot
{
private Swing xyz;
protected override void OnStart()
{
xyz = Indicators.GetIndicator<Swing>(Bars.ClosePrices, Bars.ClosePrices, 5);
}
protected override void OnBar()
{
var currentSwingHigh = xyz.SwingHighPlot.Last(0);
var currentSwingLow = xyz.SwingLowPlot.Last(0);
var Price = (Symbol.Ask + Symbol.Bid)/2;
if ((Price > currentSwingLow)||(Price > currentSwingHigh))
{
Close(TradeType.Sell, "test");
if (Positions.Count == 0)
ExecuteMarketOrder(TradeType.Buy, SymbolName, 1000, "Bullish", 50, 100);
}
if ((Price < currentSwingLow)||(Price < currentSwingHigh))
{
Close(TradeType.Buy, "test");
if (Positions.Count == 0)
ExecuteMarketOrder(TradeType.Sell, SymbolName, 1000, "Bearish", 50, 100);
}
}
private void Close(TradeType tradeType, string Label)
{
foreach (var position in Positions.FindAll(Label, SymbolName, tradeType))
ClosePosition(position);
}
}
}
@Unable to invoke target method in current thread. Use `BeginInvokeOnMainThread` method to prevent this error.: 22 Nov 2022, 18:56
Hi,
I have just completed my first bot build out but I keep getting the error [Unable to invoke target method in current thread. Use `BeginInvokeOnMainThread` method to prevent this error.]
Is there a way I can share the code privately and get assistance on this issue.
Thanks.
Joyce.
@How to build an indicator in a cbot with DataSeries: 11 Nov 2022, 13:30
Hi
Found a solution already from one of the forums. Thank you.
Joyce.
@How to build an indicator in a cbot with DataSeries: 09 Nov 2022, 09:24
Hi,
The two errors I'm getting while building out the indicator in the cbot are:
- Error CS0103: The name 'High' does not exist in the current context
- Error CS0103: The name 'Low' does not exist in the current context
Joyce
@How to build an indicator in a cbot with DataSeries: 08 Nov 2022, 20:02
Hi,
I'm just curious since I have tried building out an indicator in a cbot with the parameters below but errors keep on coming time and again. How can one call these indicator parameters to the cbot on the OnStart section? I have added my own version on the OnStart but this does not seem to work.
Joyce.
From Indicator
public class xyz : Indicator
[Parameter("High")]
public DataSeries High { get; set; }
[Parameter("Low")]
public DataSeries Low { get; set; }
[Parameter("Strength", DefaultValue = 5, MinValue = 1)]
public int strength { get; set; }
To Cbot
Indicator Declarations
private xyz ss;
On Start Indicator BuildOut
=======> ss = indicators.GetIndicator<xyz>(High,Low,5) <=====================
@Daily market Open Price Reference in cBot: 05 Oct 2022, 11:44
You forgot to declare the variable for the dailyBars. Above the OnStart() method you just need private Bars dailyBars;
using System; using System.Linq; using cAlgo.API; using cAlgo.API.Indicators; using cAlgo.API.Internals; using cAlgo.Indicators; namespace cAlgo.Robots { [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class New : Robot { [Parameter(DefaultValue = 0.0)] public double Parameter { get; set; } private Bars dailyBars; protected override void OnStart() { // Put your initialization logic here dailyBars = MarketData.GetBars("Daily"); } protected override void OnTick() { // Put your core logic here } protected override void OnBar() { // Put your core logic here if (Bars.Last(0).Close > dailyBars.Last(0).Close) { ///Execute Buy Trade } if (Bars.Last(0).Close < dailyBars.Last(0).Close) { ///Execute Sell Trade } } protected override void OnStop() { // Put your deinitialization logic here } } }
I'm still not able to get the sample code above to build on CTrader. Error messages:
Kindly assist.
Joyce.
@Daily market Open Price Reference in cBot: 05 Oct 2022, 10:16
Thanks. I had not noticed that beforehand.
@Daily market Open Price Reference in cBot: 03 Oct 2022, 14:02
jwandia2022 said:
ctid3999979 said:
jwandia2022 said:
Hi All,
Is there any way to write a logic that allows a cbot execute a buy/sell trade once the Daily Market Open Price is crossed?
Joyce.
If I'm understanding your query correctly, you could use the MarketData.GetBars() method to get the daily candles, then write some code such as
dailyBars = MarketData.GetBars("Daily"); protected override void OnBar() { if (Bars.Last(0).Close > dailyBars.Last(0).Close) { ExecuteMarketOrder() } }
Hi Again,
Which syntax should I use before "dailyBars = MarketData.GetBars("Daily")" to call the method?
Below is a sample of the code
using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;
namespace cAlgo.Robots
{
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class New : Robot
{
[Parameter(DefaultValue = 0.0)]
public double Parameter { get; set; }
protected override void OnStart()
{
// Put your initialization logic here
dailyBars = MarketData.GetBars("Daily");
}
protected override void OnTick()
{
// Put your core logic here
}
protected override void OnBar()
{
// Put your core logic here
if (Bars.Last(0).Close > dailyBars.Last(0).Close)
{
///Execute Buy Trade
}
if (Bars.Last(0).Close < dailyBars.Last(0).Close)
{
///Execute Sell Trade
}
}
protected override void OnStop()
{
// Put your deinitialization logic here
}
}
}