a new challenge
a new challenge
24 Sep 2020, 03:44
Hi Guys, (Hi Pani). I have a new challenge that can be useful for many traders in this community
I tried to put conditions to be filled in the one-day chart, in the one-hour chart.
The idea is, when the programmed conditions are met in the chart for one day and one hour at the same time,
the bot executes the trade.
. This seems to be the biggest challenge I have encountered so far
I tried using the following command lines, but was unsuccessful
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.ESouthAmericaStandardTime, AccessRights = AccessRights.None)] public class bot : Robot
public RelativeStrengthIndex _rsi;
public RelativeStrengthIndex _rsi2;
public RelativeStrengthIndex _rsiDay;
public RelativeStrengthIndex _rsiDay2;
protected override void OnStart() { // Put your initialization logic here MarketData.GetSeries(Symbol, TimeFrame.1day);
_rsiDay = Indicators.RelativeStrengthIndex(GetSeries.ClosePrices, 1);
_rsiDay2 = Indicators.RelativeStrengthIndex(GetSeries.ClosePrices, 5);
if (_rsiDay.Result.LastValue < 40)
if (_rsiDay2.Result.LastValue < 40)
if (_rsi.Result.LastValue < 40)
if (_rsi2.Result.LastValue < 49)
ExecuteMarketOrder(TradeType.Sell, Symbol, Volume, "bot", StopLoss, TakeProfit);
Replies
samuel.jus.cornelio
24 Sep 2020, 09:40
RE:
PanagiotisCharalampous said:
Hi sam,
There are a lot of mistakes in your code. What is the actual information you are missing?
Best Regards,
Panagiotis
Hi Pani, you are the best! And I'm sure you have the answer I looked for a series of examples of how to put a multitimeframe condition in my code, and I couldn't find any examples. Could you please. give me an example of how to put a daily condition on an hourly chart. Setting a practical example When an RSI on the daily chart is above 60% and another rsi on the hourly chart is over 60% the boat executes an order
Thanks bro, your help has motivated me a lot on this platform, and I'm sure you have been very helpful to the people of this community. Thank you very much
@samuel.jus.cornelio
PanagiotisCharalampous
24 Sep 2020, 10:27
Hi Sam,
Here you go
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 NewcBot : Robot
{
[Parameter(DefaultValue = 0.0)]
public double Parameter { get; set; }
RelativeStrengthIndex _rsiDaily;
RelativeStrengthIndex _rsiHourly;
protected override void OnStart()
{
var dailyBars = MarketData.GetBars(TimeFrame.Daily);
var hourlyBars = MarketData.GetBars(TimeFrame.Hour);
_rsiDaily = Indicators.RelativeStrengthIndex(dailyBars.ClosePrices, 14);
_rsiHourly = Indicators.RelativeStrengthIndex(hourlyBars.ClosePrices, 14);
}
protected override void OnBar()
{
if (_rsiDaily.Result.Last(1) > 60 && _rsiHourly.Result.Last(1) > 60)
{
ExecuteMarketOrder(TradeType.Buy, Symbol.Name, 1000);
}
}
protected override void OnStop()
{
// Put your deinitialization logic here
}
}
}
Best Regards,
Panagiotis
@PanagiotisCharalampous
maciel.rafael1
24 Sep 2020, 16:48
RE:
Hi Pani,
When I try this bot on back testing and I verify the information on trading view the value for the RSI is not the same
Could it be that the bot is selecting the wrong price ?
PanagiotisCharalampous said:
Hi Sam,
Here you go
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 NewcBot : Robot { [Parameter(DefaultValue = 0.0)] public double Parameter { get; set; } RelativeStrengthIndex _rsiDaily; RelativeStrengthIndex _rsiHourly; protected override void OnStart() { var dailyBars = MarketData.GetBars(TimeFrame.Daily); var hourlyBars = MarketData.GetBars(TimeFrame.Hour); _rsiDaily = Indicators.RelativeStrengthIndex(dailyBars.ClosePrices, 14); _rsiHourly = Indicators.RelativeStrengthIndex(hourlyBars.ClosePrices, 14); } protected override void OnBar() { if (_rsiDaily.Result.Last(1) > 60 && _rsiHourly.Result.Last(1) > 60) { ExecuteMarketOrder(TradeType.Buy, Symbol.Name, 1000); } } protected override void OnStop() { // Put your deinitialization logic here } } }
Best Regards,
Panagiotis
@maciel.rafael1
PanagiotisCharalampous
24 Sep 2020, 07:56
Hi sam,
There are a lot of mistakes in your code. What is the actual information you are missing?
Best Regards,
Panagiotis
Join us on Telegram
@PanagiotisCharalampous