Stop Signal

Created at 13 Jul 2016, 21:59
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!
NI

nirin

Joined 09.12.2013

Stop Signal
13 Jul 2016, 21:59


Hi All,

Can someone help please,

How can i stop the cbot order from an indicator signal when its last trade is a loss; or create an order at the middle of the stoploss and at the same time stop the signal? beacause the bot stil continues to take an order when its signal still true after a stoploss.

Thanks for your help! 


@nirin
Replies

cyfer
14 Jul 2016, 10:23

I usually do this through a Bool Swtich 

Lets say your signal is a Long Trade and before it's opened the Bot is waiting for the Signal 

In this case The Bool Switch (Lets Call it CanOpenLongTrade) will be true 

To initialize 

//initialize
private bool CanOpenLongTrade ;

//OnStart 

CanOpenLongTrade = True 

Now Your cBot Got the Signal , Let's say on OnTick Method , You test for the Validity of opening a Long Trade

if(Condition1 && Condition2 && CanOpenLongTrade)
{
 // Here you Execute the opening of the long trade
}

and at the same OnTick or OnBar method you Swich it Off

  

if(Condition1 && Condition2 && CanOpenLongTrade)
{
 // Here you Execute the opening of the long trade
 CanOpenLongTrade = false ;
}

Now it will not take the long signals again 

Still you must turn it back on , maybe after the Trade is closed , According to specific time or what ever you want 

The point is you :

-Start with the bool switch True

-Check for being true before a position is opened 

-Turn it off immediately after you open the trade

-Turn it back on again to allow the cBot to open another position 

 

 


@cyfer

nirin
14 Jul 2016, 18:55

Thanks a lot for your help cyfer!


@nirin