Replies

ctid2434759
27 Sep 2023, 00:08 ( Updated at: 27 Sep 2023, 04:53 )

RE: Heikin Ashi bars on desktop

PanagiotisCharalampous said: 

Dear johnthielen,

Heikin Ashi charts will be included in the next major release of cTrader Desktop.

Best Regards,

Panagiotis 

Join us on Telegram and Facebook


Hi Panagiotis,

Do you know when the Heikin Ashi Chart will be coming to the next major release on desktop?


@ctid2434759

ctid2434759
03 Feb 2023, 09:20 ( Updated at: 03 Feb 2023, 09:31 )

RE:

Every single time I write the question on this forum that I've been stuck on for days, weeks or months I figure it out about an hour after I ask the question.

So if anyone ever want's the code. What I have written above works.

I'm very very happy.

I'de like to take the time to say thanks to.....ABSOLUTE NO BODY, the coding champ does whatever the f the coding champ wants.


@ctid2434759

ctid2434759
08 Jan 2023, 09:08 ( Updated at: 09 Jan 2023, 06:50 )

Calculating Position Size (volume) works in USDJPY but the same calculation does not work in EURUSD correctly

Fixed it. Don't know how to delete the questions.


@ctid2434759

ctid2434759
04 Jan 2023, 00:24 ( Updated at: 04 Jan 2023, 00:26 )

RE:

Thanks for your help Panagiotis.

I actually figured out how to utilise your suggestion of ExecuteMarketRangeOrder using it like it was a LMT order.

I'll paste the code bellow if anyone needs it.

Essentially you get a specific price on the chart bellow the current price 'X' pips. Save that value and draw a line if you want for visual reference.
Then keep checking current ASK price on tick and if that price goes bellow your 'Line' then it executes a MarketRangeOrder.

You can change the values to suit and change the CheckPositions call if you want to add more orders etc.

Thanks again.

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.SingaporeStandardTime, AccessRights = AccessRights.None)]
    public class ClosePositionOnTime : Robot
    
    
    // NOTE
    // For the live environment i need to change the _highprice = Bars.HighPrices.Maximum(2);
    // Change it to _highprice = Bars.LastBar.High;
    // It has to do with the way the close of the markets works.
    
    {

        // Just the current simulator pairs global variables.
        private double _highPrice;
        private double _lmtPrice;


        protected override void OnStart()
        {
            
             // Get the high Price of the last candle for this pair
            _highPrice = Bars.HighPrices.Maximum(2);
            // Then set the price 1 pip bellow that (so i can allow it to act like a LMT order)
            _lmtPrice = _highPrice - 1 * Symbol.PipSize;
            
            // Draw this LMT order or price line on the chart so i can see the entry point.
            var highLine = Chart.DrawHorizontalLine("Low", _lmtPrice, Color.Blue);
            highLine.IsInteractive = true;    

            
        }

  
       protected override void OnTick()
       {           
 
            // Get the current Price, which is the symbols previous ASK price.
            // Then inside the onTick method this keeps checking every tick if the ask price is bellow the entry price.
            var _previousAsk = Symbol.Ask;
            

            
            // Check if the current price is higher than the previous ticks ASK price
            if (_lmtPrice != 0 && _previousAsk < _lmtPrice)
            {
            
                //See if there are any Open positions
                var CheckPositions = Positions.Count;    
               
                
                
                    
                //var myLabelCount = Positions.Count(p => p.Label == "X");
                var currentSymbolOrderLabel = Positions.FindAll("X").Length;
                    
                //If "CheckPositions" Reports That less than 2 total positions are open and no existing current order with the label "X" is open, Then ExecuteMarketRangeOrder
                if (CheckPositions < 2 && currentSymbolOrderLabel < 1) {   
            
                    // Place a buy order
                    // At the current ask price because its bellow the trigger price with a range of 1 pip.
                    ExecuteMarketRangeOrder(TradeType.Buy, SymbolName, 1000, 1, Symbol.Ask, "X", null, 25);
                    //Print("High price: " + _highPrice);   
                    //Print("Current price: " + currentPrice);
                }
            
           }
           
               
                
       }
       


        protected override void OnStop()
        {
            // Handle cBot stop here
        }
    }
}

 


@ctid2434759

ctid2434759
03 Jan 2023, 02:53

RE:

Hi Ryanoia,

Did you figure out a way to do this? This is exactly what I'm stuck on.

Do not fill new order if the resulting margin level due to the opening of said positions results in a less than x% margin level, were x is a user defined parameter.


@ctid2434759

ctid2434759
03 Jan 2023, 01:27

RE: RE:

Hi Panagiotis,

 

I had a play with Market Range Orders, however they do not function in the desired way.

