Skip to content

AwesomeOscillator

interface cAlgo.API.Indicators

DesktopCLICloud

Displays the market momentum as a histogram.

Definition

public interface AwesomeOscillator

Namespace: cAlgo.API.Indicators · Group: Indicators · Implements: StandardIndicator

Examples

Example 1

var awesomeOscillator = Indicators.AwesomeOscillator();
Print("Awesome Oscillator: {0}", awesomeOscillator.Result.LastValue);
awesomeOscillator = api.Indicators.AwesomeOscillator()
api.Print(f"Awesome Oscillator: {awesomeOscillator.Result.LastValue}")

Example 2

using cAlgo.API;
using cAlgo.API.Indicators;

namespace cAlgo.Robots
{
    // This sample cBot shows how to use an Awesome Oscillator indicator
    public partial class AwesomeOscillatorSample : Robot
    {
        private double _volumeInUnits;

        private AwesomeOscillator _awesomeOscillator;

        public Position[] BotPositions
        {
            get
            {
                return Positions.FindAll(Label);
            }
        }

        protected override void OnStart()
        {
            _volumeInUnits = Symbol.QuantityToVolumeInUnits(VolumeInLots);

            _awesomeOscillator = Indicators.AwesomeOscillator();
        }

        protected override void OnBar()
        {
            foreach (var position in BotPositions)
            {
                if ((position.TradeType == TradeType.Buy && _awesomeOscillator.Result.Last(1) < _awesomeOscillator.Result.Last(2))
                    || (position.TradeType == TradeType.Sell && _awesomeOscillator.Result.Last(1) > _awesomeOscillator.Result.Last(2)))
                {
                    ClosePosition(position);
                }
            }

            if (_awesomeOscillator.Result.Last(1) > 0 && _awesomeOscillator.Result.Last(2) <= 0)
            {
                ExecuteMarketOrder(TradeType.Buy, SymbolName, _volumeInUnits, Label, StopLossInPips, TakeProfitInPips);
            }
            else if (_awesomeOscillator.Result.Last(1) < 0 && _awesomeOscillator.Result.Last(2) >= 0)
            {
                ExecuteMarketOrder(TradeType.Sell, SymbolName, _volumeInUnits, Label, StopLossInPips, TakeProfitInPips);
            }
        }
    }
}
import clr

clr.AddReference("cAlgo.API")

# Import cAlgo API types
from cAlgo.API import *

# Import trading wrapper functions
from robot_wrapper import *

class AwesomeOscillatorSample():
    def on_start(self):
        self.volumeInUnits = api.Symbol.QuantityToVolumeInUnits(api.VolumeInLots)
        self.awesomeOscillator = api.Indicators.AwesomeOscillator()

    def on_bar_closed(self):
        for position in self.get_bot_positions():
            if (position.TradeType == TradeType.Buy and self.awesomeOscillator.Result.Last(0) < self.awesomeOscillator.Result.Last(1)) or (position.TradeType == TradeType.Sell and self.awesomeOscillator.Result.Last(0) > self.awesomeOscillator.Result.Last(1)):
                api.ClosePosition(position)

        if self.awesomeOscillator.Result.Last(0) > 0 and self.awesomeOscillator.Result.Last(1) <= 0:
            api.ExecuteMarketOrder(TradeType.Buy, api.SymbolName, self.volumeInUnits, api.Label, api.StopLossInPips, api.TakeProfitInPips)
        elif self.awesomeOscillator.Result.Last(0) < 0 and self.awesomeOscillator.Result.Last(1) >= 0:
            api.ExecuteMarketOrder(TradeType.Sell, api.SymbolName, self.volumeInUnits, api.Label, api.StopLossInPips, api.TakeProfitInPips)

    def get_bot_positions(self):
        return api.Positions.FindAll(api.Label)
{
  "AccessRights": "None",
  "TimeZone": "UTC",
  "Parameters": [
    {
      "Name": "VolumeInLots",
      "DisplayName": "Volume (Lots)",
      "Type": "Double",
      "DefaultValue": 0.01
    },
    {
      "Name": "StopLossInPips",
      "DisplayName": "Stop Loss (Pips)",
      "Type": "Double",
      "DefaultValue": 10
    },
    {
      "Name": "TakeProfitInPips",
      "DisplayName": "Take Profit (Pips)",
      "Type": "Double",
      "DefaultValue": 10
    },
    {
      "Name": "Label",
      "Type": "String",
      "DefaultValue": "Sample"
    }
  ]
}

Properties

Name Description
ResultDesktopCLICloudIndicatorDataSeries Gets the Awesome Oscillator calculation result.

Inherited members

From StandardIndicator: AddToChart, Symbol, TimeFrame, Bars