Topics
Replies

firemyst
22 Mar 2024, 01:06 ( Updated at: 22 Mar 2024, 07:52 )

TO change the volume, use the ModifyVolume method;

To close a position entirely, use the Close method.


@firemyst

firemyst
21 Mar 2024, 08:26

In all honesty, I can't follow this. I'd rather see pictures. Do you have screen capture of the issue you can share?


@firemyst

firemyst
18 Mar 2024, 01:21 ( Updated at: 18 Mar 2024, 14:40 )

  1. it might be better if you make it an indicator and then use that custom indicator in your cbot
  2. if you're having trouble, what code have you created/started? Post it here and someone might be inclined to help you.

@firemyst

firemyst
18 Mar 2024, 01:20 ( Updated at: 18 Mar 2024, 14:40 )

I provided you an example in your other post:

https://ctrader.com/forum/cbot-support/42024

 


@firemyst

firemyst
18 Mar 2024, 01:18

I'll give you a few snippets. This is what I did and have notepad launching from cbots this way:


//you need to grant full access permissions
 [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]
        //These are for showing Notepad. Put them in top of your class file
        [DllImport("user32.dll", EntryPoint = "SetWindowText")]
        private static extern int SetWindowText(IntPtr hWnd, string text);
        [DllImport("user32.dll", EntryPoint = "FindWindowEx")]
        private static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
        [DllImport("User32.dll", EntryPoint = "SendMessage")]
        private static extern int SendMessage(IntPtr hWnd, int uMsg, int wParam, string lParam);
//to actually launch notepad from your code.
//don't put this in the ontick event or you'll crash your machine trying 
//to constantly launch notepad on every tick.
//the Process class is found in System.Diagnostics
Process notepad = Process.Start(new ProcessStartInfo("notepad.exe"));
if (notepad != null)
{
    notepad.WaitForInputIdle();

    if (!string.IsNullOrEmpty(title))
        SetWindowText(notepad.MainWindowHandle, title);

    if (!string.IsNullOrEmpty(message))
    {
        IntPtr child = FindWindowEx(notepad.MainWindowHandle, new IntPtr(0), "Edit", null);
        SendMessage(child, 0x000C, 0, message);
    }
}

@firemyst

firemyst
16 Mar 2024, 13:00

I don't think you can. I'm not sure how you can do that given that the angle of the line will change depending on the zoom-level of the chart, which I don't think you can detect.


@firemyst

firemyst
15 Mar 2024, 00:32 ( Updated at: 15 Mar 2024, 06:59 )

RE: RE:

caputojr said: 

PanagiotisCharalampous said:

Hi caputojr,

If you google it, you will find many.

Best Regards,

Panagiotis 

Join us on Telegram and Facebook

Hi Panagiotis,

Thank you for your prompt reply. In fact I did a google search but i could only find paid indicators and so I came here looking for some enlightment.

I hope I can find someone willing to help.

 

Thanks

 

You obviously need to improve your Google skills because when I googled it, 2 of the first 3 results are multitime frame moving averages that are free:

 

https://www.google.com/search?q=calgo+multi+timeframe+moving+average+indicator&sca_esv=990b066ce6362448&source=hp&ei=RJbzZbvsK4Xd4-EP6_690AI&iflsig=ANes7DEAAAAAZfOkVHYt9Rg7ZP2XuzCI4zHtGijfgOzc&oq=calgo+multi+timeframe+moving+average&gs_lp=Egdnd3Mtd2l6IiRjYWxnbyBtdWx0aSB0aW1lZnJhbWUgbW92aW5nIGF2ZXJhZ2UqAggBMgUQIRigATIFECEYoAFI-FNQAFjxSnAEeACQAQCYAbECoAHZRaoBCDAuNy4zMi4xuAEDyAEA-AEBmAIsoAK7RsICERAuGIAEGLEDGIMBGMcBGNEDwgIREC4YgwEYxwEYsQMY0QMYgATCAgsQABiABBixAxiDAcICEBAAGIAEGIoFGLEDGIMBGArCAgsQLhiABBixAxiDAcICCxAuGIAEGMcBGNEDwgIFEAAYgATCAhEQLhiABBiKBRixAxjHARjRA8ICCBAAGIAEGLEDwgIOEAAYgAQYigUYsQMYgwHCAg4QLhiABBixAxjHARjRA8ICCBAuGIAEGLEDwgIIEC4YsQMYgATCAg4QLhiABBixAxjHARivAcICCxAuGIAEGMcBGK8BwgINEC4YgAQYChixAxiDAcICDRAAGIAEGAoYsQMYgwHCAhAQABiABBiKBRgKGLEDGIMBwgIHEC4YgAQYCsICBxAAGIAEGArCAg0QLhiABBgKGMcBGK8BwgIIEAAYFhgeGArCAgcQABiABBgNwgIGEAAYHhgNwgIHECEYChigAcICBBAhGBWYAwCSBwg0LjUuMzQuMaAH6LwB&sclient=gws-wiz#ip=1

 

 


