Help

Created at 15 Feb 2020, 12:29
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!
DO

dordkash@gmail.com

Joined 30.09.2017

Help
15 Feb 2020, 12:29


Hello friends
Suppose I've written a program that puts up or down a particular hammer to buy or sell
Now I have a problem
If there are two special hammers in succession, I don't want the top or bottom of the second to be customized
How to write this?


@dordkash@gmail.com
Replies

dordkash@gmail.com
17 Feb 2020, 09:36

No one to help?
Is the text written meaningless?


@dordkash@gmail.com

PanagiotisCharalampous
17 Feb 2020, 09:56

Hi reza h,

Your question is very general for somebody to give you a specific answer. So I will try to give a general answer to a general question, in case it helps. Use a flag that will be raised when the first hammer is detected. When the flag has been raised, do not detect any hammers. Lower the flag whenever you think it should be lowered.

Best Regards,

Panagiotis 

Join us on Telegram

 


@PanagiotisCharalampous

dordkash@gmail.com
18 Feb 2020, 10:34

RE:

PanagiotisCharalampous said:

Hi reza h,

Your question is very general for somebody to give you a specific answer. So I will try to give a general answer to a general question, in case it helps. Use a flag that will be raised when the first hammer is detected. When the flag has been raised, do not detect any hammers. Lower the flag whenever you think it should be lowered.

Best Regards,

Panagiotis 

Join us on Telegram

 

Thankful
Can you tell me a c-bot that used the flag?
This is a great help
If you need to put the c-bot code here
I've been having this problem for a while and I can't solve it


@dordkash@gmail.com

PanagiotisCharalampous
18 Feb 2020, 10:51

Hi reza h,

Here is a general example on how to raise/lower a flag based on conditions

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
    {

        bool _hammerDetected;
        protected override void OnStart()
        {
            // Put your initialization logic here
        }

        protected override void OnBar()
        {
            if (LowerFlag())
            {
                _hammerDetected = false;
            }

            if (!_hammerDetected && HammerDetected())
            {
                _hammerDetected = true;
            }
        }

        private bool LowerFlag()
        {
            // put here the conditions to lower your flag
            return true;
        }

        private bool HammerDetected()
        {
            // detect your hammer
            return true;
        }

        protected override void OnStop()
        {
            // Put your deinitialization logic here
        }
    }
}

 

Best Regards,

Panagiotis 

Join us on Telegram

 


@PanagiotisCharalampous

dordkash@gmail.com
19 Feb 2020, 13:38

RE:

PanagiotisCharalampous said:

Hi reza h,

Here is a general example on how to raise/lower a flag based on conditions

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
    {

        bool _hammerDetected;
        protected override void OnStart()
        {
            // Put your initialization logic here
        }

        protected override void OnBar()
        {
            if (LowerFlag())
            {
                _hammerDetected = false;
            }

            if (!_hammerDetected && HammerDetected())
            {
                _hammerDetected = true;
            }
        }

        private bool LowerFlag()
        {
            // put here the conditions to lower your flag
            return true;
        }

        private bool HammerDetected()
        {
            // detect your hammer
            return true;
        }

        protected override void OnStop()
        {
            // Put your deinitialization logic here
        }
    }
}

 

Best Regards,

Panagiotis 

Join us on Telegram

 

Thank you
I'm trying to figure out how to make it


@dordkash@gmail.com