Help

Created at 15 Oct 2013, 20:13
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
OL

Old Account

Joined 14.10.2013

Help
15 Oct 2013, 20:13


I have made a profitabel robot, but it only runs one cycle.

Right now i have my logich on OnStart(), but if i but it on on tick it makes over a 1000 positionsn

So if someone have a code for: When the position closes go back to start. (Repit)

Or a order limiter. ( Max Orders)

Thanks!


@Old Account
Replies

Cerunnos
16 Oct 2013, 09:38

RE:

MRSV said:

I have made a profitabel robot, but it only runs one cycle.

Right now i have my logich on OnStart(), but if i but it on on tick it makes over a 1000 positionsn

So if someone have a code for: When the position closes go back to start. (Repit)

Or a order limiter. ( Max Orders)

Thanks!

With the following simple solution you can limit maximum order number to one...

private bool IsOpenPosfalse;
...

protected override void OnTick()
{
if (!IsOpenPos)
            {
               if (_TDI.PriceSeries[Index] > _TDI.Middle[Index] && _TDI.PriceSeries[Index] > _TDI.SignalSeries[Index]) ...         
                       var request = new MarketOrderRequest(TradeType.Buy, vol)  
                        {                        
                        Label = "m10_Robot",
                        SlippagePips = 50,
                        StopLossPips = init_StopLoss                     
                        };  
                        Trade.Send(request);                        
                        IsOpenPostrue;                        
               }
}

 protected override void OnPositionClosed(Position closedPosition)
     {
      IsOpenPos = false;
     }


 

 


@Cerunnos

Old Account
16 Oct 2013, 10:49

RE: RE:

Cerunnos said:

MRSV said:

I have made a profitabel robot, but it only runs one cycle.

Right now i have my logich on OnStart(), but if i but it on on tick it makes over a 1000 positionsn

So if someone have a code for: When the position closes go back to start. (Repit)

Or a order limiter. ( Max Orders)

Thanks!

With the following simple solution you can limit maximum order number to one...

private bool IsOpenPosfalse;
...

protected override void OnTick()
{
if (!IsOpenPos)
            {
               if (_TDI.PriceSeries[Index] > _TDI.Middle[Index] && _TDI.PriceSeries[Index] > _TDI.SignalSeries[Index]) ...         
                       var request = new MarketOrderRequest(TradeType.Buy, vol)  
                        {                        
                        Label = "m10_Robot",
                        SlippagePips = 50,
                        StopLossPips = init_StopLoss                     
                        };  
                        Trade.Send(request);                        
                        IsOpenPostrue;                        
               }
}

 protected override void OnPositionClosed(Position closedPosition)
     {
      IsOpenPos = false;
     }


 

 

Thanks a lot Ceruunos!


@Old Account