It seems to grab the current 'Ask' price and not fill a buy order any higher than 'x' pips to allow for slippage.
So current Ask of 0.68023 for AUDUSD with a range of 2 pips cannot fill higher than 0.68043.

I need to have LMT buy orders bellow the current price waiting to get filled.

There is a current mechanism in cTrader that stops more orders being filled when you go over the allowed account leverage.

So if I have 24 orders, 3 might fill then I will get a msg saying no more can fill due to insufficient funds (max leverage) which is great.
I need to utilise that mechanism but for amount of trades.

So same mechanism but just never fill more than 2 or 3 trades using LMT buy orders.
It's like I need an account/server level max open positions.


Any guidance would be greatly appreciated, I've written the rest of the bot but it's just this one thing that is a make or break that I can't solve.


Thanks

 


@ctid2434759

ctid2434759
03 Jan 2023, 00:22

RE:

Hi Panagiotis,

Thanks for that.

I wasn't aware of Market Range Orders I'll have a look into it.

Curiously do you know of a way to 'step in front' of the server so they never execute? 
Or is your solution of market range orders the only one you can think of?

I just need my account to never fill more than 'X' orders. 2, 4, 3 ect.
So if I have 24 LMT orders waiting, only fill 3 then stop filling anymore.

Thanks.
If I can't figure it out I might end up hiring your services.


@ctid2434759

ctid2434759
27 Dec 2022, 05:28 ( Updated at: 02 Jan 2023, 04:33 )

Ignore

Ignore this, not sure how to delete the above post.


@ctid2434759

ctid2434759
08 Aug 2022, 05:18 ( Updated at: 08 Aug 2022, 05:19 )

RE:

Hi Panagiotis,

I am facing the same problems.


I have a cBot that I've run in cTrader 4.1 and it executes in 3 seconds.

I run the exact same cBot in 4.2.18 and it takes 1minute and 6 seconds.

 

The new updates have made cTrader extremely slow. It's a shame that these updates are a forced download as I never would have upgraded until the stability and speed issues were fixed.

 


@ctid2434759

ctid2434759
08 Aug 2022, 05:14

RE:

I have the same issue.

cTrader 4.2.18 is much slower than 4.1


I have two accounts to test on. The account that runs on 4.1 executes my cBot in 3 seconds.

The account that runs off 4.2.18 runs the same cBot in 1minute and 6seconds.

The update also broke a bunch of cBots.

Please advise on a fix timeframe?

 


@ctid2434759

ctid2434759
03 Aug 2022, 02:16 ( Updated at: 03 Aug 2022, 08:42 )

RE: RE:How would I do this for the updated code base in 2022?

I want to get the last 1 minute bars high print from a differant symbol and place the order based off of that last bars high price.


This is what I currently have but unfortunately it gets the last bars highest price of the open instance and not the other symbols it's referencing when placing the orders.

       public Symbol[] MySymbols;

        protected override void OnStart()
        {

            MySymbols = Symbols.GetSymbols("EURUSD", "GBPUSD");
        
            foreach (var symbolName in MySymbols)
            {
                PlaceLimitOrder(TradeType.Buy, symbolName, 1000, Bars.HighPrices[Bars.Count -2]-6*symbolName.PipSize,"myLimitOrder", null, 18);
            }

        }

Updated. This works.

            var mySymbol = Symbols.GetSymbol("SYMBOLNAME");
            var mySymbolSeries = MarketData.GetBars(TimeFrame.Minute, "SYMBOLNAME");
            var mySymbolPrice = mySymbolSeries.LastBar.High;
            
            PlaceLimitOrder(TradeType.Buy, mySymbol, 10000, mySymbolPrice-7*mySymbol.PipSize,"myLimitOrder", null, 18);


@ctid2434759

ctid2434759
02 Aug 2022, 11:16 ( Updated at: 02 Aug 2022, 11:24 )

RE:

Thanks!

So I actually want to do.

The last bars high minus a specific number of pips.

So I got your code to work
PlaceLimitOrder(TradeType.Buy, SymbolName, 2000, Bars.HighPrices.Last(1),"myLimitOrder");

Then added this to be the final value of 6 pips bellow.


PlaceLimitOrder(TradeType.Buy, SymbolName, 2000, Bars.HighPrices.Last(1)-6*Symbol.PipSize,"myLimitOrder");


Thanks so much for your help.
Now I'm onto the next step which I really want to figure that out myself but I'm sure I'll be in touch. ha

 


@ctid2434759

ctid2434759
02 Aug 2022, 10:37

RE:

Hi Panagiotis,

Thanks for the reply, i needed to change the target framework to .NET Framework 4.x and now it works.

When creating a new CBOT it was automatically .NET 6.0 which would not run for me.

 

 

 


@ctid2434759