Topics
10 Aug 2023, 21:08
 281
 3
10 Aug 2023, 21:08
 316
 1
12 Oct 2020, 10:39
 1175
 2
04 Oct 2020, 21:56
 2484
 7
03 Oct 2020, 15:08
 1229
 4
03 Oct 2020, 14:59
 913
 1
30 Sep 2020, 16:30
 902
 2
30 Sep 2020, 16:20
 921
 3
25 Sep 2020, 11:03
 883
 2
24 Sep 2020, 20:14
 843
 2
16 Sep 2020, 10:25
 1948
 3
31 Aug 2020, 17:03
 1230
 4
29 Jul 2020, 13:59
 806
 2
27 Jul 2020, 21:41
 846
 2
27 Jul 2020, 17:03
 811
 2
Replies

luca.tocchi
11 Aug 2023, 06:02

RE: crash

firemyst said: 

why it crash?

Why don't you post the error message or a screen capture of the crash? 

Creashed in OnStart whit NullReferenceExeption: Object reference not set to an istance of an object

 

the program keeps going but doesn’t print anything


@luca.tocchi

luca.tocchi
08 Aug 2023, 06:16 ( Updated at: 08 Aug 2023, 06:23 )

RE: placelimitorder success

firemyst said: 

What do you mean by “activated”? DO you mean when the order is actually executed? If so, just check the trade result:

 

TradeResult r = PlaceStopOrder(TradeType.Buy, SymbolName,  volumeInUnits, Symbol.Bid + 15);

if (r.IsSuccessful) {

////

}

 

I mean when the pending order turns into position. 

 

                TradeResult r = PlaceStopOrder(TradeType.Buy, SymbolName, volumeInUnits, Symbol.Bid + 0.0003);
                
                if (r.IsSuccessful)
                {
                 Print("yes");
                }

 

in this case it print “yes” immediatly. But I want it to print “yes”, only when the order is executed. When the price line crosses the order line and the order filled

thanks


@luca.tocchi

luca.tocchi
05 Oct 2020, 18:33

RE:

PanagiotisCharalampous said:

Hi Luca,

Use ModifyTrailingStop.

Best Regards,

Panagiotis 

Join us on Telegram

yes, however, being in onTick () if I put longPosition.ModifyTrailingStop every time it will put the stop loss back to +30

 

if (longPosition.Pips >= 50)

ModifyPosition(longPosition, longPosition.EntryPrice + Symbol.PipSize * 30, longPosition.TakeProfit);

longPosition.ModifyTrailingStop(true);

so i don't think it works

 

 


@luca.tocchi

luca.tocchi
05 Oct 2020, 14:35

RE:

PanagiotisCharalampous said:

Hi Luca,

Here is the correct way to do this

                if (longPosition.Pips >= 50)
                    ModifyPosition(longPosition, longPosition.EntryPrice + Symbol.PipSize * 30, longPosition.TakeProfit);

Best Regards,

Panagiotis 

Join us on Telegram

if once the stop loss is at +30, I want it to become trail?


@luca.tocchi

luca.tocchi
05 Oct 2020, 13:41

RE:

PanagiotisCharalampous said:

Hi Luca,

Here is the correct way to do this

                if (longPosition.Pips >= 50)
                    ModifyPosition(longPosition, longPosition.EntryPrice + Symbol.PipSize * 30, longPosition.TakeProfit);

Best Regards,

Panagiotis 

Join us on Telegram

thanks a lot!


@luca.tocchi

luca.tocchi
05 Oct 2020, 13:41

RE:

PanagiotisCharalampous said:

Hi Luca,

The information you need to access in not accessible from this indicator. You need to make the information accessibe e.g. through a public property, and then access it from the cBot.

Best Regards,

Panagiotis 

Join us on Telegram

Thanks!


@luca.tocchi

luca.tocchi
30 Sep 2020, 16:30

RE:</

PanagiotisCharalampous ha detto:

Ciao Luca,

Si prega di pubblicare questo nell'argomento corretto.

Migliori saluti

Panagiotis 

Unisciti a noi su Telegram

oh I'm sorry


@luca.tocchi

luca.tocchi
18 Sep 2020, 16:40

RE: RE:

firemyst said:

luca.tocchi said:

hi my bot should modify the stop loss (using ModifyOrder) when it reaches the stop loss minus 0.2 pips
how can I do?
 

thanks

//for long positions

if ((Symbol.Bid - CurrentStopLossValue) / Symbol.PipSize <= 0.2)

{

    //price is within 0.2 pips of SL

   p.ModifiyStopLossPips //or p.ModifyStopLossPrice depending on what you want to do

}

Thanks a lot!


@luca.tocchi

luca.tocchi
02 Sep 2020, 20:03

RE: RE:

firemyst said:

