Description
You must try different parameters up to take profit. The main idea of this robot is put a smaller take profit and a bigger stop lost, always betting on the rebound after each new bar.
Range market: hight profits
Trend market: Very high losses
Risk: hight
// -------------------------------------------------------------------------------------------------
//
// This code is a cAlgo API sample.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk
//
// The "Sample Martingale cBot" creates a random Sell or Buy order. If the Stop loss is hit, a new
// order of the same type (Buy / Sell) is created with double the Initial Volume amount. The cBot will
// continue to double the volume amount for all orders created until one of them hits the take Profit.
// After a Take Profit is hit, a new random Buy or Sell order is created with the Initial Volume amount.
//
// -------------------------------------------------------------------------------------------------
using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;
namespace cAlgo
{
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class RickyMoney : Robot
{
[Parameter("Initial Quantity (Lots)", DefaultValue = 1, MinValue = 0.01, Step = 0.01)]
public double InitialQuantity { get; set; }
[Parameter("SL", DefaultValue = 20)]
public int StopLoss { get; set; }
[Parameter("TP", DefaultValue = 20)]
public int TakeProfit { get; set; }
int newprofit;
private Random random = new Random();
bool ganada;
bool compra;
bool permiso;
protected override void OnStart()
{
Positions.Closed += OnPositionsClosed;
newprofit = TakeProfit;
ExecuteOrder(InitialQuantity, GetRandomTradeType(), StopLoss, TakeProfit);
}
private void ExecuteOrder(double quantity, TradeType tradeType, int stop, int take)
{
var volumeInUnits = Symbol.QuantityToVolume(quantity);
var result = ExecuteMarketOrder(tradeType, Symbol, volumeInUnits, "Robot", stop, take);
if (result.Error == ErrorCode.NoMoney)
Stop();
}
private void OnPositionsClosed(PositionClosedEventArgs args)
{
permiso = true;
Print("Closed");
var position = args.Position;
if (position.Label != "Robot" || position.SymbolCode != Symbol.Code)
return;
if (position.NetProfit > 0)
{
ganada = true;
if (position.TradeType == TradeType.Buy)
{
compra = true;
}
else
{
compra = false;
}
}
else
{
ganada = false;
if (position.TradeType == TradeType.Buy)
{
compra = true;
}
else
{
compra = false;
}
}
}
protected override void OnBar()
{
if (permiso)
{
permiso = false;
if (ganada)
{
newprofit = TakeProfit;
if (compra)
{
ExecuteOrder(InitialQuantity, TradeType.Sell, StopLoss, TakeProfit);
}
else
{
ExecuteOrder(InitialQuantity, TradeType.Buy, StopLoss, TakeProfit);
}
}
else
{
if (compra)
{
ExecuteOrder(InitialQuantity, TradeType.Buy, StopLoss / 1, newprofit);
}
else
{
ExecuteOrder(InitialQuantity, TradeType.Sell, StopLoss / 1, newprofit);
}
}
}
}
private TradeType GetRandomTradeType()
{
return random.Next(2) == 0 ? TradeType.Buy : TradeType.Sell;
}
}
}
ripupo88
Joined on 03.09.2017
- Distribution: Free
- Language: C#
- Trading platform: cTrader Automate
- File name: RickyMoney.algo
- Rating: 0
- Installs: 2459
- Modified: 13/10/2021 09:54
Warning! Running cBots downloaded from this section may lead to financial losses. Use them at your own risk.
Note that publishing copyrighted material is strictly prohibited. If you believe there is copyrighted material in this section, please use the Copyright Infringement Notification form to submit a claim.
Comments
Log in to add a comment.
VI
I delight in, result in I found exactly what I was having a look for. You have ended my four day long hunt! God Bless you man. Have a great day. ByeSprings repair
HA
There is noticeably a lot of money comprehend this. I assume you’ve made specific nice points in functions also. 비아마켓
One important thing is that when you’re searching for a student loan you may find that you’ll want a cosigner. There are many scenarios where this is correct because you could find that you do not have a past credit score so the loan provider will require that you’ve got someone cosign the credit for you. Good post.tamilrockers 2021 tamil movies download