how to get price from Fractal Chaos Bands

Created at 12 Feb 2021, 06:18
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
MA

marian.kosa

Joined 12.02.2021

how to get price from Fractal Chaos Bands
12 Feb 2021, 06:18


Hi,
I have only basic knowledge of programming from school (long time ago), but even that i got pretty close to what i want to program. 

One think i did not figured out is how to get low and high price from Fractal Chaos Bands. 
I am stuck at what i should write instead of "index" in  "_fractalChaosBands.High[index]" from example:

public override void Calculate(int index)
{            
    Print("Fractal Chaos Bands High = {0}", _fractalChaosBands.High[index]); 
}
 

I tried to replace it, define it somehow, but best result i got is to simply write 0 there, but i do not get what i want that way. 
Again i am not programmer so i have no idea what it is or how it works... I was looking at examples, other people works, etc.

Everything else works as expected after several hours of trial and error :)


I will be thankful for any help, direction in this matter. 
 

 


@marian.kosa
Replies

PanagiotisCharalampous
12 Feb 2021, 08:24

Hi marian.kosa,

Thanks for posting in our forum. It is not clear to me what is the problem. Why do you want to replace index? What are you trying to do?

Best Regards,

Panagiotis 

Join us on Telegram


@PanagiotisCharalampous

marian.kosa
12 Feb 2021, 10:14

RE:

I want to extract price from that indicator to use it later as stoploss.

I am trying to figure out what that index represent, because with it, i am getting several errors, depending how i adjust the code. 
For example "Error CS0115: 'cAlgo.bot.OnBar(int)': no suitable method found to override" or "Error CS0103: The name 'index' does not exist in the current context"

 

Current simplified code:

using System.Linq;
using cAlgo.API;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;

namespace cAlgo
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.FileSystem)]

    public class bot: Robot
    {
        [Parameter("Volume", DefaultValue = 10000)]
        public int volume { get; set; }

        [Parameter(DefaultValue = 15, MinValue = 1)]
        public int TakeProfit { get; set; }

        public FractalChaosBands _fractalChaosBands;

        protected override void OnBar()
        {
            _fractalChaosBands = Indicators.FractalChaosBands();

                double FL = _fractalChaosBands.Low[index];
                double FH = _fractalChaosBands.High[index];

                if (***)
                {
                    ExecuteMarketOrder(TradeType.Buy, SymbolName, volume, "BOT", FL, TakeProfit, "buy");
                }

                if (***)
                {
                    ExecuteMarketOrder(TradeType.Sell, SymbolName, volume, "BOT", FH, TakeProfit, "sell");
                }            
        }
    }
}

 


@marian.kosa

PanagiotisCharalampous
12 Feb 2021, 11:04

Hi marian.kosa,

The index represents the index of the current bar being calculated and as you can see it is passed as a parameter to the Calculate method. So you can use it only inside this method. It is a local variable. If you want to access the values of the indicator inside the cBot, you should consider using Last() method.

Best Regards,

Panagiotis 

Join us on Telegram


@PanagiotisCharalampous

marian.kosa
12 Feb 2021, 11:35

RE:

I was trying to Last(), but i probably wrote it wrong. 
Anyway i wrote it that way now "double FL = _fractalChaosBands.Low.Last(1);"

Aaand as i was writing my next question, i realized, that i was writing stoploss in price, not in pips....

Thanks, for your time, I should be able to continue from here.

PanagiotisCharalampous said:

Hi marian.kosa,

The index represents the index of the current bar being calculated and as you can see it is passed as a parameter to the Calculate method. So you can use it only inside this method. It is a local variable. If you want to access the values of the indicator inside the cBot, you should consider using Last() method.

Best Regards,

Panagiotis 

Join us on Telegram

 


@marian.kosa