noob - how to refer indicator in my Robot

Created at 10 Jul 2013, 17:04
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!
ST

stoko

Joined 05.07.2013

noob - how to refer indicator in my Robot
10 Jul 2013, 17:04


Hi,

 

Where can I see an example of referncing to an indicator from a robot.

Would you mind putting a little example of using ZigZag in the Martingale sample?

 

Regards,

 

Stoyan


@stoko
Replies

gorin
16 Jul 2013, 12:10

Sample Martingale with zigzag

//#reference: ..\Indicators\ZigZag.algo  // 1. Add reference

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

namespace cAlgo.Robots
{
    [Robot]
    public class SampleMartingaleRobot : Robot
    {
        private ZigZag zigZag; // 2. declare
        
        [Parameter(DefaultValue = 12)]
        public int Depth { get; set; }

        [Parameter(DefaultValue = 5)]
        public int Deviation { get; set; }
        
        [Parameter(DefaultValue = 3)]
        public int BackStep { get; set; }
        
       // etc.
protected override void OnStart() { zigZag = Indicators.GetIndicator<ZigZag>(Depth, Deviation, BackStep); // 3. Initialize ExecuteOrder(InitialVolume, GetRandomTradeCommand()); } private void ExecuteOrder(int volume, TradeType tradeType) { Print(zigZag.Result.LastValue); // 4. Get value // etc. } // etc.




@gorin

... Deleted by UFO ...