Giter Club home page Giter Club logo

Comments (6)

ashbz avatar ashbz commented on August 27, 2024

What files are missing? What's the error you are getting?

from cryptosharp.

lucaszacutti avatar lucaszacutti commented on August 27, 2024

hi ashbz!, these files:
image
image
image
image
image
thanks!

from cryptosharp.

lucaszacutti avatar lucaszacutti commented on August 27, 2024

let me know if you need help and how I can contribute to the project!

from cryptosharp.

ashbz avatar ashbz commented on August 27, 2024

The project is not actively being developed anymore, but you are free to fork it!

I just made a new commit which adds the missing files.

Originally I used Github's own upload feature, which didn't work correctly, and I forgot to fix it.

Let me know if you got all the files now.

Thanks!

from cryptosharp.

lucaszacutti avatar lucaszacutti commented on August 27, 2024

the project now compiles correctly! Could you share some examples of strategies code to understand more quickly how the application works?
I setted my indicators but now I dont know the next step.. Should I call context.Buy() method to concrete a trade? or how is supposed to be done? and when I have a signal of sale, I must call CloseOrder?
thanks again!!

from cryptosharp.

ashbz avatar ashbz commented on August 27, 2024

You can try these out:

#1 - Simple Moving Averages:

using System.Linq;
using CryptoCore.Scripting;
using CryptoCore.Classes;


public class MyStrategy
{
    // how much to buy in USD
    float BUY_AMOUNT = 100f;
    
    // this event runs every time we have a new Candle (of the interval we have selected)
    public void OnData(Context context)
    {
        // indicator declaration
        var fastMA = Indicators.SimpleMovingAverage(14, context.CloseValues);
        var slowMA = Indicators.SimpleMovingAverage(60, context.CloseValues);

        // if any of the values are 0 in Moving Averages, we do not have indicator data yet
        if (fastMA.Last()== 0f || slowMA.Last()==0f) return;
        
        // buy when the fast moving average has a 4% difference with the slow moving average, and is underneath it
        // signals a sudden huge drop
        var shouldBuy  = fastMA.Last()<slowMA.Last() && (Helper.GetPercentage(fastMA.Last(),slowMA.Last())<96f);
        
        // sell when there is a 9% difference
        // which signals a sudden uptrend
        var shouldSell = fastMA.Last()>slowMA.Last() && (Helper.GetPercentage(slowMA.Last(),fastMA.Last())<91f);
        
        
        if (shouldBuy)
        {
            // buy and return a OrderInfo object
            var ord = context.Buy(BUY_AMOUNT);
        }

        if (shouldSell)
        {
            // for each open order, sell if there is profit
            foreach(var order in context.GetOpenOrders()){
                if (order.CurrentProfit()>0f){
                    context.CloseOrder(order);
                }
            }
        }

    }   

}

#2 - Bollinger Bands + RSI

using System.Linq;
using CryptoCore.Scripting;
using CryptoCore.Classes;


public class MyStrategy
{
    // how much to buy in USD
    float BUY_AMOUNT = 100f;
    
    // this event runs every time we have a new Candle (of the interval we have selected)
    public void OnData(Context context)
    {
        // get a BollingerBandsData object with a period of 31 and a standard deviation of 3.5
        var bb21 = Indicators.BollingerBands(31,3.5f,context.CloseValues);
        // get the RSI indicator values with a period of 18
        var rsi  = Indicators.RSI(18,context.CloseValues);
        
        // we do not have indicator data yet
        if (bb21==null || bb21.Upper.Last()== 0f) return;
        
        // buy when the lowest value of a candle is less than the Lower bollinger band line
        // AND when RSI shows it is oversold
        var shouldBuy = context.LastCandle.High < bb21.Lower.Last() && rsi.Last()<20;
        
        // sell when the lowest value of the same candle is above the Upper bollinger band line
        // AND when RSI shows it is overbought
        var shouldSell = context.LastCandle.Low > bb21.Upper.Last() && rsi.Last()>80;
        
        
        if (shouldBuy)
        {
            // buy and return a OrderInfo object
            var ord = context.Buy(BUY_AMOUNT);
        }

        if (shouldSell)
        {
            // for each open order, sell if there is profit of at least $2
            foreach(var order in context.GetOpenOrders()){
                if (order.CurrentProfit()>2f){
                    context.CloseOrder(order);
                }
            }
        }

    }   

}

All indicators

using System.Linq;
using CryptoCore.Scripting;
using CryptoCore.Classes;


public class MyStrategy
{
    public void OnData(Context context)
    {
        var bb  = Indicators.BollingerBands(31,3.5f,context.CloseValues);
        var rsi = Indicators.RSI(18,context.CloseValues);
        var sma = Indicators.SimpleMovingAverage(14,context.CloseValues);
        var ema = Indicators.ExponentialMovingAverage(14,context.CloseValues);
        var atr = Indicators.ATR(14,context.HighValues,context.LowValues,context.CloseValues);
        var wr  = Indicators.WilliamsR(14,context.HighValues,context.LowValues,context.CloseValues);
        var adx = Indicators.ADX(14,context.HighValues,context.LowValues,context.CloseValues);
        var sd  = Indicators.StandardDeviation(14,3.5f,context.CloseValues);
        var cci = Indicators.CCI(14,context.HighValues,context.LowValues,context.CloseValues);
        var ps  = Indicators.ParabolicSAR(context.HighValues,context.CloseValues);
    }   
}

from cryptosharp.

Related Issues (2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.