luca.tocchi said:

how do i check the direction of the moving averages in real time and if they go high i go buy if they go low i sell?

Thanks a lot

You get the current value of the MA and can compare it to the previous value to see if it's increasing or decreasing.

//example pseudo-code
if (ma.Result.Last(0) > ma.Result.Last(1))
    //open long position 
else if (ma.Result.Last(0) < ma.Result.Last(1))
    //open short position
else
   //the ma values are equal. What do you want to do?

 

Yes sure

but I have to check 3 moving averages, if all 3 are up go buy, if all 3 are down go sell

but if at least one of these averages goes in the opposite direction, the program must wait for all three to go in the same direction

I would be grateful if you could help me


@luca.tocchi

luca.tocchi
31 Aug 2020, 18:06

RE:

PanagiotisCharalampous said:

Hi Luca,

This will never trigger because you have programmed an infinite while loop. There is no way for the condition to become true.

Best Regards,

Panagiotis 

Join us on Telegram

 

what should i correct?

I thought that if the condition is true he waits, if it is false he exits the cycle


@luca.tocchi

luca.tocchi
27 Jul 2020, 11:26

RE:

PanagiotisCharalampous said:

Hi Luca,

Try this

if(args.Position.Label == "MyLabel1")
{
  // Do something...
}

You need to use a more precise language.

 Best Regards,

Panagiotis 

Join us on Telegram

awesome! thanks


@luca.tocchi

luca.tocchi
27 Jul 2020, 11:15

RE:

PanagiotisCharalampous said:

Hi Luca,

What do you mean when you say?

the bot does not recognize the position1 and position2 variables.

You need to use a more precise language.

 Best Regards,

Panagiotis 

Join us on Telegram

 

what I want to say: 

private void OnPositionsClosed(PositionClosedEventArgs args)
        {
            var position = args.Position;

        }

the function considers all positions that close regardless of the label

I need to tell him: if position 1 (var position1 = Positions.Find ("MyLabel1") is closed do this .. 

so also for other positions with different labels, 

but I can't ... because it considers all positions closed regardless of the label

 


@luca.tocchi

luca.tocchi
22 Jul 2020, 14:42

RE:

PanagiotisCharalampous said:

Hi Luca,

You can use AddHours() method.

Best Regards,

Panagiotis 

Join us on Telegram

 

using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class NewcBot : Robot
    {
        [Parameter(DefaultValue = 0.0)]
        public double Parameter { get; set; }

        protected override void OnStart()
        {
            Print(DateTime.Now);
            Print(DateTime.Now.AddHours(1));

            if (DateTime.Now.AddHours(1))
            {
                Print("ok");
           }
        }
    }
}

I want to print "ok" after 1 hour from power on

but so it gives me error

where am i wrong?


@luca.tocchi

luca.tocchi
22 Jul 2020, 14:28

RE:

 

thanks


@luca.tocchi

luca.tocchi
30 Jun 2020, 08:51

RE:

PanagiotisCharalampous said:

Hi Luca,

It is not possible to run a cBot when the computer is turned off. You can consider running your cBot on a VPS.

Best Regards,

Panagiotis 

Join us on Telegram

 

thanks

 


@luca.tocchi

luca.tocchi
24 Jun 2020, 16:34

RE:

PanagiotisCharalampous said:

Hi Luca,

You can use Symbol.Tick event to subscribe with more event handlers to the event.

Best Regards,

Panagiotis 

Join us on Telegram

 

 

thanks


@luca.tocchi

luca.tocchi
22 Jun 2020, 11:54

RE:

PanagiotisCharalampous said:

Hi Luca,

Yes correct.

Best Regards,

Panagiotis 

Join us on Telegram

thanks! have a nice day


@luca.tocchi

luca.tocchi
22 Jun 2020, 11:53

RE: RE:

luca.tocchi said:

PanagiotisCharalampous said:

Hi Luca,

You are not printing the last bar but the bar before. To get the last bar you need to use Last(0).

Best Regards,

Panagiotis 

Join us on Telegram

while the value of the penultimate candle is 1?

thanks

 


@luca.tocchi

luca.tocchi
22 Jun 2020, 11:52

RE: RE:

luca.tocchi said:

PanagiotisCharalampous said:

Hi Luca,

You are not printing the last bar but the bar before. To get the last bar you need to use Last(0).

Best Regards,

Panagiotis 

Join us on Telegram

while the value of the penultimate candle is 1?

thanks

 


@luca.tocchi

luca.tocchi
22 Jun 2020, 11:51

RE:

PanagiotisCharalampous said:

Hi Luca,

You are not printing the last bar but the bar before. To get the last bar you need to use Last(0).

Best Regards,

Panagiotis 

Join us on Telegram

thanks

 


@luca.tocchi