How to sop a winning trade from reopening again for a bit

To add comments, please log in or register
Tuck99
18
Tuck99  

Hello,


I have a function that opena a trade on signal idicators, but after it closes out of the trade it opens another one up again.

I'm wondering how to write a function that would would wait a half hour before it can open another one.


Code is

 if (!ExistPositions()){

      if ((Buy1=Buy2)){

         OpenBuy();

         return;

      }

What can I add to this function to make it work that way?


Thanks

Ahmad Zuhairdi Noh
6122
Ahmad Zuhairdi Noh  
Tuck99:

Hello,


I have a function that opena a trade on signal idicators, but after it closes out of the trade it opens another one up again.

I'm wondering how to write a function that would would wait a half hour before it can open another one.


Code is

 if (!ExistPositions()){

      if ((Buy1=Buy2)){

         OpenBuy();

         return;

      }

What can I add to this function to make it work that way?


Thanks

First, you put this guy before OnInit() (make it general statement)

int TimeHold = 0;


then change your current code to the following. Vuala! Now your trade will open once per hour. Goodluck.

if(!ExistPositions()) {     if ((Buy1=Buy2) && TimeHold != Hour())     {         OpenBuy();         TimeHold = Hour();         return;     } }

Maksim Emeliashin
189
Maksim Emeliashin  
You also, can check exists positions (for example, how near they are placed to the current price).
Tuck99
18
Tuck99  
Ahmad Zuhairdi Noh:

First, you put this guy before OnInit() (make it general statement)

int TimeHold = 0;


then change your current code to the following. Vuala! Now your trade will open once per hour. Goodluck.

Thanks. So, you mean after the first trade closes out, then it will wait an hour even if a buy order is sent to it before the hour is up?

To add comments, please log in or register