@firemyst

firemyst
13 Mar 2024, 00:20

RE: RE: Trailing SL distance

polepole said: 

Thank you for your reply, it is almost clear now. Although it is strange that you do not have a parameter where you can specify the trailing distance when you activate the trailing SL.

Let me see if I understood corectly:

  1. I have a BUY opened at price P
  2. Price has risen at P+60pips and now I set a SL at P+15pips

Question 3: If I enable trialing SL, the SL will now trail at 45 pips below current price? Alternatively, if I enable trailing SL and there is no SL, it will trail at 60 pips?

Then:

  1. Price has now reached P+100 and SL is at P+55 (because it's trailing 45 pips)
  2. I move the SL to P+30pips

Question 4: Will this change the trailing distance to 70 pips?

Question 5: If I move the SL at P+70pips, will this change the trailing distance to 30 pips?
 

Thank you!

 

Some times the best way to learn is to try it yourself and see what happens… self discovery is a wonderful thing :-)

 3: If I enable trialing SL, the SL will now trail at 45 pips below current price? Alternatively, if I enable trailing SL and there is no SL, it will trail at 60 pips?

If you meant you set the SL at P+15 when price reached P+60, then yes, the SL should remain approximately 45 pips behind. I say “approximately” because cTrader doesn't move the SL with every tick (from what I understand) to keep server loads low.

 

Questions 4 & 5 - try it yourself manually. Place an order in a demo account. Wait for your order to get x-pips in profit. THen manually move your SL forward and/or backwards and watch what happens. Then you'll see it in action and learn so much more than by me answering your questions. 

 


@firemyst

firemyst
13 Mar 2024, 00:10

I may be wrong, but when you run the indicator from inside the bot, it's using what you have specified as the bot's time zone:

 

TimeZone = TimeZones.UTC

@firemyst

firemyst
10 Mar 2024, 03:12 ( Updated at: 10 Mar 2024, 05:44 )

"However, the problem is that when I tried copying the code to use, it resulted in errors, and there are no examples for me to follow."

Have you even tried Google?

A simple search on “c# websocketclient example” brings back a list of websites, and the first one (medium.com) has a complete example including how to add it to your project using the NuGet package manager.

https://www.google.com/search?q=c%23+websocketclient+example&sca_esv=8b94fdf9c54254b4&source=hp&ei=PyTtZbCOE6TP7_UPoLuc4Ag&iflsig=ANes7DEAAAAAZe0yT3nG5JowWnfbTh6aAtNPKXoeGw1O&oq=c%23+webSocketClient&gs_lp=Egdnd3Mtd2l6IhJjIyB3ZWJTb2NrZXRDbGllbnQqAggBMgUQABiABDIGEAAYFhgeMgsQABiABBiKBRiGAzILEAAYgAQYigUYhgMyCxAAGIAEGIoFGIYDSP1CUABYgR5wAHgAkAEAmAH3AaABqByqAQYwLjExLje4AQPIAQD4AQGYAhKgAtYcwgIOEC4YgAQYsQMYxwEY0QPCAggQABiABBixA8ICCxAAGIAEGLEDGIMBwgILEC4YgAQYsQMYgwHCAggQABgWGB4YCpgDAJIHBTAuOS45oAeOUA&sclient=gws-wiz

 


@firemyst

firemyst
10 Mar 2024, 03:03

Why don't you post the code you have if you expect any help without having to pay someone?

 


@firemyst

firemyst
10 Mar 2024, 03:01

How come you don't print the values for :

  1. CurrentTime
  2. ParseTime(Time1).AddMinutes(-TimeDurationMinutes)
  3. ParseTime(Time1).AddMinutes(TimeDurationMinutes)
  4. and all the values for Time2-7

You don't know what those actual values are. You may think you know what they are, but you should print them out in your log so you know what they actually are.

For instance, you're getting the server time. Do you know what time zone the cTrader server is in? ANd then you're adding hours to that. Have you confirmed through print statements what the actual server time is that you're code is looking at?

If so, prove it :-)

Put it in the output logs.

