Topics
Replies

firemyst
11 Aug 2023, 00:31

I don't think you can check for that directly, however, what you can try is:

  1. compare the new SL price with the previous SL price
  2. if they're not equal, return from the method
  3. if they're still equal, then you know the SL hasn't changed.

@firemyst

firemyst
11 Aug 2023, 00:21

why it crash?

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


@firemyst

firemyst
10 Aug 2023, 00:31

-Catch the creation of the new brick

When the “OnBar” event happens.

Or write your own in the “OnTick” method:

_currentIndex = Bars.OpenTimes.GetIndexByTime(Bars.OpenTimes.LastValue);

               if (_currentIndex != _previousIndex)
               {
               //Call your own OnBar method
                   OnBarForBot();
                   _previousIndex = _currentIndex;
               }

 

-Get the color of the last brick

Do you mean actual color? Or is what you really want to know whether the bar closed up or down?

I'll assume the latter since most bots/indicators don't care about actual colors - just check if the previous close price is > or < the previous open price.

if (Bars.ClosePrices.Last(1) > Bars.OpenPrices.Last(1))

   ///bullish bar

else

   ///bearish bar

 


@firemyst

firemyst
08 Aug 2023, 23:42

@Spotware please delete this spam


@firemyst

firemyst
08 Aug 2023, 06:19

RE: RE: placelimitorder success

luca.tocchi said: 

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. 

Then do what I suggested. If the trade result is successful, you know you have a position. 


@firemyst

firemyst
08 Aug 2023, 00:05 ( Updated at: 21 Dec 2023, 09:23 )

You've done this?

Doing it manually through folder paths as you suggested, might not always work because you might not get the right folder (if there's bee multiple updates) or the data might be in more than one location


@firemyst

firemyst
08 Aug 2023, 00:03

They might consider it if you actually post this in the correct forum:

https://ctrader.com/forum/suggestions


@firemyst

firemyst
08 Aug 2023, 00:02 ( Updated at: 21 Dec 2023, 09:23 )

To make sure @Spotware sees this, please also report this issue and link to thread via the cTrader desktop app:


@firemyst

firemyst
07 Aug 2023, 23:58

If there's losing trades, you may want to consider leaving it as it is so you have to manually restart it. This does two things:

  1. makes sure your account doesn't blow up if it keeps continuously losing more than 3 trades
  2. gives you a chance to review the trades and what's happening.

 

If you really want it to start again the next day, you can try this:

  1. reset the losing count to 0
  2. keep track of the time. When your new day starts, allow the bot to proceed again. Something like this:

if (!allowTrades && Server.Time > 9am)

{

    allowTrades = true;

}

 

In your OnTick method:

if (allowTrades)

{

 ////rest of method

}

else

return;

 

and you'd have to update your code:

if (losercount == 3)

{

    allowTrades = false;

                            Stop();

}


@firemyst

firemyst
07 Aug 2023, 23:51

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) {

////

}


@firemyst

firemyst
07 Aug 2023, 00:13

You might get your wish if you post in the correct forum:

https://ctrader.com/forum/suggestions

 


@firemyst

firemyst
07 Aug 2023, 00:13 ( Updated at: 21 Dec 2023, 09:23 )

You need to have your charts in multichart mode and click this tool to do a little bit of what you want:


@firemyst

firemyst
07 Aug 2023, 00:04

POst a picture of your issue?


@firemyst

firemyst
07 Aug 2023, 00:03

Of course it's only doing buys. That's all you tell it to do. :-)

 

   private void OpenPosition(TradeType command)
        {
            ExecuteMarketOrder(TradeType.Buy, SymbolName, Volume, null, SL, TP);
        }

@firemyst

firemyst
05 Aug 2023, 00:28

@Spotware please delete this spam


@firemyst

firemyst
05 Aug 2023, 00:28

Just compile your bot without including the source code. That's how it is by default.


@firemyst

firemyst
03 Aug 2023, 00:34

@Spotware please delete this spam.


@firemyst

firemyst
02 Aug 2023, 12:05

Your code is saying get the fractal value from the last bar, not the actual last fractal value.

 

If that's not the case, then you need to post more of your code so people can see what's going on.


@firemyst

firemyst
02 Aug 2023, 12:01

You need to post this in the “Suggestions” forum


@firemyst

firemyst
02 Aug 2023, 12:00

Please keep us posted what you find out as I also use Pepperstone for one account.

Thank you.


@firemyst