Topics

Forum Topics not found

Replies

cAlgo_Fanatic
04 Apr 2013, 10:07

Hello,

Local time:  DateTime.Now

The server time: Server.Time

To get the hour part: Server.Time.Hour

 


@cAlgo_Fanatic

cAlgo_Fanatic
03 Apr 2013, 17:49

In the robot simply use the values up to index -1. 


@cAlgo_Fanatic

cAlgo_Fanatic
03 Apr 2013, 17:28

The news feed is currently up to the broker to provide in the platforms. 


@cAlgo_Fanatic

cAlgo_Fanatic
03 Apr 2013, 11:24

The Stochastic Oscillator can be found here:

/forum/calgo-reference-samples/657

We will provide the MACD Crossover in the Samples section as well.


@cAlgo_Fanatic

cAlgo_Fanatic
03 Apr 2013, 11:01

You need to add a return statement when the index is 0 and remove the Print statement:

if (index == 0)
{   
   hp[index] = 0;
   return;
}

...
// remove Print("{0}", DC[index]);




@cAlgo_Fanatic

cAlgo_Fanatic
03 Apr 2013, 09:24

You may use this code if(IsRealTime) {...} or if (!IsRealTime) return; to calculate only for new bars.


@cAlgo_Fanatic

cAlgo_Fanatic
03 Apr 2013, 09:16

When you mouse over the candle you can see the prices on the bottom left corner of the platform window.


@cAlgo_Fanatic

cAlgo_Fanatic
02 Apr 2013, 14:36

More timeframes will be included in the future. Thank you for the suggestion for the P&L. We will consider it for a future implementation.


@cAlgo_Fanatic

cAlgo_Fanatic
02 Apr 2013, 14:31

This feature will be included in the future.


@cAlgo_Fanatic

cAlgo_Fanatic
02 Apr 2013, 14:31

We apologize for any inconvenience but It is not possible to do this for the time being.


@cAlgo_Fanatic

cAlgo_Fanatic
02 Apr 2013, 11:54 ( Updated at: 23 Jan 2024, 13:15 )

Please see this sample for a custom RSI indicator: [/forum/calgo-reference-samples/655]

and for Stochastics:  [/forum/calgo-reference-samples/657]


@cAlgo_Fanatic

cAlgo_Fanatic
02 Apr 2013, 11:07

Hello,

Thank you for your kind words.

If it hits Trigger1, it will close positions if it retraces to Stopout1 before it reaches Trigger2. 
If it hits Trigger2, without/before retracing to Stopout1, close all positions if it retraces to Stopout2.
If this is correct then you are correct, you would have to set Trigger1 to false if Trigger2 becomes true.

private bool targetlevel1;
private bool targetlevel2;
//...

protected override void OnTick()
{
    if (Account.Equity >= Target1)
        targetlevel1 = true;
    if (Account.Equity >= Target2)
    {
        targetlevel2 = true;
        targetlevel1 = false;
    }
    if (targetlevel2 && Account.Equity <= Stopout2)
    {
        Trade.Close(position);
    }
    else if (targetlevel1 && Account.Equity <= Stopout1)
    {
        Trade.Close(position);
    }
}




@cAlgo_Fanatic

cAlgo_Fanatic
29 Mar 2013, 14:54

Hello,

Try this code:

public override void Calculate(int index)
{
    if (index == 0) return;

    DateTime currentTime = MarketSeries.OpenTime[index];
    DateTime previousTime = MarketSeries.OpenTime[index-1];

    if(currentTime.Month != previousTime.Month)
    {
        // first bar of the month           
    }
    if(currentTime.DayOfWeek == DayOfWeek.Monday && previousTime.DayOfWeek != DayOfWeek.Monday)
    {
        // first bar of the week        
    }
    if(currentTime.Date != previousTime.Date)
    {
        // first bar of the day        
    }
    //...


 

 


@cAlgo_Fanatic

cAlgo_Fanatic
29 Mar 2013, 12:17

Hello,

Did our previous reply help you resolve this issue? I'm assuming you meant to say month is replaced by hour in your last post.


@cAlgo_Fanatic

cAlgo_Fanatic
29 Mar 2013, 10:37

Hello,

It is only possible with indicators that are plotted on the chart like moving averages.


@cAlgo_Fanatic

cAlgo_Fanatic
29 Mar 2013, 10:04

The boolean variables need to be declared on an outer scope. 

I probably misunderstood the logic intended. Please try this code:

 

private bool targetlevel1;
private bool targetlevel2;
//...

protected override void OnTick()
{
    if (Account.Equity >= Target1)
        targetlevel1 = true;
    if (Account.Equity >= Target2)
        targetlevel2 = true;

    if (targetlevel1 && Account.Equity <= Stopout1)
    {
        Trade.Close(position);
    }

    if (targetlevel2 && Account.Equity <= Stopout2)
    {
        Trade.Close(position);
    }
}

 

 


@cAlgo_Fanatic

cAlgo_Fanatic
29 Mar 2013, 09:24

Hello,

You can declare a field for position that will be set when the position opens and set to null when it closes. Prior to the code that executes the trade requests check that this field is null. Therefore, you will not start a new trade if there is an open position by this robot.

private Position position;

[Parameter]
public DataSeries Source { get; set; }
// ...

 protected override void OnBar()
 {
     if (Trade.IsExecuting || position != null)
         return;
    // ...
}
protected override void OnPositionOpened(Position openedPosition)
{
      position = openedPosition; 
}
protected override void OnPositionClosed(Position closedPosition)
{
      position = null;
}





@cAlgo_Fanatic

cAlgo_Fanatic
28 Mar 2013, 11:50

Try this and let us know if it is what you are intending:

        protected override void OnTick()
        {
            //Reached targetStop2
            if(targetStop2)
                Trade.Close(position);
            else if(targetlevel2)
                targetStop2 = Account.Equity <= Stopout2;
            else if(targetStop1)
                targetlevel2 = Account.Equity >= Target2;
            else if(targetlevel1)
                targetStop1 = Account.Equity <= Stopout1;
            else
                targetlevel1 = Account.Equity >= Target1;
        }




@cAlgo_Fanatic

cAlgo_Fanatic
28 Mar 2013, 09:21

Thank you for the suggestion we will consider it for future implementations.


@cAlgo_Fanatic

cAlgo_Fanatic
27 Mar 2013, 17:49

Hello,

Try this string format: "dd/MM/yyyy hh:mm:ss.fff". You need capital MM for month. Lower mm is used for minutes in this case.

Please see: Custom Date and Time Format Strings for more examples.


@cAlgo_Fanatic