Also, your “TimeDurationMinutes” is by default set to 5; yet you only want plus/minus 2 minutes. How do we know what value you have the parameter set at when you run your bot?

Again, print this to log.

 


@firemyst

firemyst
10 Mar 2024, 02:49

Question 1: the SL should trail at the distance it is the moment the ModifyTrailingStop is executed on the server. Note that because of rapid market movements this could change between when the bot executes the command to when the server actually receives and implements it. 

 

Question 2: you position.ModifyTrailingStop(false) and i) either way for the price to move to the distance you want, or ii) move the SL yourself to the desired distance. Then you can re-enable the trailing stop.

Or another way is while trailing stop is true, you move the trailing stop either forward/backward to the distance you want by doing position.ModifyStopLossPrice or position.ModifyStopLossPips

 


@firemyst

firemyst
08 Mar 2024, 01:58

Try creating a new copy of the bot in cTrader Automate.

Paste the code in cTrader automate.

Once it's in there, then click to open Visual Studio, compile it, and try running the bot.


@firemyst

firemyst
08 Mar 2024, 01:50

RE: Smaller stop loss than expected

PanagiotisCharalampous said: 

Hi there,

SL and TP should be set in pips. You seem to pass absolute prices instead.

Best regards,

Panagiotis

Where does he set the SL as a price instead of pips? 

The variable “SL” is set as a parameter and when he opens a position, that's what he passes:

ExecuteMarketOrder(TradeType.Buy, Symbol, InitialVolume, "Frann", SL, TP);

“SL” isn't changed in the code he's provided.

Also, the “TP” is never set in the code he posted either.

 


@firemyst

firemyst
08 Mar 2024, 01:49

RE: Smaller stop loss than expected

PanagiotisCharalampous said: 

Hi there,

SL and TP should be set in pips. You seem to pass absolute prices instead.

Best regards,

Panagiotis

Where does he set the SL as a price instead of pips? 

The variable “SL” is set as a parameter and when he opens a position, that's what he passes:

ExecuteMarketOrder(TradeType.Buy, Symbol, InitialVolume, "Frann", SL, TP);

“SL” isn't changed in the code he's provided.

Also, the “TP” is never set in the code posted either.

 


@firemyst

firemyst
08 Mar 2024, 01:45

RE: RE: C bot problem

flappiyt said: 

PanagiotisCharalampous said: 

Hi there,

Please provide more information about your problem. What do you mean when you say “I noticed that it's opening positions, but I can't see them”?

Best regards,

Panagiotis

Hi Panagiotis

I can hear positions being opened, and I can see it in the top right corner. However, I noticed in the trading history that positions are being opened for approximately 0.001 seconds and are immediately closed.

Then you're probably opening the position with either the SL or TP within the security's spread.


@firemyst

firemyst
07 Mar 2024, 07:22 ( Updated at: 07 Mar 2024, 07:29 )

RE: RE: cTrader "pip scale" constantly goes flukey, and nowhere near being correct

PanagiotisCharalampous said: 

firemyst said: 

Hello Team @Spotware / @PanagiotisCharalampous

Any further updates on a fix for this issue?

Thank you

Hi firemyst,

We had no luck reproducing this issue therefore we cannot fix it at the moment.

Best regards,

Panagiotis

It's still happening - affecting the pip spread by a factor of 10. IN this screen capture, I've used the “crosshair” tool to measure the same distance from top → bottom of the chart's scale. You can see the scale says 100 pips while the crosshair says 10 pips.

 

What I'm doing now is uninstalling Spotware's cTrader Desktop 4.8.30, deleting the folders “Spotware” and “Spotware_Systems_Ltd” from appdata\local folders, and will try another install to see if that corrects the issue.


@firemyst

firemyst
06 Mar 2024, 09:58 ( Updated at: 06 Mar 2024, 14:00 )

Of course it's doing that. That's exactly what you told it to do.

Look at your logic. For starters:

 if (bodySize < 10 * Symbol.PipSize)
                    {   //Why are you setting the SL from the close price here
                        stopLoss = close - SL * Symbol.PipSize;
                    }
                    else
                    {   //and setting the SL from the open price here?
                        stopLoss = open - SL * Symbol.PipSize;
                    }
 //if the overall bar is "bullish", don't you want them both calculated from the open price?

@firemyst

firemyst
06 Mar 2024, 09:54 ( Updated at: 06 Mar 2024, 14:00 )

Duplicate. See this thread:

 

https://ctrader.com/forum/indicator-support/43045

 

 


@firemyst