stevehopwoodforex.com
https://www.stevehopwoodforex.com/phpBB3/
Print view

My diary notes and learning
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=2459
Page 1 of 1
Author:  babalu4u [ Thu Jun 06, 2013 9:34 pm ]
Post subject:  My diary notes and learning

If this will be useful to anyone I will be happy... :geek:

Ok....

This is on the start empty template robot (EA) document:

Code: Select all

// -------------------------------------------------------------------------------
//
//    This is a Template used as a guideline to build your own Robot. 
//    Please use the “Feedback” tab to provide us with your suggestions about cAlgo’s API.
//
// -------------------------------------------------------------------------------

using System;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Requests;
using cAlgo.Indicators;

namespace cAlgo.Robots
{
    [Robot]
    public class NewRobot : Robot
    {
        protected override void OnStart()
        {
            // Put your initialization logic here
        }

        protected override void OnBar()
        {
            // Put your core logic here
        }

        protected override void OnStop()
        {
            // Put your deinitialization logic here
        }
    }
}
Author:  SteveHopwood [ Thu Jun 06, 2013 9:41 pm ]
Post subject:  Re: My diary notes and learning

Please keep adding to this as you go - it is in the true spirit of our forum and will help others program for this platform.

Apart from, anything else, you always have a backup copy if you lose all your files in a disastrous event. :lol:

:D
Author:  babalu4u [ Thu Jun 06, 2013 9:46 pm ]
Post subject:  Re: My diary notes and learning

Disadvantage for now is that you can use only current chart time frame and currency in Robots (robots can't trade multycurrency).... but in near future will support this options....
Author:  babalu4u [ Thu Jun 06, 2013 9:51 pm ]
Post subject:  Re: My diary notes and learning

Yes my intention is to write all but I am not good writer and also my english :oops: this will look more like notes and one day somebody can use notes to write better cAlgo for Dummies ...
Author:  babalu4u [ Thu Jun 06, 2013 9:58 pm ]
Post subject:  Re: My diary notes and learning

Called on each incoming Bar. This method is used by Robots. Izzy..

Code: Select all

        protected override void OnBar()
        {
            // Put your core logic here
        }

Now I will look to others Robots to find useful things and to learn ...
Author:  babalu4u [ Thu Jun 06, 2013 10:08 pm ]
Post subject:  Re: My diary notes and learning

I find one useful money management function and i will tray to use or adopt to my robot...

Code: Select all

        /// <summary>
        /// Volume calculated based on Risk if winning trade otherwise doubled
        /// </summary>
        protected int Volume
        {
            get
            {
                if (profit < 0)
                    // Profit < 0 => Double previous Volume or use MaxVolume
                    return (volume * 2) > MaxVolume ? MaxVolume : volume * 2;

                // profit > 0 => Calculate Volume based on Risk and Pip value
                var risk = (int)(RiskPercent * Account.Balance / 100);
                var volumeOnRisk = (int)(risk * Symbol.Ask / (Symbol.PipSize * StopLoss));
                // round volume to nearest tradable value
                return volumeOnRisk / VolumeIncreament * VolumeIncreament;
            }
        }

        /// <summary>
        /// Max Allowed trade volume 
        /// </summary>
        protected int MaxVolume
        {
            get
            {
                // calculated based on equity and leverage 
                double maxVolume = Account.Equity * Leverage * 100 / 101;
                //round to the nearest tradable value                
                return (int)Math.Truncate(Math.Round(maxVolume) / VolumeIncreament) * VolumeIncreament;
            }
        }
Author:  Radar [ Sat Jun 08, 2013 6:26 am ]
Post subject:  Re: My diary notes and learning

Hey Babalu4u,


I'm not real sure here, but the first section looks like martingaling against a floating loss...

Code: Select all

                if (profit < 0)
                    // Profit < 0 => Double previous Volume or use MaxVolume
                    return (volume * 2) > MaxVolume ? MaxVolume : volume * 2;

Not a nice toy to play with. Might be better to get rid of that bit.

Have fun!

Radar =8^)
Author:  babalu4u [ Tue Jun 11, 2013 11:22 am ]
Post subject:  Re: My diary notes and learning

Radar wrote:Hey Babalu4u,


I'm not real sure here, but the first section looks like martingaling against a floating loss...

Code: Select all

                if (profit < 0)
                    // Profit < 0 => Double previous Volume or use MaxVolume
                    return (volume * 2) > MaxVolume ? MaxVolume : volume * 2;

Not a nice toy to play with. Might be better to get rid of that bit.

Have fun!

Radar =8^)
Hi Radar yes I know, this is only copy paste from one martingale sample robot. I will use only part of that code... ;)
All times are UTC Page 1 of 1